AlexeyAB / darknet

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

the loss is no converge #1489

Open 18bold opened 6 years ago

18bold commented 6 years ago

I use the yolov3-tiny_xnor.cfg to detect one class, the loss is around 5. I use 1300 images have object and 1300 images have no label. average loss_screenshot_28 08 2018 the .cfg file [net] batch=32 subdivisions=8 width=416 height=416 channels=3 momentum=0.9 decay=0.0005 angle=0 saturation = 1.5 exposure = 1.5 hue=.1

learning_rate=0.001 burn_in=1000 max_batches = 10000 policy=steps steps=3000,7500 scales=.5,.1

[convolutional] batch_normalize=1 filters=16 size=3 stride=1 pad=1 activation=leaky

[maxpool] size=2 stride=2

[convolutional] xnor=1 batch_normalize=1 filters=32 size=3 stride=1 pad=1 activation=leaky

[maxpool] size=2 stride=2

[convolutional] xnor=1 batch_normalize=1 filters=64 size=3 stride=1 pad=1 activation=leaky

[maxpool] size=2 stride=2

[convolutional] xnor=1 batch_normalize=1 filters=128 size=3 stride=1 pad=1 activation=leaky

[maxpool] size=2 stride=2

[convolutional] xnor=1 batch_normalize=1 filters=256 size=3 stride=1 pad=1 activation=leaky

[maxpool] size=2 stride=2

[convolutional] xnor=1 batch_normalize=1 filters=512 size=3 stride=1 pad=1 activation=leaky

[maxpool] size=2 stride=1

[convolutional] xnor=1 batch_normalize=1 filters=1024 size=3 stride=1 pad=1 activation=leaky

###########

[convolutional] xnor=1 batch_normalize=1 filters=256 size=1 stride=1 pad=1 activation=leaky

[convolutional] batch_normalize=1 filters=512 size=3 stride=1 pad=1 activation=leaky

[convolutional] size=1 stride=1 pad=1 filters=18 activation=linear

[yolo] mask = 3,4,5 anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319 classes=1 num=6 jitter=.3 ignore_thresh = .7 truth_thresh = 1 random=1

[route] layers = -4

[convolutional] xnor=1 batch_normalize=1 filters=128 size=1 stride=1 pad=1 activation=leaky

[upsample] stride=8

[route] layers = -1, 4

[convolutional] xnor=1 batch_normalize=1 filters=256 size=3 stride=1 pad=1 activation=leaky

[convolutional] size=1 stride=1 pad=1 filters=18 activation=linear

[yolo] mask = 0,1,2 anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319 classes=1 num=6 jitter=.3 ignore_thresh = .7 truth_thresh = 1 random=1

18bold commented 6 years ago

detections_count = 13789, unique_truth_count = 2266
class_id = 0, name = head, 789 ap = 67.96 % for thresh = 0.25, precision = 0.93, recall = 0.42, F1-score = 0.58 for thresh = 0.25, TP = 960, FP = 75, FN = 1306, average IoU = 69.76 %

mean average precision (mAP) = 0.679619, or 67.96 % Total Detection Time: 8.000000 Seconds

AlexeyAB commented 6 years ago

mean average precision (mAP) = 0.679619, or 67.96 % Total Detection Time: 8.000000 Seconds

mAP isn't bad.

I use the yolov3-tiny_xnor.cfg to detect one class, the loss is around 5. I use 1300 images have object and 1300 images have no label.

What command did you use for training?

Also why do you use batch=32?

18bold commented 6 years ago

@AlexeyAB Thank you for your reply.
./darknet detector train cfg/yolov3-tiny_xnor.data cfg/yolov3-tiny_xnor.cfg yolov3-tiny.conv.15 -i 0

I used batch=64 first, the loss is also around 5, so I change to 32 the result is the same. How can I get the better loss and mAP?

AlexeyAB commented 6 years ago

How can I get the better loss and mAP?


Add more images to the Training dataset, also add negative samples (images without objects) Try to use batch=64 subdivisions=2 or 4 for Training if GPU-memory is enough. Add here another one layer: https://github.com/AlexeyAB/darknet/blob/18d5e4f39c1441f2c21043ac3204b5cb279f8758/cfg/yolov3-tiny_xnor.cfg#L175

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

And train again from the begining.

Also for detection you can try to use flag -thresh 0.2 or 0.1.