Please read & provide the following #4796
Replies: 1 comment
-
When registering like this getting TypeError: '<' not supported between instances of 'numpy.str_' and 'int' |
Beta Was this translation helpful? Give feedback.
-
When registering like this getting TypeError: '<' not supported between instances of 'numpy.str_' and 'int' |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
If you do not know the root cause of the problem, please post according to this template:
Instructions To Reproduce the Issue:
Creating dict from COCO JSON here:
def get_corrosion_dicts(img_dir,json_file):
dataset_dicts = []
f = open(json_file)
data = json.load(f)
ctr=0
for i in range(len(data['images'])):
record = {}
annotations=[]
filename = os.path.join(img_dir+data['images'][i]["file_name"])
record["file_name"] = filename
record["sem_seg_file_name"] = filename
record["sem_seg"] = "True"
record["image_id"] = data['images'][i]["id"]
record["height"] = data['images'][i]["height"]
record["width"] = data['images'][i]["width"]
dataset_dicts = get_corrosion_dicts(,)
DatasetCatalog.register("coco_train", lambda d=d: get_corrosion_dicts("/content/Blisters/","/content/Train_Coco.json"))
MetadataCatalog.get("coco_train").set(thing_classes=["Blisters"])
MetadataCatalog.get("coco_train").set(stuff_classes=["Blisters"])
dataset_dicts = get_corrosion_dicts(,)
for d in random.sample(dataset_dicts, 3):
img = cv2.imread(d["file_name"])
visualizer = Visualizer(img[:, :, ::-1], metadata=coco_metadata, scale=0.5)
out = visualizer.draw_dataset_dict(d)
cv2_imshow(out.get_image()[:, :, ::-1])
https://colab.research.google.com/drive/1gbSuwvct8gyBNVMBebgSsEeYRT20Qe7Q?usp=sharing
out = visualizer.draw_dataset_dict(d)
ERROR :
/usr/local/lib/python3.8/dist-packages/detectron2/utils/visualizer.py in (.0)
242 if classes is not None:
243 if class_names is not None and len(class_names) > 0:
--> 244 labels = [class_names[i] for i in classes]
245 else:
246 labels = [str(i) for i in classes]
IndexError: list index out of range
wget -nc -nv https://github.com/facebookresearch/detectron2/raw/main/detectron2/utils/collect_env.py && python collect_env.py
Beta Was this translation helpful? Give feedback.
All reactions