'yolov5 does not train the model
I trained a dataset by yolov5. The model is existed but it does not work. It does not predict excatly.
Here the code I used:
python train.py --img 640 --batch 8 --epochs 3 --data ../datasets/coco128/coco128.yaml --workers 0 --image-weights '' --name test
outputs of the code:
When we look at the test folder for prediction:
Labels
Predictions
As you see, predictions are nothing. Also there are best.pt and last.pt files. Their size are 14.475 mb. But google colab works with same code.
Also when I try to predict images with default yolov5s.pt, it works, predictions are right.
matrix confusion, result.csv are almost empty with nan text as well.
Thank you for your helps...
Solution 1:[1]
I had a similar issue with YOLOv5 and was able to resolve it by paying attention to the --img (image size) and --conf attributes.
When calling the training script, you can define the image dimensions
python train.py --img 672 1216 ...
But you might have forgotten to use the same argument in the inference script
python detect.py --img 672 ...
Another issue is when your dataset is too small and the Recall/Precision/mAP is too low, you need to decrease the confidence filter for output during inference:
python detect.py ... --conf 0.7
You might need to reduce the --confto 0.1 to see any output. Then play with it until you are satisfied with precision/recall in your output.
Solution 2:[2]
How large is your dataset? I trained yolov5s with only around 30 images with 30 to 40 labels of numbers "0" to "9" per image, it worked poorly, but when I collected more images(66 images), the network reached [email protected] to around 0.99.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | dsalaj |
| Solution 2 | Wanling |





