open-mmlab / mmyolo

OpenMMLab YOLO series toolbox and benchmark. Implemented RTMDet, RTMDet-Rotated,YOLOv5, YOLOv6, YOLOv7, YOLOv8,YOLOX, PPYOLOE, etc.
https://mmyolo.readthedocs.io/zh_CN/dev/
GNU General Public License v3.0
2.95k stars 534 forks source link

dataset_analysis.py运行后只有coco的80类,而没有自己数据集定义的类别 #681

Closed nitongyang closed 1 year ago

nitongyang commented 1 year ago

Prerequisite

🐞 Describe the bug

(open-mmlab) root@wznjjo:/mnt/mmyolo# python tools/analysis_tools/dataset_analysis.py configs/custom_dataset/yolov5_s-v61_syncbn_fast_1xb32-100e_SODA.py --out-dir work_dirs/dataset_analysis_SODA/train_dataset 03/21 12:52:49 - mmengine - WARNING - "FileClient" will be deprecated in future. Please use io functions in https://mmengine.readthedocs.io/en/latest/api/fileio.html#file-io 03/21 12:52:49 - mmengine - WARNING - "HardDiskBackend" is the alias of "LocalBackend" and the former will be deprecated in future. loading annotations into memory... Done (t=0.10s) creating index... index created!

Print current running information: +--------------------------------------------------------------------+ | Dataset information | +---------------+-------------+--------------+-----------------------+ | Dataset type | Class name | Function | Area rule | +---------------+-------------+--------------+-----------------------+ | train_dataset | All classes | All function | [0, 32, 96, 100000.0] | +---------------+-------------+--------------+-----------------------+

Read the information of each picture in the dataset: [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 3035/3035, 46678.6 task/s, elapsed: 0s, ETA: 0s

The information obtained is as follows: +--------------------------------------------------------------------------------------------------------+ | Information of dataset class | +---------------+----------+----------------+----------+--------------+----------+------------+----------+ | Class name | Bbox num | Class name | Bbox num | Class name | Bbox num | Class name | Bbox num | +---------------+----------+----------------+----------+--------------+----------+------------+----------+ | person | 135 | umbrella | 0 | broccoli | 0 | vase | 0 | | bicycle | 0 | handbag | 0 | carrot | 0 | scissors | 0 | | car | 0 | tie | 0 | hot dog | 0 | teddy bear | 0 | | motorcycle | 0 | suitcase | 0 | pizza | 0 | hair drier | 0 | | airplane | 0 | frisbee | 0 | donut | 0 | toothbrush | 0 | | bus | 0 | skis | 0 | cake | 0 | | | | train | 0 | snowboard | 0 | chair | 0 | | | | truck | 0 | sports ball | 0 | couch | 0 | | | | boat | 0 | kite | 0 | potted plant | 0 | | | | traffic light | 0 | baseball bat | 0 | bed | 0 | | | | fire hydrant | 0 | baseball glove | 0 | dining table | 0 | | | | stop sign | 0 | skateboard | 0 | toilet | 0 | | | | parking meter | 0 | surfboard | 0 | tv | 0 | | | | bench | 0 | tennis racket | 0 | laptop | 0 | | | | bird | 0 | bottle | 0 | mouse | 0 | | | | cat | 0 | wine glass | 0 | remote | 0 | | | | dog | 0 | cup | 0 | keyboard | 0 | | | | horse | 0 | fork | 0 | cell phone | 0 | | | | sheep | 0 | knife | 0 | microwave | 0 | | | | cow | 0 | spoon | 0 | oven | 0 | | | | elephant | 0 | bowl | 0 | toaster | 0 | | | | bear | 0 | banana | 0 | sink | 0 | | | | zebra | 0 | apple | 0 | refrigerator | 0 | | | | giraffe | 0 | sandwich | 0 | book | 0 | | | | backpack | 0 | orange | 0 | clock | 0 | | | +---------------+----------+----------------+----------+--------------+----------+------------+----------+

Read bbox information in each class: [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 80/80, 52659.2 task/s, elapsed: 0s, ETA: 0s

Drawing bbox_num figure: End and save in work_dirs/dataset_analysis_SODA/train_dataset/YOLOv5CocoDataset_bbox_num.jpg

Drawing bbox_wh figure: End and save in work_dirs/dataset_analysis_SODA/train_dataset/YOLOv5CocoDataset_bbox_wh.jpg

Drawing bbox_wh_ratio figure: End and save in work_dirs/dataset_analysis_SODA/train_dataset/YOLOv5CocoDataset_bbox_ratio.jpg

Drawing bbox_area figure: End and save in work_dirs/dataset_analysis_SODA/train_dataset/YOLOv5CocoDataset_bbox_area.jpg

base = '../yolov5/yolov5_s-v61_syncbn_fast_8xb16-300e_coco.py'

max_epochs = 100 # 训练的最大 epoch data_root = './data/SODA/' # 数据集目录的绝对路径

work_dir = './work_dirs/yolov5_s-v61_syncbn_fast_1xb32-100e_SODA'

load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov5/yolov5_s-v61_syncbn_fast_8xb16-300e_coco/yolov5_s-v61_syncbn_fast_8xb16-300e_coco_20220918_084700-86e02187.pth' # noqa

train_batch_size_per_gpu = 32 train_num_workers = 4

save_epoch_intervals = 2

base_lr = base.base_lr / 4

anchors = [(68, 69), (154, 91), (143, 162)], # P3/8 [(242, 160), (189, 287), (391, 207)], # P4/16 [(353, 337), (539, 341), (443, 432)] # P5/32 ]

class_name = ('people','rider','bicycle','motor','vehicle','traffic-sign','traffic-light','traffic-camera','warning-cone','ignore', )
num_classes = len(class_name) metainfo = dict( CLASSES=class_name, PALETTE=[(220, 20, 60),(220, 10, 60),(220, 40, 60),(220, 60, 60),(220, 80, 60),(220, 1000, 60),(220, 120, 60),(220, 140, 60),(220, 160, 60),(220, 220, 60)]
)

train_cfg = dict( max_epochs=max_epochs, val_begin=20,
val_interval=save_epoch_intervals
)

model = dict( bbox_head=dict( head_module=dict(num_classes=num_classes), prior_generator=dict(base_sizes=anchors),

    loss_cls=dict(loss_weight=0.5 *
                  (num_classes / 80 * 3 / _base_.num_det_layers))))

train_dataloader = dict( batch_size=train_batch_size_per_gpu, num_workers=train_num_workers, dataset=dict( delete=True, type='RepeatDataset', times=5, dataset=dict( type=base.dataset_type, data_root=data_root, metainfo=metainfo, ann_file='/mnt/mmyolo/data/SODA/annotations/trainval.json', data_prefix=dict(img='/mnt/mmyolo/data/SODA/images/'), filter_cfg=dict(filter_empty_gt=False, min_size=32), pipeline=base.train_pipeline)))

val_dataloader = dict( dataset=dict( metainfo=metainfo, data_root=data_root, ann_file='/mnt/mmyolo/data/SODA/annotations/trainval.json', data_prefix=dict(img='/mnt/mmyolo/data/SODA/images/')))

test_dataloader = val_dataloader

val_evaluator = dict(ann_file=data_root + 'annotations/trainval.json') test_evaluator = val_evaluator

optim_wrapper = dict(optimizer=dict(lr=base_lr))

default_hooks = dict( checkpoint=dict( type='CheckpointHook', interval=save_epoch_intervals, max_keep_ckpts=5, save_best='auto'), param_scheduler=dict(max_epochs=max_epochs),

logger 输出的间隔

logger=dict(type='LoggerHook', interval=10))

Additional information

No response

mm-assistant[bot] commented 1 year ago

We recommend using English or English & Chinese for issues so that we could have broader discussion.

MACHUNHAI commented 1 year ago

请问解决了吗?

QYChan commented 1 year ago
metainfo = dict(
CLASSES=class_name,  => classes=class_name
PALETTE=[(220, 20, 60),(220, 10, 60),(220, 40, 60),(220, 60, 60),(220, 80, 60),(220, 1000, 60),(220, 120, 60),(220, 140, 60),(220, 160, 60),(220, 220, 60)]
)

Just modify the CLASSES to lower case and solve the problem.