facebookresearch / facebookresearch/detectron2
KeyError: 'thing_dataset_id_to_contiguous_id'
- Dominant language
- Python
- Stars
- 34.7k
- Forks
- 7.9k
- PR merge metrics
- No merged PRs in 30d
Description
Hi guys, i am trying to register and train a `custom panoptic dataset`. I have converted the annotations to coco format.
I have only one concretcrack class and then the following is the format of the `panoptic annotations`
```
{
"info": {...},
"images": [
{
"id": 263,
"width": 4032,
"height": 3024,
"file_name": "000263.jpg"
}, ...
...
],
"annotations": [
{
"image_id": 263,
"file_name": "000263_GT.png",
"segments_info": [
{
"id": 39372,
"category_id": 1,
"bbox": [
0.0,
803.0,
4032.0,
2221.0
],
"iscrowd": 0,
"area" : 128846
}
]
}, ...
...
"categories": [
{
"supercateory": "korad",
"isthing" : 1,
"id" : 1,
"name" : "ConcreteCrack",
"color": [
0,
153,
204
]
}
]
}
```
## Instructions To Reproduce the Issue:
```python3
from detectron2.data.datasets import register_coco_panoptic, register_coco_panoptic_separated, load_coco_json
from detectron2.data import DatasetCatalog, MetadataCatalog
from detectron2.data.datasets.coco_panoptic import load_coco_panoptic_json
if 'ConcreteCrack' in DatasetCatalog.list():
DatasetCatalog.remove('ConcreteCrack')
register_coco_panoptic("ConcreteCrack",{},"./datasets/crack/train2022/","./datasets/crack/panoptic_train2022/",
"./datasets/crack/annotations/panoptic_train2022.json","./datasets/crack/annotations/instances_train2022.json")
MetadataCatalog.get("ConcreteCrack").thing_classes = ["ConcreteCrack"]
dicts = load_coco_panoptic_json('./datasets/crack/annotations/panoptic_train2022.json','./datasets/crack/train2022/',
'./datasets/crack/panoptic_train2022/',{})
```
## However I got the following error:
```python3
Output exceeds the [size limit](command:workbench.action.openSettings?[). Open the full output data [in a text editor](command:workbench.action.openLargeOutput?9c19538d-6c07-4802-8860-9bb873fd1456)
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In [9], line 16
13 register_coco_panoptic("ConcreteCrack",{},"./datasets/crack/train2022/","./datasets/crack/panoptic_train2022/",
14 "./datasets/crack/annotations/panoptic_train2022.json","./datasets/crack/annotations/instances_train2022.json")
15 MetadataCatalog.get("ConcreteCrack").thing_classes = ["ConcreteCrack"]
---> 16 dicts = load_coco_panoptic_json('./datasets/crack/annotations/panoptic_train2022.json','./datasets/crack/train2022/',
17 './datasets/crack/panoptic_train2022/',{})
File ~/vsc/Mask2Former/seg/lib/python3.8/site-packages/detectron2/data/datasets/coco_panoptic.py:51, in load_coco_panoptic_json(json_file, image_dir, gt_dir, meta)
49 image_file = os.path.join(image_dir, os.path.splitext(ann["file_name"])[0] + ".jpg")
50 label_file = os.path.join(gt_dir, ann["file_name"])
---> 51 segments_info = [_convert_category_id(x, meta) for x in ann["segments_info"]]
52 ret.append(
53 {
54 "file_name": image_file,
(...)
58 }
59 )
60 assert len(ret), f"No images found in {image_dir}!"
File ~/vsc/Mask2Former/seg/lib/python3.8/site-packages/detectron2/data/datasets/coco_panoptic.py:51, in (.0)
49 image_file = os.path.join(image_dir, os.path.splitext(ann["file_name"])[0] + ".jpg")
50 label_file = os.path.join(gt_dir, ann["file_name"])
---> 51 segments_info = [_convert_category_id(x, meta) for x in ann["segments_info"]]
...
29 segment_info["category_id"]
30 ]
31 segment_info["isthing"] = True
KeyError: 'thing_dataset_id_to_contiguous_id'
```
How can i fix the problem? thx :)
Contributor guide
Assessment
This issue has not been assessed yet.