PaddlePaddle / PaddleDetection

Object Detection toolkit based on PaddlePaddle. It supports object detection, instance segmentation, multiple object tracking and real-time multi-person keypoint detection.
Apache License 2.0
12.59k stars 2.86k forks source link

自定义的数据集loss值一直在三百到两百之间,然后预测的种类不是我自己数据集里面的十二个种类,好像是coco的种类。 #2970

Closed w2020 closed 3 years ago

w2020 commented 3 years ago

我的十二个种类 pedestrian people bicycle car van truck tricycle awning-tricycle bus motor ignored-regions others 预测了一个汽车car的图片,结果种类是motorcycle,这是怎么回事呀,我的种类里面没有这一项呀,应该预测car才对。 下面是我的loss Accumulating evaluation results... DONE (t=0.62s). Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.004 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.014 Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.001 Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.001 Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.005 Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.022 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.002 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.010 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.015 Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.008 Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.026 Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.050 [05/12 17:02:37] ppdet.engine INFO: Total sample number: 548, averge FPS: 82.68068909681378 [05/12 17:02:37] ppdet.engine INFO: Best test bbox ap is 0.004. [05/12 17:02:37] ppdet.utils.checkpoint INFO: Save checkpoint: output/ppyolo_tiny_650e_coco [05/12 17:02:38] ppdet.engine INFO: Epoch: [35] [ 0/269] learning_rate: 0.000625 loss_xy: 20.333843 loss_wh: 23.342005 loss_iou: 104.472107 loss_obj: 95.381561 loss_cls: 56.624233 loss: 299.430481 eta: 1 day, 16:58:13 batch_cost: 2.1689 data_cost: 1.9284 ips: 11.0654 images/s [05/12 17:03:11] ppdet.engine INFO: Epoch: [35] [ 20/269] learning_rate: 0.000625 loss_xy: 20.910297 loss_wh: 23.208874 loss_iou: 109.541359 loss_obj: 99.848190 loss_cls: 54.988384 loss: 307.445251 eta: 1 day, 16:56:20 batch_cost: 1.5974 data_cost: 1.3747 ips: 15.0244 images/s [05/12 17:03:57] ppdet.engine INFO: Epoch: [35] [ 40/269] learning_rate: 0.000625 loss_xy: 19.819651 loss_wh: 23.100943 loss_iou: 101.423523 loss_obj: 98.768433 loss_cls: 53.727142 loss: 297.786194 eta: 1 day, 16:56:10 batch_cost: 2.2742 data_cost: 2.0248 ips: 10.5529 images/s [05/12 17:04:44] ppdet.engine INFO: Epoch: [35] [ 60/269] learning_rate: 0.000625 loss_xy: 17.731989 loss_wh: 21.081987 loss_iou: 91.140976 loss_obj: 87.311707 loss_cls: 51.800331 loss: 267.368591 eta: 1 day, 16:55:57 batch_cost: 2.2598 data_cost: 2.0376 ips: 10.6202 images/s [05/12 17:05:23] ppdet.engine INFO: Epoch: [35] [ 80/269] learning_rate: 0.000625 loss_xy: 19.558033 loss_wh: 22.511507 loss_iou: 99.594437 loss_obj: 95.191101 loss_cls: 54.122913 loss: 291.047180 eta: 1 day, 16:54:55 batch_cost: 1.9279 data_cost: 1.6816 ips: 12.4490 images/s [05/12 17:06:07] ppdet.engine INFO: Epoch: [35] [100/269] learning_rate: 0.000625 loss_xy: 20.004009 loss_wh: 23.521124 loss_iou: 101.963264 loss_obj: 91.186920 loss_cls: 56.627697 loss: 291.565796 eta: 1 day, 16:54:22 batch_cost: 2.1290 data_cost: 1.9052 ips: 11.2729 images/s [05/12 17:06:50] ppdet.engine INFO: Epoch: [35] [120/269] learning_rate: 0.000625 loss_xy: 19.614161 loss_wh: 22.959055 loss_iou: 101.022850 loss_obj: 94.342377 loss_cls: 53.245262 loss: 294.704437 eta: 1 day, 16:53:48 batch_cost: 2.1179 data_cost: 1.8664 ips: 11.3322 images/s 一直在三百左右,是不是因为种类的关系?

wangxinxin08 commented 3 years ago

自定义数据集需要修改相应的数据配置文件,coco格式的数据集需要修改configs/datasets/coco_detection.yml或者configs/datasets/coco_instance.yml

w2020 commented 3 years ago

自定义数据集需要修改相应的数据配置文件,coco格式的数据集需要修改configs/datasets/coco_detection.yml或者configs/datasets/coco_instance.yml

路径我都改了,numberclass设置的12,然后还改了category.py 里面的 _coco17_category():的clsid2catid和catid2name,改成自己的种类了。 这个也是loss值降不下来,只能识别car。

wangxinxin08 commented 3 years ago

发一下相关的配置文件吧

w2020 commented 3 years ago

metric: COCO num_classes: 12

TrainDataset: !COCODataSet image_dir: train2017 anno_path: annotations/instances_train2017.json dataset_dir: dataset/coco data_fields: ['image', 'gt_bbox', 'gt_class', 'is_crowd']

EvalDataset: !COCODataSet image_dir: val2017 anno_path: annotations/instances_val2017.json dataset_dir: dataset/coco

TestDataset: !ImageFolder anno_path: annotations/instances_val2017.json 我的数据集改成了和coco数据集一样的名字和路径,是不是这样有影响? —————————— epoch: 300

LearningRate: base_lr: 0.000625 schedulers:

OptimizerBuilder: optimizer: momentum: 0.9 type: Momentum regularizer: factor: 0.0005 type: L2 —————————— BASE: [ '../datasets/coco_detection.yml', '../runtime.yml', './base/ppyolo_tiny.yml', './base/optimizer_650e.yml', './base/ppyolo_tiny_reader.yml', ]

snapshot_epoch: 1 weights: output/ppyolo_tiny_650e_coco/model_final

wangxinxin08 commented 3 years ago

看配置文件应该没问题,应该是数据集比较少吧,而car的占比比较大,建议调整学习率试试

w2020 commented 3 years ago

好的,数据集有六千多张图片。 那ppdet/data/source/category.py 的这个种类是要改的吗?我不改的话好像就会识别到coco上的motorcycle,改了现在是没有,但是还是只能识别car,其他种类的车型是识别不出来,可能是数据集小了。 学习率还要往小了调么,我是单GPU。谢谢啦 def _coco17_category(): """ Get class id to category id map and category id to category name map of COCO2017 dataset

"""
clsid2catid = {
    1: 1,
    2: 2,
    3: 3,
    4: 4,
    5: 5,
    6: 6,
    7: 7,
    8: 8,
    9: 9,
    10: 10,
    11: 11,
    12:12,
}

catid2name = {
    0: 'background',
    1: 'pedestrian',
    2: 'people',
    3: 'bicycle',
    4: 'car',
    5: 'van',
    6: 'truck',
    7: 'tricycle',
    8: 'awning-tricycle',
    9: 'bus',
    10: 'motor',
    11: 'ignored-regions',
    12: 'others'
}

clsid2catid = {k - 1: v for k, v in clsid2catid.items()}
catid2name.pop(0)

return clsid2catid, catid2name
wangxinxin08 commented 3 years ago

正确地设置了数据集的路径这个应该不需要修改,学习率也可以调大试试

soHardToHaveAName commented 3 years ago

你好,请问最后是怎么解决的啊?我也出现了一样的问题

w2020 commented 3 years ago

哎,我也没找到为什么。。我就没用这个了

------------------ 原始邮件 ------------------ 发件人: "wang chong @.>; 发送时间: 2021年8月4日(星期三) 中午12:42 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [PaddlePaddle/PaddleDetection] 自定义的数据集loss值一直在三百到两百之间,然后预测的种类不是我自己数据集里面的十二个种类,好像是coco的种类。 (#2970)

你好,请问最后是怎么解决的啊?我也出现了一样的问题

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

soHardToHaveAName commented 3 years ago

https://github.com/PaddlePaddle/PaddleDetection/issues/970

啊我找到原因了!就是因为路径写错了,写成绝对路径就没问题了