yolov7_d2
yolov7_d2 copied to clipboard
How to perform inference for instance segmentation trained on custom data?
I tried using demo.py using this command python demo.py --config-file output/field_yolomask/config.yaml --input a.png -c 0.2 --output detectasd --opts MODEL.WEIGHTS output/field_yolomask/model_final.pth
However, I am getting the following error every time: return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode) cost: 3.240492105484009, fps: 0.3085951045236808 0%| | 0/1 [00:03<?, ?it/s] Traceback (most recent call last): File "demo.py", line 229, in <module> res = vis_res_fast(res, im, class_names, colors, conf_thresh) File "demo.py", line 152, in vis_res_fast img = vis_bitmasks_with_classes( File "C:\Users\Abhipray\anaconda3\envs\detectron\lib\site-packages\alfred\vis\image\mask.py", line 302, in vis_bitmasks_with_classes txt = f'{class_names[classes[i]]}' TypeError: list indices must be integers or slices, not numpy.float32
I tried changing classes=None in vis_bitmasks_with_classes, but no luck. @jinfagang Could you please help me with this? Thanks in advance.
HiοΌthis seems a bug, can u send me a PR?
Just modify the demo.py vis_fast function, make sure the classes send into vis_mask function is numpy array int rather than list of float.
Normally this shouldn't happen except your dataset has some wrong labeling
in demo.py line 145 clss = ins.pred_classes.cpu().numpy() <-- results clss could be float32 force to int will solve this problem, like below clss = ins.pred_classes.cpu().numpy().astype(int)