You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:
$ pip install -r requirements.txt
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):
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), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.
@kaushalchapaneri-intellica your code is likely out of date. You should git pull to update it or reclone the repo.
hi, while I want to train yolov5 on custom dataset I got this error:
Traceback (most recent call last):
File "train.py", line 404, in
train(hyp)
File "train.py", line 80, in train
model = Model(opt.cfg).to(device)
File "/content/yolov5/models/yolo.py", line 57, in init
self.model, self.save = parse_model(self.md, ch=[ch]) # model, savelist, ch_out
File "/content/yolov5/models/yolo.py", line 153, in parse_model
m = eval(m) if isinstance(m, str) else m # eval strings
File "", line 1, in
NameError: name 'C3' is not defined
it happens when I use lastest yolov5x.yaml file which containes:
backbone:
@Lnazvkl the error you are seeing is due to out of date or modified code. To start simply clone a fresh copy of the repo, and verify training for a few epochs.
git clone https://github.com/ultralytics/yolov5
cd yolov5
python train.py --epochs 3
@Lnazvkl I will also post our full response with additional details that may help you. Please note that most technical problems are due to:
Your modified or out-of-date code. If your issue is not reproducible in a new git clone version of this repo we can not debug it. Before going further run this code and verify your issue persists:
$ git clone https://github.com/ultralytics/yolov5 yolov5_new # clone latest
$ cd yolov5_new
$ python detect.py # verify detection# CODE TO REPRODUCE YOUR ISSUE HERE
Your custom data. If your issue is not reproducible in one of our 3 common datasets (COCO, COCO128, or VOC) we can not debug it. Visit our Custom Training Tutorial for guidelines on training your custom data. Examine train_batch0.jpg and test_batch0.jpg for a sanity check of your labels and images.
Your environment. If your issue is not reproducible in one of the verified environments below we can not debug it. If you are running YOLOv5 locally, verify your environment meets all of the requirements.txt dependencies specified below. If in doubt, download Python 3.8.0 from https://www.python.org/, create a new venv, and install requirements.
If none of these apply to you, we suggest you close this issue and raise a new one using the 🐛 Bug Report template, providing screenshots and minimum viable code to reproduce your issue. Thank you!
Requirements
Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:
$ pip install -r requirements.txt
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):
If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are passing. These tests evaluate proper operation of basic YOLOv5 functionality, including training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu.
@Lnazvkl I will also post our full response with additional details that may help you. Please note that most technical problems are due to:
Your modified or out-of-date code. If your issue is not reproducible in a new git clone version of this repo we can not debug it. Before going further run this code and verify your issue persists:
$ git clone https://github.com/ultralytics/yolov5 yolov5_new # clone latest
$ cd yolov5_new
$ python detect.py # verify detection# CODE TO REPRODUCE YOUR ISSUE HERE
Your custom data. If your issue is not reproducible in one of our 3 common datasets (COCO, COCO128, or VOC) we can not debug it. Visit our Custom Training Tutorial for guidelines on training your custom data. Examine train_batch0.jpg and test_batch0.jpg for a sanity check of your labels and images.
Your environment. If your issue is not reproducible in one of the verified environments below we can not debug it. If you are running YOLOv5 locally, verify your environment meets all of the requirements.txt dependencies specified below. If in doubt, download Python 3.8.0 from https://www.python.org/, create a new venv, and install requirements.
If none of these apply to you, we suggest you close this issue and raise a new one using the 🐛 Bug Report template, providing screenshots and minimum viable code to reproduce your issue. Thank you!
Requirements
Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:
$ pip install -r requirements.txt
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):
If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are passing. These tests evaluate proper operation of basic YOLOv5 functionality, including training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu.
as you said I update yolov5 but I got these errors:
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
python3: can't open file 'detect.py': [Errno 2] No such file or directory
@kaushalchapaneri-intellica
I've meet the same error(just use torch to torch.load('yolov5s.pt')) AttributeError: Can't get attribute 'C3' on <module 'models.common' '>
kaushalchapaneri-intellica commented on Mar 16, 2021
step 1 : re clone repo in different folder by git clone https://github.com/ultralytics/yolov5.git
step 2 : cd yolov5
step 3 : then run python detect.py --source data/images/bus.jpg (assuming your python environment has all the dependencies mentioned here)
Activity
github-actions commentedon Jan 6, 2021
👋 Hello @kaushalchapaneri-intellica, 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://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.
Requirements
Python 3.8 or later with all requirements.txt dependencies installed, including
torch>=1.7
. To install run: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
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), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.
glenn-jocher commentedon Jan 7, 2021
@kaushalchapaneri-intellica your code is likely out of date. You should
git pull
to update it or reclone the repo.Lnazvkl commentedon Jan 13, 2021
hi, while I want to train yolov5 on custom dataset I got this error:
Traceback (most recent call last):
File "train.py", line 404, in
train(hyp)
File "train.py", line 80, in train
model = Model(opt.cfg).to(device)
File "/content/yolov5/models/yolo.py", line 57, in init
self.model, self.save = parse_model(self.md, ch=[ch]) # model, savelist, ch_out
File "/content/yolov5/models/yolo.py", line 153, in parse_model
m = eval(m) if isinstance(m, str) else m # eval strings
File "", line 1, in
NameError: name 'C3' is not defined
it happens when I use lastest yolov5x.yaml file which containes:
backbone:
[from, number, module, args]
[[-1, 1, Focus, [64, 3]], # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
[-1, 3, C3, [128]],
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
[-1, 9, C3, [256]],
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
[-1, 9, C3, [512]],
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32
[-1, 1, SPP, [1024, [5, 9, 13]]],
[-1, 3, C3, [1024, False]], # 9
]
I don't know how to solve it, I will be appreciated if you help me.
glenn-jocher commentedon Jan 13, 2021
@Lnazvkl your code is out of date. Use
git pull
to update your code, or simplygit clone https://github.com/ultralytics/yolov5
to download a new copy.Lnazvkl commentedon Jan 13, 2021
I had updated, but I have got this error after update.
glenn-jocher commentedon Jan 13, 2021
@Lnazvkl the error you are seeing is due to out of date or modified code. To start simply clone a fresh copy of the repo, and verify training for a few epochs.
git clone https://github.com/ultralytics/yolov5 cd yolov5 python train.py --epochs 3
Alternatively you can start from the official notebook (3rd party notebooks are not supported):
https://colab.research.google.com/github/ultralytics/yolov5/blob/master/tutorial.ipynb
glenn-jocher commentedon Jan 13, 2021
@Lnazvkl I will also post our full response with additional details that may help you. Please note that most technical problems are due to:
git clone
version of this repo we can not debug it. Before going further run this code and verify your issue persists:Your custom data. If your issue is not reproducible in one of our 3 common datasets (COCO, COCO128, or VOC) we can not debug it. Visit our Custom Training Tutorial for guidelines on training your custom data. Examine
train_batch0.jpg
andtest_batch0.jpg
for a sanity check of your labels and images.Your environment. If your issue is not reproducible in one of the verified environments below we can not debug it. If you are running YOLOv5 locally, verify your environment meets all of the requirements.txt dependencies specified below. If in doubt, download Python 3.8.0 from https://www.python.org/, create a new venv, and install requirements.
If none of these apply to you, we suggest you close this issue and raise a new one using the 🐛 Bug Report template, providing screenshots and minimum viable code to reproduce your issue. Thank you!
Requirements
Python 3.8 or later with all requirements.txt dependencies installed, including
torch>=1.7
. To install run: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
If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are passing. These tests evaluate proper operation of basic YOLOv5 functionality, including training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu.
Lnazvkl commentedon Jan 13, 2021
as you said I update yolov5 but I got these errors:
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
python3: can't open file 'detect.py': [Errno 2] No such file or directory
special thanks for your attention.
glenn-jocher commentedon Jan 13, 2021
@Lnazvkl I don't recognize the notebook you are using. There are many 3rd party notebooks that we do not support and that may have performance issues. I would recommend you simply start from the official YOLOv5 notebook, which is authored by Ultralytics and verified working correctly:
https://colab.research.google.com/github/ultralytics/yolov5/blob/master/tutorial.ipynb
To train with the official notebook, you simply click the Setup cell, and then run the Train cell. Two clicks gets you training correctly.

Lnazvkl commentedon Jan 13, 2021
I am using google colab.
glenn-jocher commentedon Jan 13, 2021
@Lnazvkl you are using an unsupported notebook in google colab. The official Ultralytics YOLOv5 notebook is here:
https://colab.research.google.com/github/ultralytics/yolov5/blob/master/tutorial.ipynb
Lnazvkl commentedon Jan 13, 2021
thanks for your response.
cs-heibao commentedon Mar 16, 2021
@kaushalchapaneri-intellica
I've meet the same error(just use torch to torch.load('yolov5s.pt'))
AttributeError: Can't get attribute 'C3' on <module 'models.common' '>
kaushalchapaneri-intellica commentedon Mar 16, 2021
@cs-heibao try this:
step 1 : re clone repo in different folder by
git clone https://github.com/ultralytics/yolov5.git
step 2 :
cd yolov5
step 3 : then run
python detect.py --source data/images/bus.jpg
(assuming your python environment has all the dependencies mentioned here)now on python terminal or in .py file run this:
import torch
torch.load('yolov5s.pt')