You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanna split the origin dataset (coco json format) to train and test parts.
Therefore, I compared 2 methods by register_coco_instance and load_coco_json, and get the dicts respectively.
register_coco_instances("my_dataset", {}, "./dataset/annotations/train_test2017.json", "./dataset/JPEGImages")
a = DatasetCatalog.get("my_dataset")
# or
metadata = MetadataCatalog.get("my_dataset").set(
thing_classes = ["ship"],
thing_dataset_id_to_contiguous_id = {1: 0},
json_file=json_path,
image_root=img_path,
evaluator_type='coco',
)
a = load_coco_json(json_path, img_path)
DatasetCatalog.register("my_dataset", lambda: a)
both of which follow the tutorials.
however, it faced issue when implementing visualization code: visualizer = Visualizer(img[:, :, ::-1], metadata=metadata, scale=0.5, instance_mode=ColorMode.IMAGE_BW) out = visualizer.draw_dataset_dict(d)
problem / log
what is weird is that method 1 went smoothly yet method 2 went wrong and shows
File "h:\github\training\self_dataload.py", line 56, in <module>
out = visualizer.draw_dataset_dict(d)
File "h:\github\detectron2\detectron2\utils\visualizer.py", line 589, in draw_dataset_dict
labels = _create_text_labels(
File "h:\github\detectron2\detectron2\utils\visualizer.py", line 244, in _create_text_labels
labels = [class_names[i] for i in classes]
File "h:\github\detectron2\detectron2\utils\visualizer.py", line 244, in <listcomp>
labels = [class_names[i] for i in classes]
IndexError: list index out of range
Environment:
common windows environment
python 3.10
solution:
I faced the same question with #546
I check the source code and debug it. It turned out that the IDs of my categories started at 1 and not as expected at 0.
The problem should be solved by setting an internal parameter thing_dataset_id_to_contiguous_id in the metadata of the dataset. However, during my debugging, no matter how I set the parameter by metadata = MetadataCatalog.get("my_dataset").set(), the visualizer cant solve the mapping. I also try to register by a = load_coco_json(json_path, img_path, "my_dataset_1")(very similar to method 2 but register automatically and i cant filter or change the dataset manually), in that case, even i dont set the metadata, The visualizer can understand the mapping and shows the image.
Above all, I deduce that self-setting metadata in coco format cant be understood by function visualizer.draw_dataset_dict(d), or even worse by the trainer( i haven't check but since the register_coco_instance works well, I doubt if the self-setting metadata works at all).
The text was updated successfully, but these errors were encountered:
You've chosen to report an unexpected problem or bug. Unless you already know the root cause of it, please include details about it by filling the issue template.
The following information is missing: "Instructions To Reproduce the Issue and Full Logs";
Instructions To Reproduce the 🐛 Bug:
description:
I wanna split the origin dataset (coco json format) to train and test parts.
Therefore, I compared 2 methods by
register_coco_instance
andload_coco_json
, and get the dicts respectively.both of which follow the tutorials.
however, it faced issue when implementing visualization code:
visualizer = Visualizer(img[:, :, ::-1], metadata=metadata, scale=0.5, instance_mode=ColorMode.IMAGE_BW)
out = visualizer.draw_dataset_dict(d)
problem / log
what is weird is that method 1 went smoothly yet method 2 went wrong and shows
Environment:
common windows environment
python 3.10
solution:
I faced the same question with #546
I check the source code and debug it. It turned out that the IDs of my categories started at 1 and not as expected at 0.
The problem should be solved by setting an internal parameter
thing_dataset_id_to_contiguous_id
in the metadata of the dataset. However, during my debugging, no matter how I set the parameter bymetadata = MetadataCatalog.get("my_dataset").set()
, the visualizer cant solve the mapping. I also try to register bya = load_coco_json(json_path, img_path, "my_dataset_1")
(very similar to method 2 but register automatically and i cant filter or change the dataset manually), in that case, even i dont set the metadata, The visualizer can understand the mapping and shows the image.Above all, I deduce that self-setting metadata in coco format cant be understood by function visualizer.draw_dataset_dict(d), or even worse by the trainer( i haven't check but since the
register_coco_instance
works well, I doubt if the self-setting metadata works at all).The text was updated successfully, but these errors were encountered: