Skip to content

Webcam stop working suddenly  #6197

@zydisney

Description

@zydisney

YOLOv5 Component

Detection

Bug

after run python3 detect.py --source 0 --weights yolov5s.pt --conf 0.25
The webcam only capture ONE FRAME.

/Users/Aaron/miniforge3/envs/yolov5/lib/python3.9/site-packages/torchvision/io/image.py:11: UserWarning: Failed to load image Python extension: 
  warn(f"Failed to load image Python extension: {e}")
detect: weights=['yolov5s.pt'], source=0, data=data/coco128.yaml, 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 🚀 v6.0-174-g7b31a53 torch 1.10.1 CPU

Fusing layers... 
Model Summary: 213 layers, 7225885 parameters, 0 gradients
1/1: 0...  Success (inf frames 1280x720 at nan FPS)

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/Users/Aaron/miniforge3/envs/yolov5/lib/python3.9/threading.py", line 973, in _bootstrap_inner
    self.run()
  File "/Users/Aaron/miniforge3/envs/yolov5/lib/python3.9/threading.py", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/Aaron/yolov5/utils/datasets.py", line 341, in update
    time.sleep(1 / self.fps[i])  # wait time
ValueError: Invalid value NaN (not a number)
0: 384x640 1 person, Done. (0.109s)
Speed: 1.0ms pre-process, 108.9ms inference, 0.5ms NMS per image at shape (1, 3, 640, 640)
Results saved to runs/detect/exp11

Environment

  • YOLOv5
  • OS: macOS 12.1
  • Python 3.9
  • Apple M1 Chip

Minimal Reproducible Example

After run python3 detect.py --source 0 --weights yolov5s.pt --conf 0.25
The webcam only capture ONE FRAME then stoped.
A 0 sec mp4 detect result can be generated in detect\exp* folder.
It also happens when I connect to an external camera via USB.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions