Skip to content

Webcam stop working suddenly  #6197

Closed

Description

@aaronychu

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.

Activity

  1. github-actions commented on Jan 5, 2022

    @github-actions
    Contributor

    👋 Hello @zydisney, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

    If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

    If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

    For business inquiries or professional support requests please visit https://ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

    Requirements

    Python>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

    git clone https://github.com/ultralytics/yolov5  # clone
    cd yolov5
    pip install -r requirements.txt  # install

    Environments

    YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

    Status

    CI CPU testing

    If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

  2. added a commit that references this issue on Jan 5, 2022
  3. linked a pull request that will close this issueFix `nan`-robust stream FPS #6198on Jan 5, 2022
  4. added a commit that references this issue on Jan 5, 2022
  5. glenn-jocher commented on Jan 5, 2022

    @glenn-jocher
    Member

    @zydisney good news 😃! Your original issue may now be fixed ✅ in PR #6198. This PR fixes a cv2 nan framerate bug that had occured on streaming sources.

    To receive this update:

    • Git – git pull from within your yolov5/ directory or git clone https://github.com/ultralytics/yolov5 again
    • PyTorch Hub – Force-reload model = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
    • Notebooks – View updated notebooks Open In Colab Open In Kaggle
    • Docker – sudo docker pull ultralytics/yolov5:latest to update your image Docker Pulls

    Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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