I am training the model using the Yolov3 model with the data set I received from Kaggle. Model training is completed and I add the new weights to the backup folder. I run one of the fruits I trained with for testing, but object detection does not occur. The same image appears as Prediction.jpg. The training seems to be decent, but I don't understand why it can't detect objects. Please help me.
Train Terminal Code:
./darknet detector train /Users/melisabagcivan/darknet/data/obj.data /Users/melisabagcivan/darknet/cfg/yolov3.cfg /Users/melisabagcivan/Desktop/Projects/Bitirmeprojesi/yolov3.weights
Test Terminal Code:
./darknet detector test /Users/melisabagcivan/darknet/data/obj.data /Users/melisabagcivan/darknet/cfg/yolov3.cfg /Users/melisabagcivan/darknet/backup/yolov3_final.weights -thresh 0.25 -out predictions.jpg
I set up and edited obj.data and obj.names and yolov3.cfg files.
I have 3 classes: apple, banana and orange. I have properly set the values such as filter and class values in the cfg file according to the 3 classes.
cfg file
[net]
# Testing
batch=64
subdivisions=1
# Training
subdivisions=16
width= 608
height=608
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=0.3
learning_rate=0.001
burn_in=1000
max_batches = 6000 # classnum * 2000
policy=steps
steps=3600,4800 # max_batches num %80, %90
scales=.1,.1
In addition to the .jpg images in the data set, there are .txt files with the same name in yolo format.
The train.txt and test.txt files containing the paths to all the images are also ready.
When I run the test command in the terminal, it works, but the picture looks the same, there are no bounding boxes that detect objects. I'm sure I have Opencv installed. I am using macOS. Why is it not detecting it? Someone please help. I cleaned the darknet many times by saying make clean and ran it by saying make opencv = 1, but the result does not change.
[yolo] params: iou loss: mse (2), iou_norm: 0.75, obj_norm: 1.00, cls_norm: 1.00, delta_norm: 1.00, scale_x_y: 1.00
Total BFLOPS 137.613
avg_outputs = 1052318
Loading weights from /Users/melisabagcivan/darknet/backup/yolov3_final.weights...
seen 64, trained: 32013 K-images (500 Kilo-batches_64)
Done! Loaded 107 layers from weights-file
Enter Image Path: /Users/melisabagcivan/Desktop/Projects/yoloOD/dataset/test/38_Orange.jpg
Detection layer: 82 - type = 28
Detection layer: 94 - type = 28
Detection layer: 106 - type = 28
/Users/melisabagcivan/Desktop/Projects/yoloOD/dataset/test/38_Orange.jpg: Predicted in 6738.129000 milli-seconds.
I tried it with many images and it doesn't draw the box in any of them. I don't understand whether it can't detect it or whether I'm making a mistake while testing it.
Several things to note:
I suspect you are using the old abandoned repo, just based on the paths you give in the example commands. Note the AlexeyAB repo was abandoned in July 2021. https://www.ccoderun.ca/programming/yolo_faq/#which_repos_to_use_and_avoid
The new Darknet/YOLO repo people should be using is the one sponsored by Hank.ai. All new development is being done there. See here: https://github.com/hank-ai/darknet#table-of-contents
Looks like your training images contains cropped images of fruit, is that right? That first image of an apple that takes up almost 100% of the image...if you train with that, you're telling Darknet/YOLO that the objects you want to detect must take up ~100% of the image. So if you then pass in images that have apples, it will fail to detect anything. See here for details: https://www.ccoderun.ca/programming/yolo_faq/#crop_training_images
Your training command is not the recommended one. Please see the Darknet/YOLO FAQ where this is explained: https://www.ccoderun.ca/programming/yolo_faq/#training_command
You should also post a copy of your chart.png file. Maybe have a peek at your other chart_*.png files as well to see if all 3 classes are training the same way. But at the very least, please edit this question and add your chart.png file before trying to figure out why something cannot be detected.
I strongly recommend you download and run DarkMark to test your annotations prior to training. I cannot begin to count the number of issues this has solved over the years. It was written specifically to find and prevent problems. (Disclaimer: I'm the author.) https://www.ccoderun.ca/programming/yolo_faq/#what_software_is_used
Join the Darknet/YOLO discord server. Lots of folks there to help people get started. https://discord.gg/zSq8rtW