WongKinYiu / yolov9

Implementation of paper - YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information
GNU General Public License v3.0
9k stars 1.43k forks source link

predicting for segmentation #219

Open SanidhyaSharma28 opened 8 months ago

SanidhyaSharma28 commented 8 months ago

I have trained and received the weights file after training but i am unable to predict i am newbie just exploring any help is appreciated i am using this command !python predict.py --img 640 --conf 0.1 --device 0 --weights /content/yolov9/segment/yolov9/runs/train-seg/exp3/weights/best.pt --source /content/drive/MyDrive/YoloData/train/images/0006_image.png

segment/predict: weights=['/content/yolov9/segment/yolov9/runs/train-seg/exp3/weights/best.pt'], source=/content/drive/MyDrive/YoloData/train/images/0006_image.png, data=../data/coco128.yaml, imgsz=[640, 640], conf_thres=0.1, iou_thres=0.45, max_det=1000, device=0, view_img=False, save_txt=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=../runs/predict-seg, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False, vid_stride=1, retina_masks=False YOLOv5 🚀 1e33dbb Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4, 15102MiB)

Fusing layers... yolov7-af-seg summary: 281 layers, 45841619 parameters, 0 gradients, 172.3 GFLOPs Traceback (most recent call last): File "/content/yolov9/segment/yolov9/segment/predict.py", line 246, in main(opt) File "/content/yolov9/segment/yolov9/segment/predict.py", line 241, in main run(*vars(opt)) File "/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(args, **kwargs) File "/content/yolov9/segment/yolov9/segment/predict.py", line 126, in run masks = process_mask(proto[i], det[:, 6:], det[:, :4], im.shape[2:], upsample=True) # HWC File "/content/yolov9/segment/yolov9/utils/segment/general.py", line 54, in process_mask c, mh, mw = protos.shape # CHW AttributeError: 'list' object has no attribute 'shape' could be a basic error too idk any help is very much appreciated

BaselOmari commented 8 months ago

Facing the same issue

er778899789 commented 8 months ago

I have the same issue

SanidhyaSharma28 commented 8 months ago

@WongKinYiu please provide some data on working with segmentation model or is it same as yolov7

wojhok commented 7 months ago

Same there

wojhok commented 7 months ago

Okay, I think i found a solution for this one. You have to change line where process_mask function is called. So inside segment/predict.py change:

masks = process_mask(proto[i], det[:, 6:], det[:, :4], im.shape[2:], upsample=True) # HWC

into:

masks = process_mask(proto[2].squeeze(0), det[:, 6:], det[:, :4], im.shape[2:], upsample=True)  # HWC

That fixed the problem for me.

lkpopo commented 6 months ago

Okay, I think i found a solution for this one. You have to change line where process_mask function is called. So inside segment/predict.py change:

masks = process_mask(proto[i], det[:, 6:], det[:, :4], im.shape[2:], upsample=True) # HWC

into:

masks = process_mask(proto[2].squeeze(0), det[:, 6:], det[:, :4], im.shape[2:], upsample=True)  # HWC

That fixed the problem for me.

Great Job!!!