BossZard / rotation-yolov5

rotation detection based on yolov5
GNU General Public License v3.0
377 stars 97 forks source link

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

Open littlelight-e opened 2 years ago

littlelight-e commented 2 years ago

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 commented 2 years ago

这个错误只要把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 commented 2 years ago

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

huyunlei commented 2 years ago

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