运行python detect.py时报错ypeError: rectangle() got an unexpected keyword argument ‘thickness‘

解决报错python detect.py detect: weights=best.pt, source=data/images, imgsz=[640, 640], conf_thres=0.25, iou_thres=0.45, max_det=1000, device=, 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/detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False YOLOv5 🚀 2021-10-16 torch 1.10.0 CUDA:0 (NVIDIA GeForce GTX 1660 SUPER, 5936.1875MB) Fusing layers... /home/sxj/anaconda3/envs/yolo/lib/python3.7/site-packages/torch/functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at /opt/conda/conda-bld/pytorch_1634272126608/work/aten/src/ATen/native/TensorShape.cpp:2157.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] Model Summary: 213 layers, 7018216 parameters, 0 gradients, 15.8 GFLOPs image 1/96 /home/sxj/opencv_yolov5/yolov5_1/data/images/000001.png: Traceback (most recent call last): File "detect.py", line 307, in <module> main(opt) File "detect.py", line 302, in main run(**vars(opt)) File "/home/sxj/anaconda3/envs/yolo/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 28, in decorate_context return func(*args, **kwargs) File "detect.py", line 225, in run annotator.box_label(xyxy, label, color=colors(c, True)) File "/home/sxj/opencv_yolov5/yolov5_1/utils/plots.py", line 96, in box_label cv2.rectangle(self.im, p1, p2, color, thickness=self.lw, lineType=cv2.LINE_AA) TypeError: rectangle() got an unexpected keyword argument 'thickness'

这种一般都是OpenCV的版本问题,我的之前版本是4.6.0.66换成4.5.1.48即可

pip install opencv-python==4.5.1.48 -i https://pypi.douban.com/simple
 pip install opencv-contrib-python==4.5.1.48 -i https://pypi.douban.com/simple

在运行就可以了 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值