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
yolov5 does not train or detect #4839
Comments
👋 Hello @Elektrikci21, 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. RequirementsPython>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started: $ git clone https://github.com/ultralytics/yolov5
$ cd yolov5
$ pip install -r requirements.txt EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf 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. |
@Elektrikci21 it appears you may have environment problems. Please ensure you meet all dependency requirements if you are attempting to run YOLOv5 locally. If in doubt, create a new virtual Python environment, clone the latest repo (code changes daily), and RequirementsPython>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started: $ git clone https://github.com/ultralytics/yolov5
$ cd yolov5
$ pip install -r requirements.txt EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf 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 I did everything from scratch but it does not work again. |
@Elektrikci21 I'm suggesting you add many more samples to your training data set, ideally >1k images. From my experience anything less than 250-350 images per class you might have trouble getting any meaningful results. Also, make sure your labels are correct and if possible add background images to your model by adding images with a blank or empty label txt file that do not include things you have labeled. Ideally you would have over 1k samples and maybe 100 background images. I have over 10k samples for most of my classes now after having only started with about 1k. Trying to train with too few images is a very common issue people have. If you want a good data set to train with you can download a pre configured data set with good labels to see how your data set differs from a large well labeled data set. https://docs.ultralytics.com/yolov5/tutorials/train_custom_data This is the most important bit, if you want this to work read this and follow it. https://docs.ultralytics.com/yolov5/tutorials/tips_for_best_training_results Also make sure your training data set is representative of the input data you expect -- eg don't make all super high end images then take inference images with a 1950s web cam. Try to get training data from real world examples of how you expect data to come in. |
I get the same problem, when it works on GPU, the box, obj, cls are nan and ap is 0, but when it works on CPU, you can get the correct results |
@MangoloD it appears you may have environment problems. Please ensure you meet all dependency requirements if you are attempting to run YOLOv5 locally. If in doubt, create a new virtual Python 3.8 environment, clone the latest repo (code changes daily), and RequirementsPython>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started: $ git clone https://github.com/ultralytics/yolov5
$ cd yolov5
$ pip install -r requirements.txt EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf 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. |
Perhaps this is a GPU issue? I have a GPU from the 16 series like Elektrikci21, an Nvidia GTX 1660 Ti, and my training would always produce nan values from epoch 0. I fixed this by switching to an Nvidia GTX 1070 and training immediately worked as expected. |
@ayayaQ your experiement is make sense. We could be sure if we would have more example about this sitiuation. I also can add this example; I also try to make image classification by using tensorflow.keras and my training results are always wrong. When I predict on the model, results always return same index and same accuracy that is 1. |
@iceisfun I think it is not about samples. Because when I train same dataset with same configuration in google colab, results make sense, everything is okay. |
I think this could be an issue with the included version of cuDNN in PyTorch? I noticed one of the issues fixed in cuDNN release 8.2.2 stated as related to this GPU series.
|
@ayayaQ Thanks for your research and sharing them with us. Latest version of PyTorch supports CUDA 10.2 and CUDA 11.1 but cuDNN 8.2.2 supports 10.2 and 11.4 so we have to use 10.2 version. I will try to do it and edit this answer. |
@ayayaQ I tested your answer and problem is solved. I just changed cuda version from 11.1 to 10.2 and there is no problem. I used these codes.
You can find same code at here @MangoloD If you have not solved the problem yet, please try this way and notice us about your results. Thanks for everyone. |
I can confirm with the 10.2 installation that my training is now working as expected on the GTX 1660 Ti. |
@DaliaMahdy 👋 Hello! Thanks for asking about improving YOLOv5 🚀 training results. Most of the time good results can be obtained with no changes to the models or training settings, provided your dataset is sufficiently large and well labelled. If at first you don't get good results, there are steps you might be able to take to improve, but we always recommend users first train with all default settings before considering any changes. This helps establish a performance baseline and spot areas for improvement. If you have questions about your training results we recommend you provide the maximum amount of information possible if you expect a helpful response, including results plots (train losses, val losses, P, R, mAP), PR curve, confusion matrix, training mosaics, test results and dataset statistics images such as labels.png. All of these are located in your We've put together a full guide for users looking to get the best results on their YOLOv5 trainings below. Dataset
Model SelectionLarger models like YOLOv5x and YOLOv5x6 will produce better results in nearly all cases, but have more parameters, require more CUDA memory to train, and are slower to run. For mobile deployments we recommend YOLOv5s/m, for cloud deployments we recommend YOLOv5l/x. See our README table for a full comparison of all models.
python train.py --data custom.yaml --weights yolov5s.pt
yolov5m.pt
yolov5l.pt
yolov5x.pt
custom_pretrained.pt
python train.py --data custom.yaml --weights '' --cfg yolov5s.yaml
yolov5m.yaml
yolov5l.yaml
yolov5x.yaml Training SettingsBefore modifying anything, first train with default settings to establish a performance baseline. A full list of train.py settings can be found in the train.py argparser.
Further ReadingIf you'd like to know more a good place to start is Karpathy's 'Recipe for Training Neural Networks', which has great ideas for training that apply broadly across all ML domains: http://karpathy.github.io/2019/04/25/recipe/ Good luck 🍀 and let us know if you have any other questions! |
@Elektrikci21 @DaliaMahdy While training getting nan at box, obj, cls. What could be the reason? In training, it boxes some objects. But when I am testing the model unable to detect it. |
Anyone manage to try using Cuda 11.3? |
I realized I had a problem with the dataset from the roboflow side, it worked when I fixed it |
@wtjasmine glad to hear that you were able to identify and fix the issue with your dataset. Dataset problems can often lead to unexpected results during training. Make sure to thoroughly review and validate your dataset to ensure it is well-labeled and representative of your target objects. If you encounter any further issues or have any additional questions, feel free to ask. |
Hi, I haven't able to fix the issue, I have checked my dataset label, all objects are well labeled. I have followed all these recommendations on my dataset:
I have tried to train with 300 epochs without changing any default settings of the model, the training stops halfway after 100 epochs the metrics do not show improvement. Although the losses of both validation and training still decreasing during training, metrics like precision, recall, and mAP seems to stick around 0.53, does this means the training has reached the final results and training should stop? Because I am trying to detect small objects from images, could you pls suggest some tips to improve the results? Thank you. |
@wtjasmine hi there, I understand that you have followed the recommended guidelines for your dataset, ensuring sufficient images per class, instances per class, image variety, label consistency, label accuracy, label verification, and background images. Regarding your training, if the losses are still decreasing but the metrics like precision, recall, and mAP appear to be stagnant around 0.53, it might indicate that the training has reached a plateau and further training might not lead to significant improvements. However, there are a few tips you can try to potentially improve the results for detecting small objects:
Remember to monitor the training and validation metrics closely to evaluate the impact of these changes. Feel free to share any further questions or issues you may have. Good luck with your project! |
@vrushank41 the link you provided seems to be broken, and I'm unable to view the error image. Could you please double-check the link and ensure it is accessible to me? Additionally, if you could provide the error message or a description of the issue, I'd be more than happy to assist you further. |
@vrushank41 It seems you're encountering an issue with a missing .csv file following the completion of the training process. Without being able to view the content from the provided links, it's challenging to identify the exact cause of the problem. However, it sounds like there might be an unexpected behavior at the end of the training process. To better understand the issue, it would be helpful to have a bit more information:
Please feel free to provide additional details, and I'd be more than happy to help you resolve this issue. |
Before submitting a bug report, please be aware that your issue must be reproducible with all of the following,
otherwise it is non-actionable, and we can not help you:
git fetch && git status -uno
to check andgit pull
to update repoIf this is a custom dataset/training question you must include your
train*.jpg
,val*.jpg
andresults.png
figures, or we can not help you. You can generate these with
utils.plot_results()
.🐛 Bug
When I train coco128 dataset with yolov5, it trains and there is no warning about training. After training, yolov5 produce some folders and files such as weights, confusion_matrix.png, results.csv, results.png... When we look at results.png, confusion_matrix.png, result.csv they are just empty. You can see result.png below:
result.csv is same wiith resul.png as well. Some files is not created properly as I said but weights is created and they have same size with yolov5s.pt.
If I try to predict a sample with the trained model, it does not give me compatible result. There are no rectangles, error message, warning or something else but if I predict an image with yolov5s.pt which is produced by default, detection work. There is considirable result.
You can seee all processes below:
To Reproduce (REQUIRED)
To train a model
Input:
Output:
To detect
input:
output:
Here the output image
There are no labels, it is like input image.,
Expected behavior
A clear and concise description of what you expected to happen.
Environment
- OS:
Host Name: DESKTOP-3NBVRK6
OS Name: Microsoft Windows 10 Home
OS Version: 10.0.19042 N/A Build 19042
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Workstation
OS Build Type: Multiprocessor Free
System Boot Time: 16.09.2021, 17:48:39
System Type: x64-based PC
Processor(s): 1 Processor(s) Installed.
[01]: Intel64 Family 6 Model 165 Stepping 2 GenuineIntel ~2400 Mhz
BIOS Version: INSYDE Corp. 1.07.10TFB5, 5.10.2020
Windows Directory: C:\Windows
System Directory: C:\Windows\system32
Boot Device: \Device\HarddiskVolume1
System Locale: tr;Türkçe
Input Locale: tr;Türkçe
Time Zone: (UTC+03:00) İstanbul
Total Physical Memory: 16.173 MB
Available Physical Memory: 7.350 MB
Virtual Memory: Max Size: 18.605 MB
Virtual Memory: Available: 7.710 MB
Virtual Memory: In Use: 10.895 MB
Page File Location(s): C:\pagefile.sys
Domain: WORKGROUP
Hotfix(s): 10 Hotfix(s) Installed.
[01]: KB5004331
[02]: KB4562830
[03]: KB4570334
[04]: KB4577586
[05]: KB4580325
[06]: KB4586864
[07]: KB4589212
[08]: KB4598481
[09]: KB5005565
[10]: KB5005699
Hyper-V Requirements: VM Monitor Mode Extensions: Yes
Virtualization Enabled In Firmware: Yes
Second Level Address Translation: Yes
Data Execution Prevention Available: Yes
- GPU:
Intel(R) UHD Graphics
NVIDIA GeForce GTX 1650 Ti
DriverVersion
27.20.100.9365
30.0.14.7111
Python version: 3.9.7
If you have another files or informations, just let me know.
Thanks.
The text was updated successfully, but these errors were encountered: