if ‘youtube.com/‘ in url or ‘youtu.be/‘ in url:TypeError: argument of type ‘int‘ is not iterable

46 篇文章 6 订阅
11 篇文章 1 订阅

 使用jetson agx xavier测试训练yolo5.6,得到权重文件pt模型使用USB摄像头测试报错

python3 detect.py --weights runs/train/exp16/weights/best.pt --source 0
Matplotlib created a temporary config/cache directory at /tmp/matplotlib-q3eugw7s because the default path (/home/nvidia/.cache/matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.
Namespace(agnostic_nms=False, augment=False, classes=None, conf_thres=0.25, device='', exist_ok=False, img_size=640, iou_thres=0.45, name='exp', nosave=False, project='runs/detect', save_conf=False, save_txt=False, source='0', update=False, view_img=False, weights=['runs/train/exp16/weights/best.pt'])
YOLOv5 🚀 v5.0-0-gf5b8f7d5 torch 1.9.0 CUDA:0 (Xavier, 31928.53515625MB)

Fusing layers...
/usr/local/lib/python3.6/dist-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  /media/nvidia/NVME/pytorch/pytorch-v1.9.0/c10/core/TensorImpl.h:1156.)
  return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)
Model Summary: 392 layers, 47025981 parameters, 0 gradients, 115.3 GFLOPS
Xlib:  extension "RANDR" missing on display "localhost:10.0".
1/1: 0... Traceback (most recent call last):
  File "detect.py", line 178, in <module>
    detect()
  File "detect.py", line 51, in detect
    dataset = LoadStreams(source, img_size=imgsz, stride=stride)
  File "/home/nvidia/yolov5/utils/datasets.py", line 279, in __init__
    if 'youtube.com/' in url or 'youtu.be/' in url:  # if source is YouTube video
TypeError: argument of type 'int' is not iterable

279             if 'youtube.com/' in str(url) or 'youtu.be/' in str(url):  # if source is YouTube video

将219行改成如上即可

 参考过另外一个方法对我这个没生效,你不介意的话可以看下(2条消息) 【目标检测】YOLOv5 5.0调用摄像头报错的处理_Cul_accino的博客-CSDN博客_yolo检测调用摄像头fps

然后,为了显示实时FPS,需要修改以下两个文件:

 utils/datasets.py 

 

 

337        # return self.sources, img, img0, None
 338         return self.sources, img, img0, self.fps

​​​​​​​

 

detect.py

  # Stream results
119             if view_img: #实时显示当前FPS 1000 /
120                 cv2.putText(im0,"YOLOV5 FPS: {0}".format(float('%.3f' % (1 / (t2 - t1)))),(100,50),cv2.FONT_HERSHEY_SIMPLEX,1.5,(30,144,255),3)
121                 cv2.imshow(str(p), im0)
122                 cv2.waitKey(1)  # 1 millisecond
123
124             # Save results (image with detections)
125             if save_img:
126                 if dataset.mode == 'image':
127                     cv2.imwrite(save_path, im0)
128                 else:  # 'video' or 'stream'
129                     if vid_path != save_path:  # new video
130                         vid_path = save_path
131                         if isinstance(vid_writer, cv2.VideoWriter):
132                             vid_writer.release()  # release previous video writer
133                         #if vid_cap:# video
134                         if not vid_cap: #video加个not取反
135                             fps = vid_cap.get(cv2.CAP_PROP_FPS)
136                             w = int(vid_cap.get(cv2.CAP_PROP_FRAME_WIDTH))
137                             h = int(vid_cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
138                         else:  # stream
139                             fps, w, h = 30, im0.shape[1], im0.shape[0]
140                             save_path += '.mp4'
141                         vid_writer = cv2.VideoWriter(save_path, cv2.VideoWriter_fourcc(*'mp4v'), fps, (w, h))
142                     vid_writer.write(im0)

 

下一篇试下加速 

  • 5
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

无证驾驶梁嗖嗖

让我们解决Jetson使用问题

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值