yolov5_obb icon indicating copy to clipboard operation
yolov5_obb copied to clipboard

running train.py and mAP, P, R always 0

Open tinly00 opened this issue 2 years ago • 8 comments

我使用自己的数据集训练出现了以下问题,想请教一下: 训练数据集270张,数据集建立的是单类、密集小目标识别,进行训练,效果并不好:map一直为0 labels_correlogram labels_xyls results train_batch0 train_batch1 train_batch2

val_batch0_labels.jpg val_batch0_labels

val_batch0_pred.jpg val_batch0_pred

hyp:

lr0: 0.01
lrf: 0.2
momentum: 0.937
weight_decay: 0.0005
warmup_epochs: 150
warmup_momentum: 0.8
warmup_bias_lr: 0.1
box: 0.05
cls: 0.5
cls_pw: 1.0
theta: 0.5
theta_pw: 1.0
obj: 1.0
obj_pw: 1.0
iou_t: 0.2
anchor_t: 4.0
fl_gamma: 0.0
hsv_h: 0.015
hsv_s: 0.7
hsv_v: 0.4
degrees: 180.0
translate: 0.1
scale: 0.25
shear: 0.0
perspective: 0.0
flipud: 0.5
fliplr: 0.5
mosaic: 0.75
mixup: 0.1
copy_paste: 0.0
cls_theta: 180
csl_radius: 2.0

opt:

weights: weights/yolov5m.pt
cfg: ''
data: /media/scau/21B1CA0D9A1CBC09/DL/yolov5_obb-master/yolov5_obb-master/data/obbspike_polydata.yaml
hyp: data/hyps/obb/hyp.finetune_dota.yaml
epochs: 500
batch_size: 4
imgsz: 1024
rect: false
resume: false
nosave: false
noval: false
noautoanchor: false
evolve: null
bucket: ''
cache: null
image_weights: false
device: ''
multi_scale: false
single_cls: false
adam: false
sync_bn: false
workers: 8
project: runs/train
name: exp
exist_ok: false
quad: false
linear_lr: false
label_smoothing: 0.0
patience: 1000
freeze:
- 0
save_period: -1
local_rank: -1
entity: null
upload_dataset: false
bbox_interval: -1
artifact_alias: latest
save_dir: runs/train/exp30

map一直为0,应该没跑起来,可以请教一下作者大大是哪里出了问题了吗?请问有什么改参数建议呢?谢谢! @hukaixuan19970627 @acai66 @Ethan-niu

tinly00 avatar Aug 21 '22 08:08 tinly00

其中训练的时候,label 有很多负的,不知道是否有关?

train: Scanning '/media/scau/21B1CA0D9A1CBC09/DL/yolov5_obb-master/yolov5_obb-master/dataset/spikedata/train/labelTxt.cache' images and labels... 269 found, 1 missing, 0 empty, 248 corrupted: 100% 270/270 [00:00<?, ?it/s]
train: WARNING: /media/scau/21B1CA0D9A1CBC09/DL/yolov5_obb-master/yolov5_obb-master/dataset/spikedata/train/images/pic_DJI_0639_0001_11.jpg: ignoring corrupt image/label: negative label values [    -7.8397     -5.7692     -3.8711     -0.4634     -17.641     -3.4027       -13.2 -7.6294e-06      -17.04     -9.9187         -17], please check your dota format labels
train: WARNING: /media/scau/21B1CA0D9A1CBC09/DL/yolov5_obb-master/yolov5_obb-master/dataset/spikedata/train/images/pic_DJI_0639_0001_12.jpg: ignoring corrupt image/label: negative label values [    -17.909     -7.7279 -1.5259e-05     -11.452     -28.554    -0.80508], please check your dota format labels
train: WARNING: /media/scau/21B1CA0D9A1CBC09/DL/yolov5_obb-master/yolov5_obb-master/dataset/spikedata/train/images/pic_DJI_0639_0001_21.jpg: ignoring corrupt image/label: negative label values [    -3.8497     -16.142    -0.22592      -4.267     -11.721], please check your dota format labels
train: WARNING: /media/scau/21B1CA0D9A1CBC09/DL/yolov5_obb-master/yolov5_obb-master/dataset/spikedata/train/images/pic_DJI_0639_0001_22.jpg: ignoring corrupt image/label: negative label values [    -7.7083     -1.6432     -18.711], please check your dota format labels
train: WARNING: /media/scau/21B1CA0D9A1CBC09/DL/yolov5_obb-master/yolov5_obb-master/dataset/spikedata/train/images/pic_DJI_0639_0002_11.jpg: ignoring corrupt image/label: negative label values [   -0.91707     -9.3809     -3.1936     -1.7354     -8.1032 -7.6294e-06     -14.276     -18.161     -9.5996      -13.68     -2.9231     -3.4462], please check your dota format labels
train: WARNING: /media/scau/21B1CA0D9A1CBC09/DL/yolov5_obb-master/yolov5_obb-master/dataset/spikedata/train/images/pic_DJI_0639_0002_12.jpg: ignoring corrupt image/label: negative label values [    -27.595     -1.6335      -11.23     -11.597], please check your dota format labels
train: WARNING: /media/scau/21B1CA0D9A1CBC09/DL/yolov5_obb-master/yolov5_obb-master/dataset/spikedata/train/images/pic_DJI_0639_0002_21.jpg: ignoring corrupt image/label: negative label values [   -0.51249    -0.91823 -3.3826e-06     -10.265     -3.9489], please check your dota format labels
train: WARNING: /media/scau/21B1CA0D9A1CBC09/DL/yolov5_obb-master/yolov5_obb-master/dataset/spikedata/train/images/pic_DJI_0639_0002_22.jpg: ignoring corrupt image/label: negative label values [    -1.7188    -0.03282], please check your dota format labels
train: WARNING: /media/scau/21B1CA0D9A1CBC09/DL/yolov5_obb-master/yolov5_obb-master/dataset/spikedata/train/images/pic_DJI_0639_0003_11.jpg: ignoring corrupt image/label: negative label values [    -5.6819     -21.922     -17.011 -4.7684e-06     -14.241     -9.9944      -4.677     -11.046     -5.7779     -12.441     -10.176     -10.725     -16.173], please check your dota format labels
train: WARNING: /media/scau/21B1CA0D9A1CBC09/DL/yolov5_obb-master/yolov5_obb-master/dataset/spikedata/train/images/pic_DJI_0639_0003_12.jpg: ignoring corrupt image/label: negative label values [    -15.664     -12.658       -7.98     -25.829], please check your dota format labels
train: WARNING: /media/scau/21B1CA0D9A1CBC09/DL/yolov5_obb-master/yolov5_obb-master/dataset/spikedata/train/images/pic_DJI_0639_0003_21.jpg: ignoring corrupt image/label: negative label values [    -29.128     -3.4046     -9.1896      -25.16    -0.43852     -6.2855      -13.48], please check your dota format labels
train: WARNING: /media/scau/21B1CA0D9A1CBC09/DL/yolov5_obb-master/yolov5_obb-master/dataset/spikedata/train/images/pic_DJI_0639_0003_22.jpg: ignoring corrupt image/label: negative label values [      -13.2     -3.9434     -3.9259     -32.624], please check your dota format labels
train: WARNING: /media/scau/21B1CA0D9A1CBC09/DL/yolov5_obb-master/yolov5_obb-master/dataset/spikedata/train/images/pic_DJI_0639_0004_11.jpg: ignoring corrupt image/label: negative label values [    -3.8258     -16.674     -6.2168     -12.569], please check your dota format labels
train: WARNING: /media/scau/21B1CA0D9A1CBC09/DL/yolov5_obb-master/yolov5_obb-master/dataset/spikedata/train/images/pic_DJI_0639_0004_12.jpg: ignoring corrupt image/label: negative label values [    -7.2419], please check your dota format labels
............

tinly00 avatar Aug 21 '22 08:08 tinly00

getting the same error, very metric is 0.

nik13 avatar Aug 23 '22 16:08 nik13

hello, thank your great project! I have just trained your solution with DOTA dataset and It works well !! But when I created custom dataset so the result is very bad :(, recall and precision are fluctuate greatly and often approach 0 Could you please double check? thanks

image

hongson23 avatar Aug 24 '22 08:08 hongson23

the main issue is if you are using single class. Also, finetune your lr.

nik13 avatar Aug 24 '22 09:08 nik13

hello, thank your great project! I have just trained your solution with DOTA dataset and It works well !! But when I created custom dataset so the result is very bad :(, recall and precision are fluctuate greatly and often approach 0 Could you please double check? thanks

image

I had used this project on another custom dataset, it worked well too. So i guess the question is my dataset. From the warning info, it means my label value is negative, so when training, the pic with negative value will be deleted. So, pic for train decreased and there are few pictures in the dataset. I use labelme with polygon method,and when i transform the polygon points into smallest rectangle and get its 4 points, but the point‘s coordinate sometimes will out of the picture. So, i get the negative label value, but now i do not know how to solve it better.

tinly00 avatar Aug 25 '22 08:08 tinly00

the main issue is if you are using single class. Also, finetune your lr.

no, i set a class'none', it can solve the problem that only 1 class.

tinly00 avatar Aug 25 '22 08:08 tinly00

您好!可以将Adam置为True试试。我写一下我的调参路径,希望对您有用。 1、参数都没改,用自己的数据集,训练100个epoch,最后的P、R一直都不高; results

2、后来我参考 https://github.com/hukaixuan19970627/yolov5_obb/issues/380 ,调小了lr0: 0.001,mosaic: 0.0,使用exp2的best作为预训练模型;训练到100早停了; results

3、参考 https://github.com/hukaixuan19970627/yolov5_obb/issues/57#issuecomment-888931205 ,Adam置为True,使用exp2的best作为预训练模型,lr0: 0.001,mosaic: 0.0,P、R提升很大 results

xuewengeophysics avatar Nov 08 '22 09:11 xuewengeophysics

@tinly00 请问现在效果怎么样?可以识别密集小目标了吗

WKffz avatar Mar 21 '24 13:03 WKffz