Closed asriaws closed 1 year ago
@asriaws hi, to run live inference from multiple webcams with YOLOv5, you can use the streams.txt
file you created, but make sure to specify the correct path for the webcam sources in the file.
In the error message you provided, it seems that the path /Users/asriaws/pokerbot/yolov5/0
does not exist. Please double-check the paths you have specified in the streams.txt
file to ensure they are correct.
If you still encounter issues, please let us know and provide the absolute paths to the webcam sources you are trying to use.
Thank you for using YOLOv5 and feel free to reach out if you have any further questions or concerns.
Note: Since I am the author and maintainer of the YOLOv5 repo, it is my pleasure to assist you. However, the success and continuous development of YOLOv5 are made possible by the YOLO community and the dedicated Ultralytics team.
Hi @glenn-jocher - I am not sure if that's the root cause. Here is why:
This is success to detect my USB webcam
python detectaws.py --weights playingcardsm.pt --source 0 --device mps
Now I added 0 in the streams.txt and it failed that I mentioned earlier
python detectaws.py --weights playingcardsm.pt --source streams.txt --device mps
I tried troubleshooting detect.py. When the input source is stream.txt
the webcam
variable (line 91 on detect.py) is set to false (which I believe is the root cause)
webcam = source.isnumeric() or source.endswith('.streams') or (is_url and not is_file)
I override webcam = True
and it worked for 1 USB Webcam, As I added 2nd webcam in the stream.txt - I got different error.
File stream.txt
0
1
New Error
(env) asriaws@3c063016ae64 yolov5 % python detectaws.py --weights playingcardsm.pt --source streams.txt --device mps
detectaws: weights=['playingcardsm.pt'], source=streams.txt, data=data/coco128.yaml, imgsz=[640, 640], conf_thres=0.25, iou_thres=0.45, max_det=1000, device=mps, 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, vid_stride=1
False
False
streams.txt
YOLOv5 🚀 v7.0-207-g4e2ba7e Python-3.11.0 torch-2.0.0 MPS
Fusing layers...
YOLOv5m summary: 212 layers, 21059025 parameters, 0 gradients, 48.5 GFLOPs
Troubleshooting:::::::1/2: 1...
1/2: 1... Success (inf frames 1920x1080 at 5.00 FPS)
Troubleshooting:::::::2/2: 0...
2/2: 0... Success (inf frames 1920x1080 at 30.00 FPS)
Traceback (most recent call last):
File "/Users/asriaws/pokerbot/yolov5/detectaws.py", line 273, in <module>
main(opt)
File "/Users/asriaws/pokerbot/yolov5/detectaws.py", line 268, in main
run(**vars(opt))
File "/Users/asriaws/pokerbot/env/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/asriaws/pokerbot/yolov5/detectaws.py", line 113, in run
dataset = LoadStreams(source, img_size=imgsz, stride=stride, auto=pt, vid_stride=vid_stride)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/asriaws/pokerbot/yolov5/utils/dataloaders.py", line 382, in __init__
s = np.stack([letterbox(x, img_size, stride=stride, auto=auto)[0].shape for x in self.imgs])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/asriaws/pokerbot/yolov5/utils/dataloaders.py", line 382, in <listcomp>
s = np.stack([letterbox(x, img_size, stride=stride, auto=auto)[0].shape for x in self.imgs])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/asriaws/pokerbot/yolov5/utils/augmentations.py", line 113, in letterbox
shape = im.shape[:2] # current shape [height, width]
^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'shape'
(env) asriaws@3c063016ae64 yolov5 %
@asriaws The issue you're experiencing seems to be related to the letterbox
function in the data loaders. It appears that the input image shape is None
, causing an attribute error.
The error is occurring in the line that calculates the current shape of the image: shape = im.shape[:2]
. It seems that some images are not being loaded properly or have become None
, which is leading to the error.
To investigate further, you can try printing the images loaded from the source to verify if they are being read correctly. Additionally, you can check if there are any issues with the images themselves, such as unsupported formats or corrupted files.
I recommend reviewing the image loading and preprocessing steps in your implementation to ensure that the images are being processed correctly before inference.
Let me know if you have any further questions or need additional assistance.
Thank you for your patience and understanding.
👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.
For additional resources and information, please see the links below:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!
Thank you for your contributions to YOLO 🚀 and Vision AI ⭐
Search before asking
Question
Hello, I need to run live inference from multiple webcam. I have trained yolov5 and the inference seems working fine with 1 webcam using following command.
python detectaws.py --weights playingcardsm.pt --source 0 --device mps
Now I created
streams.txt
with two webcam input sourceWhen trying below command it errors out.
python detectaws.py --weights playingcardsm.pt --source streams.txt --device mps
Error
Any help will be highly appreciated.
Additional
No response