Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

运行detect.py时遇到了问题,这该怎么解决呢 #25

Open
littlelight-e opened this issue Aug 8, 2021 · 3 comments
Open

运行detect.py时遇到了问题,这该怎么解决呢 #25

littlelight-e opened this issue Aug 8, 2021 · 3 comments

Comments

@littlelight-e
Copy link

Fusing layers...
Model Summary: 188 layers, 2.22122e+07 parameters, 0 gradients
image 1/1 D:\Weld inspection\YOLOv5\rotation-yolov5-master\inference\images\1.tif: Traceback (most recent call last):
File "D:\Weld inspection\YOLOv5\rotation-yolov5-master\detect.py", line 174, in
detect()
File "D:\Weld inspection\YOLOv5\rotation-yolov5-master\detect.py", line 79, in detect
pred = rotate_non_max_suppression(pred, opt.conf_thres, opt.iou_thres, classes=opt.classes, agnostic=True)
File "D:\Weld inspection\YOLOv5\rotation-yolov5-master\utils\general.py", line 869, in rotate_non_max_suppression
i = nms(boxes, scores)
File "D:\Weld inspection\YOLOv5\rotation-yolov5-master\utils\general.py", line 797, in nms
rotate_ious = rotate_iou(max_iou_boxes[-1], sort_boxes[1:])
File "D:\Weld inspection\YOLOv5\rotation-yolov5-master\utils\general.py", line 710, in rotate_iou
r_b1 = get_rotated_coors(box1[i])
File "D:\Weld inspection\YOLOv5\rotation-yolov5-master\utils\general.py", line 729, in get_rotated_coors
R[:2] = cv2.getRotationMatrix2D(angle=-a*180/math.pi, center=(cx,cy), scale=1)
TypeError: Can't parse 'center'. Sequence item with index 0 has a wrong type

@littlelight-e
Copy link
Author

这个错误只要把OpenCV版本切换到4.2即可解决,但是又遇到了新问题如下,猜想会不会是因为torch的版本问题,我想将torch版本切换到1.6可是,提示我不能切换。
image 1/1 D:\Weld inspection\YOLOv5\rotation-yolov5-master\inference\images\1.tif: D:\Weld inspection\YOLOv5\rotation-yolov5-master\venv\lib\site-packages\torch\nn\functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at ..\c10/core/TensorImpl.h:1156.)
return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)
Traceback (most recent call last):
File "D:/Weld inspection/YOLOv5/rotation-yolov5-master/detect.py", line 174, in
detect()
File "D:/Weld inspection/YOLOv5/rotation-yolov5-master/detect.py", line 79, in detect
pred = rotate_non_max_suppression(pred, opt.conf_thres, opt.iou_thres, classes=opt.classes, agnostic=True)
File "D:\Weld inspection\YOLOv5\rotation-yolov5-master\utils\general.py", line 870, in rotate_non_max_suppression
i = nms(boxes, scores)
File "D:\Weld inspection\YOLOv5\rotation-yolov5-master\utils\general.py", line 798, in nms
rotate_ious = rotate_iou(max_iou_boxes[-1], sort_boxes[1:])
File "D:\Weld inspection\YOLOv5\rotation-yolov5-master\utils\general.py", line 721, in rotate_iou
return ft(ious)
TypeError: type torch.cuda.FloatTensor not available. Torch not compiled with CUDA enabled.

@littlelight-e
Copy link
Author

如果不是用gpu的话,而且这些库装的全是最新版的话,只要改两个地方,一个是self.inplace删掉,一个是把OpenCV-Python的版本改为4.2,完成这两个就能使用cpu执行detect.py了。作者的只能识别航拍中的船,
5
其余的应该要自己训练,
如果想使用gpu,我猜,不同于在YOLOv5.v5中,只要安装适合自己电脑的cuda和cudnn,再安装pytorch框架即可,而要安装作者指定的版本。

@huyunlei
Copy link

非常感谢您的解决方案,关于opencv的问题,只需要把getRotationMatrix2D参数改为int就可以了,就像作者说的后面的opencv可能不支持double

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants