andy-yun / pytorch-0.4-yolov3

Yet Another Implimentation of Pytroch 0.4.1 and YoloV3 on python3
MIT License
279 stars 72 forks source link

detection error #63

Closed hareesh00 closed 5 years ago

hareesh00 commented 5 years ago

Hi,

I tried to detect the bounding boxes with pretrained weights. But I am facing the error. Pytorch version in my system : 0.4.1.post2

Error Mesage : Can you please suggest the fix. Loading weights from yolov3.weights... Done! data/dog.jpg: Predicted in 1.102185 seconds. 3 box(es) is(are) found Traceback (most recent call last): File "detect.py", line 113, in detect(cfgfile, weightfile, imgfile) File "detect.py", line 39, in detect plot_boxes(img, boxes, 'predictions.jpg', class_names) File "/home/hareeshkumawat/GitHub/adv/A3/utils.py", line 305, in plot_boxes print('%s: %f' % (class_names[cls_id], cls_conf)) TypeError: list indices must be integers or slices, not float

andy-yun commented 5 years ago

@hareesh00 in 304th line, change cls_id = int(box[6]). After version upgrading, array index may be stricted.

sdustdk1427 commented 5 years ago

但是修改之后又出现了这个问题: Traceback (most recent call last): File "detect.py", line 113, in detect(cfgfile, weightfile, imgfile) File "detect.py", line 39, in detect plot_boxes(img, boxes, 'predictions.jpg', class_names) File "/public/home/G19850028/RWJ/pytorch-0.4-yolov3-master/utils.py", line 312, in plot_boxes drawtext(img, (x1, y1), text, bgcolor=rgb, font=font) File "/public/home/G19850028/RWJ/pytorch-0.4-yolov3-master/utils.py", line 275, in drawtext img.paste(box_img, (sx, sy)) File "/public/home/G19850028/zheng/Anacoda3/public/home/G19850028/anacoda35/envs/pytorch0.4/lib/python3.6/site-packages/PIL/Image.py", line 1472, in paste self.im.paste(im, box) TypeError: integer argument expected, got float 这要怎么修改?谢谢

andy-yun commented 5 years ago

@sdustdk1427 Ok, you change the 271th codes as : sx, sy = int(pos[0]), int(pos[1]-th-2) I'll update the code.