Closed Sandr001 closed 3 years ago
π Hello @Sandr001, 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.
Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7
. To install run:
$ pip install -r requirements.txt
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.
@Sandr001 hi thanks for the bug report! @AyushExel we seem to have a W&B bug here. User is on Windows on the latest commit v5.0-42-g4200674.
Seems like data_dict.get('train') is failing as data_dict has no 'train' key.
@Sandr001 looking at your error message it appears that your dataset.yaml file has no 'train' field, in which case there is no bug in the code. This field is required, and is used to identify your training set. See Train Custom Data tutorial to get started:
If you believe you have a reproducible issue, we suggest you close this issue and raise a new one using the π Bug Report template, providing screenshots and a minimum reproducible example to help us better understand and diagnose your problem. Thank you!
@Sandr001 as Glenn pointed out, probably your dataset.yaml
file is missing some info. Can you share the file here for us to take a look at? The file should contain train
and val
paths
Thank you Glenn and Ayush for responding to my issue. The below given is the content in my dataset.yaml file:
train:training/data/images/train val:training/data/images/valid
nc:1
names:['duck']
@Sandr001 as Glenn pointed out, probably your
dataset.yaml
file is missing some info. Can you share the file here for us to take a look at? The file should containstrain
andval
paths
@Sandr001 Can you try adding space after the :
. like:
train: training/data/images/train
val: training/data/images/valid
nc: 1
names: ['duck]
@Sandr001 Can you try adding space after the
:
. like:train: training/data/images/train val: training/data/images/valid nc: 1 names: ['duck]
Adding space after ':' solved my issue. Thanks a lot.
@Sandr001 great!
Hi.. I have a doubt.. will YOLO V5 work on all versions of Ubuntu?
@Sandr001
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.
Hi.. Can I get the detected label names from the image saved into a .txt file in the detect folder like --save-txt, --save-conf etc ?
@Sandr001 not with detect.py, but if you run inference using YOLOv5 PyTorch Hub models you can use .pandas()
to produce detections with class names:
import cv2
import torch
from PIL import Image
# Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
# Images
for f in ['zidane.jpg', 'bus.jpg']: # download 2 images
torch.hub.download_url_to_file('https://github.com/ultralytics/yolov5/releases/download/v1.0/' + f, f)
img1 = Image.open('zidane.jpg') # PIL image
img2 = cv2.imread('bus.jpg')[:, :, ::-1] # OpenCV image (BGR to RGB)
imgs = [img1, img2] # batch of images
# Inference
results = model(imgs, size=640) # includes NMS
# Results
results.print()
results.save() # or .show()
results.xyxy[0] # img1 predictions (tensor)
results.pandas().xyxy[0] # img1 predictions (pandas)
# xmin ymin xmax ymax confidence class name
# 0 749.50 43.50 1148.0 704.5 0.874023 0 person
# 1 433.50 433.50 517.5 714.5 0.687988 27 tie
# 2 114.75 195.75 1095.0 708.0 0.624512 0 person
# 3 986.00 304.00 1028.0 420.0 0.286865 27 tie
See PyTorch Hub tutorial for full details:
Thank you.
@Sandr001 not with detect.py, but if you run inference using YOLOv5 PyTorch Hub models you can use
.pandas()
to produce detections with class names:import cv2 import torch from PIL import Image # Model model = torch.hub.load('ultralytics/yolov5', 'yolov5s') # Images for f in ['zidane.jpg', 'bus.jpg']: # download 2 images torch.hub.download_url_to_file('https://github.com/ultralytics/yolov5/releases/download/v1.0/' + f, f) img1 = Image.open('zidane.jpg') # PIL image img2 = cv2.imread('bus.jpg')[:, :, ::-1] # OpenCV image (BGR to RGB) imgs = [img1, img2] # batch of images # Inference results = model(imgs, size=640) # includes NMS # Results results.print() results.save() # or .show() results.xyxy[0] # img1 predictions (tensor) results.pandas().xyxy[0] # img1 predictions (pandas) # xmin ymin xmax ymax confidence class name # 0 749.50 43.50 1148.0 704.5 0.874023 0 person # 1 433.50 433.50 517.5 714.5 0.687988 27 tie # 2 114.75 195.75 1095.0 708.0 0.624512 0 person # 3 986.00 304.00 1028.0 420.0 0.286865 27 tie
See PyTorch Hub tutorial for full details:
YOLOv5 Tutorials
- Train Custom DataΒ π RECOMMENDED
- Tips for Best Training ResultsΒ βοΈ RECOMMENDED
- Weights & Biases LoggingΒ π NEW
- Supervisely EcosystemΒ π NEW
- Multi-GPU Training
- PyTorch HubΒ β NEW
- ONNX and TorchScript Export
- Test-Time Augmentation (TTA)
- Model Ensembling
- Model Pruning/Sparsity
- Hyperparameter Evolution
- Transfer Learning with Frozen LayersΒ β NEW
- TensorRT Deployment
Hi! If it was for custom data what are the changes to be made? How to point inference to the model trained with our custom data?
@Sandr001 see PyTorch Hub tutorial for information on loading custom YOLOv5 models.
Hi.. For my doubt clarification I am asking this question. Please help with this doubt. Can YOLOv5 be used solely for classification purposes.? Since both classification and detection is done at a go, will YOLOv5 help in this for my custom data? Thank you in advance.
@Sandr001 yes, you can train a YOLOv5 classifier with this branch: https://github.com/ultralytics/yolov5/tree/classifier
python classifier.py
See argparser for details and example usage.
https://github.com/ultralytics/yolov5/blob/classifier/classifier.py
# YOLOv5 classifier training
# Usage: python classifier.py --model yolov5s --data mnist --epochs 10 --img 128
π Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.
Access additional YOLOv5 π resources:
Access additional Ultralytics β‘ resources:
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 YOLOv5 π and Vision AI β!
βAttribute Error when I run the following command :
python train.py --img 640 --batch 16 --epochs 300--data training/dataset.yaml --cfg training/yolov5l.yaml
This is what I'm getting. Please help!