{"action":"created","issue":{"url":"https://api.github.com/repos/ayooshkathuria/YOLO_v3_tutorial_from_scratch/issues/10","repository_url":"https://api.github.com/repos/ayooshkathuria/YOLO_v3_tutorial_from_scratch","labels_url":"https://api.github.com/repos/ayooshkathuria/YOLO_v3_tutorial_from_scratch/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/ayooshkathuria/YOLO_v3_tutorial_from_scratch/issues/10/comments","events_url":"https://api.github.com/repos/ayooshkathuria/YOLO_v3_tutorial_from_scratch/issues/10/events","html_url":"https://github.com/ayooshkathuria/YOLO_v3_tutorial_from_scratch/issues/10","id":318704119,"number":10,"title":"torch.FloatTensor type error","user":{"login":"cloudliu01","id":15914527,"avatar_url":"https://avatars2.githubusercontent.com/u/15914527?v=4","gravatar_id":"","url":"https://api.github.com/users/cloudliu01","html_url":"https://github.com/cloudliu01","followers_url":"https://api.github.com/users/cloudliu01/followers","following_url":"https://api.github.com/users/cloudliu01/following{/other_user}","gists_url":"https://api.github.com/users/cloudliu01/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudliu01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudliu01/subscriptions","organizations_url":"https://api.github.com/users/cloudliu01/orgs","repos_url":"https://api.github.com/users/cloudliu01/repos","events_url":"https://api.github.com/users/cloudliu01/events{/privacy}","received_events_url":"https://api.github.com/users/cloudliu01/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-04-29T09:49:18Z","updated_at":"2018-04-29T11:36:24Z","closed_at":"2018-04-29T11:36:24Z","author_association":"NONE","body":"Without any changes on the code downloaded, when I ran command 'python detect.py --images imgs --det det', I got errors below:\r\n\r\n> Loading network.....\r\nNetwork successfully loaded\r\n\r\n> 256.4507   62.3959  374.7849  120.3694    0.9988    0.9377    7.0000\r\n 265.0707   62.5722  379.6248  121.3135    0.9726    0.8795    7.0000\r\n 254.2707   69.4995  376.2362  125.0286    0.9040    0.9200    7.0000\r\n  58.2381   80.8954  312.3383  296.0082    0.9004    0.9983    1.0000\r\n  61.3210   58.3361  311.3177  316.3376    0.8639    0.9972    1.0000\r\n  89.2337   73.0579  308.4990  302.5144    0.9240    0.9960    1.0000\r\n  63.8950   89.8635  308.2446  312.9947    0.9908    0.9991    1.0000\r\n  54.9051   76.0959  312.2937  337.0284    0.9859    0.9981    1.0000\r\n  87.4243   84.2302  307.2956  313.9760    0.9861    0.9996    1.0000\r\n  66.4022   72.3304  323.7131  332.9052    0.5739    0.9988    1.0000\r\n  59.7964  112.0306  173.2647  379.6315    0.9257    0.9818   16.0000\r\n  66.6987  160.9137  173.3377  393.2019    0.9999    0.9980   16.0000\r\n  73.8193  154.1310  187.0550  391.4006    0.9704    0.9931   16.0000\r\n  63.6121  176.9761  171.9654  404.1670    0.9892    0.9789   16.0000\r\n[torch.cuda.FloatTensor of size 14x7 (GPU 0)]\r\n\r\n>Traceback (most recent call last):\r\n  File \"detect.py\", line 126, in <module>\r\n    prediction = write_results(prediction, confidence, num_classes, nms_conf = nms_thesh)\r\n  File \"/media/lliu/hdd4/YOLO_v3_tutorial_from_scratch/YOLO_v3_tutorial_from_scratch-master/util.py\", line 159, in write_results\r\n    ious = bbox_iou(image_pred_class[i].unsqueeze(0), image_pred_class[i+1:])\r\n  File \"/media/lliu/hdd4/YOLO_v3_tutorial_from_scratch/YOLO_v3_tutorial_from_scratch-master/util.py\", line 43, in bbox_iou\r\n    iou = inter_area / (b1_area + b2_area - inter_area)\r\n  File \"/home/lliu/.conda/envs/pyTorch_35_new/lib/python3.5/site-packages/torch/tensor.py\", line 300, in __sub__\r\n    return self.sub(other)\r\nTypeError: sub received an invalid combination of arguments - got (torch.FloatTensor), but expected one of:\r\n> * (float value)\r\n      didn't match because some of the arguments have invalid types: (torch.FloatTensor)\r\n> * (torch.cuda.FloatTensor other)\r\n      didn't match because some of the arguments have invalid types: (torch.FloatTensor)\r\n> * (float value, torch.cuda.FloatTensor other)\r\n\r\nAfter tracing it back I found it's an bug in line 37, util.py: All the variables before this line are in **(GPU 0)**, whereas the output **inter_area** of this line doesn't contain **(GPU 0)**, which causes the subsequent **iou** calculation failed (line 43).\r\n\r\nThe data inspection of **inter_rect_x2**, note the **(GPU 0)**:\r\n>In [5]: inter_rect_x2\r\nOut[5]: \r\n\r\n> 307.2956\r\n 308.2446\r\n 308.2446\r\n 308.2446\r\n 308.2446\r\n 308.2446\r\n[torch.cuda.FloatTensor of size 6 (GPU 0)]\r\n\r\nThe data inspection of **inter_area** :\r\n> In [4]: inter_area\r\nOut[4]: \r\n\r\n> 49504.1289\r\n 54990.4844\r\n 47005.5273\r\n 50822.8750\r\n 54990.4844\r\n 54428.5430\r\n[torch.FloatTensor of size 6]\r\n\r\nTo fix the issue, I just simply added the .cuda() function to the np commands in line 37:\r\n> inter_area = np.maximum(inter_rect_x2 - inter_rect_x1 + 1, 0).cuda()*np.maximum(inter_rect_y2 - inter_rect_y1 + 1, 0).cuda()\r\n\r\n\r\nThis seems working to me; however, I don't know why just me saw this issue. Wrote this down for others reference.\r\n\r\nBTW, I am using Pytorch 0.3, cuda 8 and cudnn 6\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ayooshkathuria/YOLO_v3_tutorial_from_scratch/issues/comments/385244754","html_url":"https://github.com/ayooshkathuria/YOLO_v3_tutorial_from_scratch/issues/10#issuecomment-385244754","issue_url":"https://api.github.com/repos/ayooshkathuria/YOLO_v3_tutorial_from_scratch/issues/10","id":385244754,"user":{"login":"ayooshkathuria","id":22730263,"avatar_url":"https://avatars2.githubusercontent.com/u/22730263?v=4","gravatar_id":"","url":"https://api.github.com/users/ayooshkathuria","html_url":"https://github.com/ayooshkathuria","followers_url":"https://api.github.com/users/ayooshkathuria/followers","following_url":"https://api.github.com/users/ayooshkathuria/following{/other_user}","gists_url":"https://api.github.com/users/ayooshkathuria/gists{/gist_id}","starred_url":"https://api.github.com/users/ayooshkathuria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ayooshkathuria/subscriptions","organizations_url":"https://api.github.com/users/ayooshkathuria/orgs","repos_url":"https://api.github.com/users/ayooshkathuria/repos","events_url":"https://api.github.com/users/ayooshkathuria/events{/privacy}","received_events_url":"https://api.github.com/users/ayooshkathuria/received_events","type":"User","site_admin":false},"created_at":"2018-04-29T11:36:24Z","updated_at":"2018-04-29T11:36:24Z","author_association":"OWNER","body":"I've fixed the issue. It works fine on GPU now. "}}
{"actor":{"display_login":"ayooshkathuria"}}