Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError: 1/1: 0... Failed to open 0 #8180

Closed
1 of 2 tasks
deb-cod opened this issue Jun 12, 2022 · 6 comments · Fixed by #8209
Closed
1 of 2 tasks

AssertionError: 1/1: 0... Failed to open 0 #8180

deb-cod opened this issue Jun 12, 2022 · 6 comments · Fixed by #8209
Labels
bug Something isn't working

Comments

@deb-cod
Copy link

deb-cod commented Jun 12, 2022

Search before asking

  • I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

No response

Bug

Fusing layers...
YOLOv5x summary: 444 layers, 86173414 parameters, 0 gradients
WARNING: Environment does not support cv2.imshow() or PIL Image.show() image displays
cv2.imshow() is disabled in Google Colab environments
[ WARN:0] global /io/opencv/modules/videoio/src/cap_v4l.cpp (802) open VIDEOIO ERROR: V4L: can't open camera by index 0
Traceback (most recent call last):
File "/content/yolov5/detect.py", line 252, in
main(opt)
File "/content/yolov5/detect.py", line 247, in main
run(**vars(opt))
File "/usr/local/lib/python3.7/dist-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/content/yolov5/detect.py", line 100, in run
dataset = LoadStreams(source, img_size=imgsz, stride=stride, auto=pt)
File "/content/yolov5/utils/dataloaders.py", line 325, in init
assert cap.isOpened(), f'{st}Failed to open {s}'
AssertionError: 1/1: 0... Failed to open 0

Environment

detect: weights=['/content/yolov5/best.pt'], source=0, data=/content/yolov5/data/fire.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=yolov5/runs/detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False
YOLOv5 🚀 v6.1-251-gc23a441 Python-3.7.13 torch-1.11.0+cu113 CUDA:0 (Tesla P100-PCIE-16GB, 16281MiB)

I ran in terminal in Colab... still getting the same problem

Minimal Reproducible Example

I ran in terminal in Colab... still getting the same problem

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@deb-cod deb-cod added the bug Something isn't working label Jun 12, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jun 12, 2022

👋 Hello @deb-cod, 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 support@ultralytics.com.

Requirements

Python>=3.7.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.

@glenn-jocher
Copy link
Member

@deb-cod webcam inference is only supported on local devices. I’ll add a TODO to improve error reporting on this to make it clearer for users

glenn-jocher added a commit that referenced this issue Jun 14, 2022
Improve user error understanding for #8180
@glenn-jocher glenn-jocher linked a pull request Jun 14, 2022 that will close this issue
@glenn-jocher glenn-jocher removed the TODO label Jun 14, 2022
glenn-jocher added a commit that referenced this issue Jun 14, 2022
* Reject webcam inference on Colab/Kaggle

Improve user error understanding for #8180

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* cleanup

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@glenn-jocher
Copy link
Member

@deb-cod good news 😃! Your original issue may now be fixed ✅ in PR #8209. This PR adds improved error reporting to help users understand that webcam inference with --source 0 must be run in a local environment with access to a webcam, not on remote environments like Colab/Kaggle.

To receive this update:

  • Gitgit 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
  • Dockersudo 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 🚀!

@banana7778
Copy link

same question..didU solved it?

@sloika
Copy link

sloika commented Aug 29, 2022

I try to use it locally on my machine and it still has the same bug. Already up to date repo.

@glenn-jocher
Copy link
Member

Webcam inference works correctly:

Screenshot 2022-08-29 at 19 32 40

ctjanuhowski pushed a commit to ctjanuhowski/yolov5 that referenced this issue Sep 8, 2022
* Reject webcam inference on Colab/Kaggle

Improve user error understanding for ultralytics#8180

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* cleanup

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants