0

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:

enter image description here

enter image description here

enter image description here

When we look at the test folder for prediction:

Labels

labels

Predictions

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...

Innat
  • 16,113
  • 6
  • 53
  • 101
Wtow
  • 98
  • 1
  • 8

2 Answers2

0

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.

dsalaj
  • 2,857
  • 4
  • 34
  • 43
  • Thanks for your helps. I would use --img parameter but not conf. I actually solved the problem on github, it was about cuda. You can also check [here](https://github.com/ultralytics/yolov5/issues/4839) – Wtow Oct 19 '21 at 16:59
0

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 mAP@0.5 to around 0.99.

Wanling
  • 1
  • 1
  • Thanks for your helps. I would use --img parameter but not conf. I actually solved the problem on github, it was about cuda. You can also check [here](https://github.com/ultralytics/yolov5/issues/4839) – Wtow Apr 20 '22 at 14:36