AlexeyAB / darknet

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

Trained chart looks weird, both mAP and loss are high. #8571

Open KyleChenpopo opened 2 years ago

KyleChenpopo commented 2 years ago

Hi, very thankful for the invention of yolov4 and this repository, I already trained with yolov4 and got a excellent result.

But this time when I trained with "yolov4-csp", I got a weird chart of mAP and Loss, I'm not sure where I did the wrong settings or not. Here show my training information.

os:
windows10-64bit

command(cmd):
darknet.exe detector train data/obj.data cfg/yolov4-csp-custom.cfg yolov4-csp.conv.142 -map
# I've used pre-trained weight "yolov4-csp.conv.142".
# I've fine-tuned parameters inside "yolov4-csp.cfg" as my custom cfg file.

yolov4-csp-custom.cfg (I only changed some of the parameters):
[net]
batch=64
subdivisions=16
width=416
height=416
channels=3
momentum=0.949
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

learning_rate=0.001
burn_in=1000
max_batches = 6000
policy=steps
steps=4800,5400
scales=.1,.1

mosaic=1

letter_box=1

ema_alpha=0.9998

#optimized_memory=1

#23:104x104 54:52x52 85:26x26 104:13x13 for 416
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#also changed classes=1 and filters=18 at the last 3 layers of convolutional and yolo.

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

[yolo]
mask = 6,7,8
anchors = 12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 459, 401
classes=1
num=9
jitter=.1
scale_x_y = 2.0
objectness_smooth=1
ignore_thresh = .7
truth_thresh = 1
#random=1
resize=1.5
iou_thresh=0.2
iou_normalizer=0.05
cls_normalizer=0.5
obj_normalizer=0.4
iou_loss=ciou
nms_kind=diounms
beta_nms=0.6
new_coords=1
max_delta=2

*This is information of my CUDA/cuDNN/OPENCV/GPU version 3080

*This is my trained chart, before I trained with normal yolov4, the Loss is not like this. But with yolov4-csp, the blue line is always on the top. chart_yolov4-csp-custom

*This is showing what it looks like after I finished 6000 steps.

mAP

My question is, why the mAP and Loss both are high? Am I setting something wrong? Because I used the same dataset to trained with normal yolov4 before, so I think my dataset settings are ok. But just saw this chart, can anyone gives some advise?

BTW: the trained weight (yolov4-csp-custom_best.weights) can correctly detect my objects!

Hato1 commented 2 years ago

If you want to see the change in loss, you can adjust chart height in config (.cfg). I've found max_chart_loss = 70 works well to mitigate this issue.

Edit: One too many zeros, oops

stephanecharette commented 2 years ago

I don't know if the previous commenter was trying to be funny. A more reasonable values is max_chart_loss=4.0. Your loss should be between 0.0 and 1.0 to get decent results. A value of 700 is so high that the chart won't show you anything useful.

From the image above, if your loss is approximately 22, I'd say there is room for improvement.