AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.71k stars 7.96k forks source link

yolov3 training issue #2129

Open Hidayath-Shaik opened 5 years ago

Hidayath-Shaik commented 5 years ago

Hi Alexey, I am performing yolo training for gun, knife. All the dataset images are of different sizes downloaded from google. Labelling for images is done using LabelImg. gun dataset count: 4705 knife dataset count: 2277 I have referred "train.txt" for both "valid" and "train" parameters in "obj.data" and trained for 1500 epochs. the mAP was 61% but when I test the prediction via "./darknet detect" command, object is displaying in full frame as shown below: screenshot from 2018-12-29 23-03-15 In the below case, yolo is predicting wrongly: screenshot from 2018-12-29 23-24-26

Below is my cfg file: yolov3_weapon.txt

Questions:

  1. for the first image, the bounding box is shown on the complete frame. Do I need to configure any other setting to plot it correctly?
  2. In the other image, even if we don't have gun in the image, it is predicting wrongly. Do I need to configure any setting to increase the accuracy?
  3. Also, when I predict the same model via openCV i.e. cv.dnn.readNet(yolo-weights, yolo-config) method it is not at all predicting even if I set the confidence to "0". what could be wrong? I want the predictions to work in this approach as this is how we will implement for real time detection.
  4. Please advise on the necessary configuration to achieve the yolo to be able to detect gun,knife from the video surveillance camera with below image quality:

gun 41

I am definitely going to train for more epochs but worried with the current accuracy. It would be great if you can shed some light to fix these issues.

Thanks, Hidayath

AlexeyAB commented 5 years ago

@HidayathullaShaik Hi,

You should get very good result on these images without any addition changes after 4000 iteration. Only if your training dataset is correct.


I have referred "train.txt" for both "valid" and "train" parameters in "obj.data" and trained for 1500 epochs. the mAP was 61%

https://github.com/AlexeyAB/darknet#when-should-i-stop-training

Usually sufficient 2000 iterations for each class(object), but not less than 4000 iterations in total.

Hidayath-Shaik commented 5 years ago
  • Did you train 1500 epochs=iteration/number_of_images, or 1500 iterations?
  • What commands did you use for Training, mAp and Detection?

Also, when I detect the same model via openCV i.e. cv.dnn.readNet(yolo-weights, yolo-config) method it is not at all predicting even if I set the threshold to "0". what could be wrong?

if I start training and stop after some iterations. Then if I start training with the last saved weights file, would yolo make a note of images used for training in last iteration from train.txt or would it train from the first image of train.txt?

Thanks, Hidayath

AlexeyAB commented 5 years ago

I have trained for 1500 iterations.

This is too few iterations. You should train at least 4000 iterations.


Detection Command: ./darknet detect "yolov3_weapon.cfg" "backup/yolov3_weapon_last.weights" "testimages/G1.jpg"

This is incorrect command. It is suitable only for default coco-model. Use this: https://github.com/AlexeyAB/darknet#how-to-use-on-the-command-line ./darknet detector test "data/weapon.data" "yolov3_weapon.cfg" "backup/yolov3_weapon_last.weights" "testimages/G1.jpg"


There are no bad labels when checked in bad.list but will check through yolo_mark.

There only obvious errors in the bad.list and bad_label.list files. You must check your dataset by using Yolo_mark.


Also, when I detect the same model via openCV i.e. cv.dnn.readNet(yolo-weights, yolo-config) method it is not at all predicting even if I set the threshold to "0". what could be wrong?

There may be many reasons: badly trained model, incorrect filenames, ...

Hidayath-Shaik commented 5 years ago

A quick question: if I start training and stop it after some iterations, a weights file will be created. Then if I start training with the last saved weights file, would yolo make a note of images used for training in last iteration from train.txt or would it train from the first image of train.txt?

Hidayath-Shaik commented 5 years ago

Hi Alexey, Is it okay to give complete image dataset for valid in obj.data file? i.e. same image dataset for training and validation.

Thanks, Hidayath

AlexeyAB commented 5 years ago

A quick question: if I start training and stop it after some iterations, a weights file will be created. Then if I start training with the last saved weights file, would yolo make a note of images used for training in last iteration from train.txt or would it train from the first image of train.txt?

Yolo will not remember what images are used. And it doesn't matter, since Yolo read images randomly.


Is it okay to give complete image dataset for valid in obj.data file? i.e. same image dataset for training and validation.

It is ok. But the best practice is to use 80% for training dataset, 10% for valid dataset, 10% for test dataset. Or 90% for training dataset, 10% for valid dataset (valid and test datasets are the same).