facebookresearch / detectron2

Detectron2 is a platform for object detection, segmentation and other visual recognition tasks.
https://detectron2.readthedocs.io/en/latest/
Apache License 2.0
29.43k stars 7.33k forks source link

Use custom dataset #1457

Closed Ilbotre closed 4 years ago

Ilbotre commented 4 years ago

I'm registering a new dataset for people detection purpose following your docs:https://detectron2.readthedocs.io/tutorials/datasets.html. All the annotations in this dataset, not in COCO format, are just of person. So, taking into account the wanted format of a dataset in detectron 2 I place in the "category_id" field present in "annotations"list[dict] the corresponding int value according to COCO annotations, that is 1 since I have only person annotations: obj = { "bbox": [x0, y0, w, h], "bbox_mode": BoxMode.XYWH_ABS, "category_id": 1, # Since I have just person annotations "iscrowd": 0 }

Then, when I want to register dataset metadata as follow: MetadataCatalog.get("my_dataset").thing_classes = ["person"]

I got this error:

File "/home/nicolo/Desktop/deep_learning/deep_vision/deep_vision/dataset/kaist_2015/data_preprocessing.py", line 212, in dataset_dicts_lwir, dataset_dicts_rgb = main()

File "/home/nicolo/Desktop/deep_learning/deep_vision/deep_vision/dataset/kaist_2015/data_preprocessing.py", line 205, in main check_dataset_is_loaded_correctly(dataset_dicts_lwir, "kaist_lwir_train", n_img_to_visualize=5)

File "/home/nicolo/Desktop/deep_learning/deep_vision/deep_vision/engine/transfer_learning.py", line 150, in check_dataset_is_loaded_correctly vis = visualizer.draw_dataset_dict(d)

File "/home/nicolo/.conda/envs/detectron2/lib/python3.7/site-packages/detectron2/utils/visualizer.py", line 494, in draw_dataset_dict labels = [names[i] for i in labels]

File "/home/nicolo/.conda/envs/detectron2/lib/python3.7/site-packages/detectron2/utils/visualizer.py", line 494, in labels = [names[i] for i in labels]

IndexError: list index out of range

In order to avoid this issue I HAVE TO put inside the "category_id" field present in "annotations" list[dict] a 0, as following: obj = { "bbox": [x0, y0, w, h], "bbox_mode": BoxMode.XYWH_ABS, "category_id": 0, # With 1 I fetch the above IndexError "iscrowd": 0 }

Why I can't express properly the category_id of my annotations according to COCO stardards?

ppwwyyxx commented 4 years ago

The documentation https://detectron2.readthedocs.io/tutorials/datasets.html says:

category_id (int): an integer in the range [0, num_categories) representing the category label.

Ilbotre commented 4 years ago

If I make in that way I will obtain the error that I was talking about in this issue

ppwwyyxx commented 4 years ago

category_id should be 0 according to the above documentation.

Ilbotre commented 4 years ago

Sorry but category_id should’t be equal to 1 since all my annotations are of people?

Ilbotre commented 4 years ago

Sorry but I have understood what you meant only right now. Thank you