open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.5k stars 9.45k forks source link

Training on your own data set, once you start with precision, the next epoch will all become zeros #11924

Open luoyq6 opened 2 months ago

luoyq6 commented 2 months ago
企业微信截图_172475129453

auto_scale_lr = dict(base_batch_size=16, enable=True) backend_args = None data_root = '/data/luoyq/data/toutu/v3' dataset_type = 'VOCDataset' default_hooks = dict( checkpoint=dict(rule='greater', save_best='auto', type='CheckpointHook'), logger=dict(interval=50, type='LoggerHook'), param_scheduler=dict(type='ParamSchedulerHook'), sampler_seed=dict(type='DistSamplerSeedHook'), timer=dict(type='IterTimerHook'), visualization=dict(type='DetVisualizationHook')) default_scope = 'mmdet' env_cfg = dict( cudnn_benchmark=False, dist_cfg=dict(backend='nccl'), mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0)) launcher = 'pytorch' load_from = None log_level = 'INFO' log_processor = dict(by_epoch=True, type='LogProcessor', window_size=50) model = dict( backbone=dict( base_width=4, depth=50, frozen_stages=1, groups=32, init_cfg=dict( checkpoint='open-mmlab://resnext50_32x4d', type='Pretrained'), norm_cfg=dict(requires_grad=True, type='BN'), norm_eval=True, num_stages=4, out_indices=( 0, 1, 2, 3, ), style='pytorch', type='ResNeXt'), data_preprocessor=dict( bgr_to_rgb=True, mean=[ 123.675, 116.28, 103.53, ], pad_size_divisor=32, std=[ 58.395, 57.12, 57.375, ], type='DetDataPreprocessor'), neck=dict( in_channels=[ 256, 512, 1024, 2048, ], num_outs=5, out_channels=256, type='FPN'), roi_head=dict( bbox_head=[ dict( bbox_coder=dict( target_means=[ 0.0, 0.0, 0.0, 0.0, ], target_stds=[ 0.1, 0.1, 0.2, 0.2, ], type='DeltaXYWHBBoxCoder'), fc_out_channels=1024, in_channels=256, loss_bbox=dict(beta=1.0, loss_weight=1.0, type='SmoothL1Loss'), loss_cls=dict( loss_weight=1.0, type='CrossEntropyLoss', use_sigmoid=False), num_classes=4, reg_class_agnostic=True, roi_feat_size=7, type='Shared2FCBBoxHead'), dict( bbox_coder=dict( target_means=[ 0.0, 0.0, 0.0, 0.0, ], target_stds=[ 0.05, 0.05, 0.1, 0.1, ], type='DeltaXYWHBBoxCoder'), fc_out_channels=1024, in_channels=256, loss_bbox=dict(beta=1.0, loss_weight=1.0, type='SmoothL1Loss'), loss_cls=dict( loss_weight=1.0, type='CrossEntropyLoss', use_sigmoid=False), num_classes=4, reg_class_agnostic=True, roi_feat_size=7, type='Shared2FCBBoxHead'), dict( bbox_coder=dict( target_means=[ 0.0, 0.0, 0.0, 0.0, ], target_stds=[ 0.033, 0.033, 0.067, 0.067, ], type='DeltaXYWHBBoxCoder'), fc_out_channels=1024, in_channels=256, loss_bbox=dict(beta=1.0, loss_weight=1.0, type='SmoothL1Loss'), loss_cls=dict( loss_weight=1.0, type='CrossEntropyLoss', use_sigmoid=False), num_classes=4, reg_class_agnostic=True, roi_feat_size=7, type='Shared2FCBBoxHead'), ], bbox_roi_extractor=dict( featmap_strides=[ 4, 8, 16, 32, ], out_channels=256, roi_layer=dict(output_size=7, sampling_ratio=0, type='RoIAlign'), type='SingleRoIExtractor'), num_stages=3, stage_loss_weights=[ 1, 0.5, 0.25, ], type='CascadeRoIHead'), rpn_head=dict( anchor_generator=dict( ratios=[ 0.0625, 0.08333333333333333, 0.5, 1.0, 2.0, 12.0, 16.0, ], scales=[ 4, 8, 16, ], strides=[ 4, 8, 16, 32, 64, ], type='AnchorGenerator'), bbox_coder=dict( target_means=[ 0.0, 0.0, 0.0, 0.0, ], target_stds=[ 1.0, 1.0, 1.0, 1.0, ], type='DeltaXYWHBBoxCoder'), feat_channels=256, in_channels=256, loss_bbox=dict( beta=0.1111111111111111, loss_weight=1.0, type='SmoothL1Loss'), loss_cls=dict( loss_weight=1.0, type='CrossEntropyLoss', use_sigmoid=True), type='RPNHead'), test_cfg=dict( rcnn=dict( max_per_img=100, nms=dict(iou_threshold=0.5, type='nms'), score_thr=0.05), rpn=dict( max_per_img=1000, min_bbox_size=0, nms=dict(iou_threshold=0.7, type='nms'), nms_pre=1000)), train_cfg=dict( rcnn=[ dict( assigner=dict( ignore_iof_thr=-1, match_low_quality=False, min_pos_iou=0.5, neg_iou_thr=0.5, pos_iou_thr=0.5, type='MaxIoUAssigner'), debug=False, pos_weight=-1, sampler=dict( add_gt_as_proposals=True, neg_pos_ub=-1, num=512, pos_fraction=0.25, type='RandomSampler')), dict( assigner=dict( ignore_iof_thr=-1, match_low_quality=False, min_pos_iou=0.6, neg_iou_thr=0.6, pos_iou_thr=0.6, type='MaxIoUAssigner'), debug=False, pos_weight=-1, sampler=dict( add_gt_as_proposals=True, neg_pos_ub=-1, num=512, pos_fraction=0.25, type='RandomSampler')), dict( assigner=dict( ignore_iof_thr=-1, match_low_quality=False, min_pos_iou=0.7, neg_iou_thr=0.7, pos_iou_thr=0.7, type='MaxIoUAssigner'), debug=False, pos_weight=-1, sampler=dict( add_gt_as_proposals=True, neg_pos_ub=-1, num=512, pos_fraction=0.25, type='RandomSampler')), ], rpn=dict( allowed_border=0, assigner=dict( ignore_iof_thr=-1, match_low_quality=True, min_pos_iou=0.3, neg_iou_thr=0.3, pos_iou_thr=0.7, type='MaxIoUAssigner'), debug=False, pos_weight=-1, sampler=dict( add_gt_as_proposals=False, neg_pos_ub=-1, num=256, pos_fraction=0.5, type='RandomSampler')), rpn_proposal=dict( max_per_img=2000, min_bbox_size=0, nms=dict(iou_threshold=0.7, type='nms'), nms_pre=2000)), type='CascadeRCNN') optim_wrapper = dict( loss_scale='dynamic', optimizer=dict(lr=0.02, momentum=0.9, type='SGD', weight_decay=0.0001), type='AmpOptimWrapper') param_scheduler = [ dict( begin=0, by_epoch=False, end=500, start_factor=0.001, type='LinearLR'), dict( begin=0, by_epoch=True, end=12, gamma=0.1, milestones=[ 30, 60, 90, ], type='MultiStepLR'), ] resume = False test_cfg = dict(type='TestLoop') test_dataloader = dict( batch_size=2, dataset=dict( ann_file='VOC2007/ImageSets/Main/val.txt', backend_args=None, data_prefix=dict(sub_data_root='VOC2007/'), data_root='/data/luoyq/data/toutu/v3', pipeline=[ dict(backend_args=None, type='LoadImageFromFile'), dict(keep_ratio=True, scale=( 2048, 1024, ), type='Resize'), dict(type='LoadAnnotations', with_bbox=True), dict( meta_keys=( 'img_id', 'img_path', 'ori_shape', 'img_shape', 'scale_factor', ), type='PackDetInputs'), ], test_mode=True, type='VOCDataset'), drop_last=False, num_workers=6, persistent_workers=True, sampler=dict(shuffle=False, type='DefaultSampler')) test_evaluator = dict(eval_mode='11points', metric='mAP', type='VOCMetric') test_pipeline = [ dict(backend_args=None, type='LoadImageFromFile'), dict(keep_ratio=True, scale=( 2048, 1024, ), type='Resize'), dict(type='LoadAnnotations', with_bbox=True), dict( meta_keys=( 'img_id', 'img_path', 'ori_shape', 'img_shape', 'scale_factor', ), type='PackDetInputs'), ] train_cfg = dict(max_epochs=100, type='EpochBasedTrainLoop', val_interval=1) train_dataloader = dict( batch_sampler=dict(type='AspectRatioBatchSampler'), batch_size=2, dataset=dict( dataset=dict( datasets=[ dict( ann_file='VOC2007/ImageSets/Main/train.txt', backend_args=None, data_prefix=dict(sub_data_root='VOC2007/'), data_root='/data/luoyq/data/toutu/v3', filter_cfg=dict( bbox_min_size=0, filter_empty_gt=True, min_size=32), pipeline=[ dict(backend_args=None, type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True), dict( keep_ratio=True, scale=[ ( 2600, 1440, ), ( 2048, 1280, ), ], type='RandomResize'), dict(prob=0.5, type='RandomFlip'), dict(type='PackDetInputs'), ], type='VOCDataset'), dict( ann_file='VOC2007/ImageSets/Main/val.txt', backend_args=None, data_prefix=dict(sub_data_root='VOC2007/'), data_root='/data/luoyq/data/toutu/v3', filter_cfg=dict( bbox_min_size=0, filter_empty_gt=True, min_size=32), pipeline=[ dict(backend_args=None, type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True), dict( keep_ratio=True, scale=[ ( 2600, 1440, ), ( 2048, 1280, ), ], type='RandomResize'), dict(prob=0.5, type='RandomFlip'), dict(type='PackDetInputs'), ], type='VOCDataset'), ], ignore_keys=[ 'dataset_type', ], type='ConcatDataset'), times=3, type='RepeatDataset'), num_workers=6, persistent_workers=True, sampler=dict(shuffle=True, type='DefaultSampler')) train_pipeline = [ dict(backend_args=None, type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True), dict( keep_ratio=True, scale=[ ( 2600, 1440, ), ( 2048, 1280, ), ], type='RandomResize'), dict(prob=0.5, type='RandomFlip'), dict(type='PackDetInputs'), ] val_cfg = dict(type='ValLoop') val_dataloader = dict( batch_size=2, dataset=dict( ann_file='VOC2007/ImageSets/Main/val.txt', backend_args=None, data_prefix=dict(sub_data_root='VOC2007/'), data_root='/data/luoyq/data/toutu/v3', pipeline=[ dict(backend_args=None, type='LoadImageFromFile'), dict(keep_ratio=True, scale=( 2048, 1024, ), type='Resize'), dict(type='LoadAnnotations', with_bbox=True), dict( meta_keys=( 'img_id', 'img_path', 'ori_shape', 'img_shape', 'scale_factor', ), type='PackDetInputs'), ], test_mode=True, type='VOCDataset'), drop_last=False, num_workers=6, persistent_workers=True, sampler=dict(shuffle=False, type='DefaultSampler')) val_evaluator = dict(eval_mode='11points', metric='mAP', type='VOCMetric') vis_backends = [ dict(type='LocalVisBackend'), ] visualizer = dict( name='visualizer', type='DetLocalVisualizer', vis_backends=[ dict(type='LocalVisBackend'), ]) work_dir = 'work-dir/toutu/v3'

sunrongqian commented 1 month ago

Have you solved this issue yet? I'm conducting instance segmentation for 5 categories, but the AP (Average Precision) for each epoch remains at 0. I've already made changes where I thought were necessary.

luoyq6 commented 1 month ago

你解决了这个问题吗?我正在对 5 个类别进行实例分割,但每个 epoch 的 AP (Average Precision) 仍为 0。我已经在我认为必要的地方做了改变。 no

luoyq6 commented 1 month ago

@hhaAndroid

sunrongqian commented 1 month ago

你解决了这个问题吗?我正在对 5 个类别进行实例分割,但每个 epoch 的 AP (Average Precision) 仍为 0。我已经在我认为必要的地方做了改变。 no

I have solved the problem. You can try to modify from the example given by the official documentation, that is, build a new weight file, and supplement the parameters you want to change, rather than modify in the original py file. After modification, run python setup.py install on the terminal, and then train.

Cloud65000 commented 1 month ago

你解决了这个问题吗?我正在对 5 个类别进行实例分割,但每个 epoch 的 AP (Average Precision) 仍为 0。我已经在我认为必要的地方做了改变。 no

I have solved the problem. You can try to modify from the example given by the official documentation, that is, build a new weight file, and supplement the parameters you want to change, rather than modify in the original py file. After modification, run python setup.py install on the terminal, and then train.

Maybe I have had the same problem. I added some new layers and some learnable vectors into one module of MM-DINO. I can get a normal output of loss after 1 iteration but the weights of added layers and learnable vectors suddenly became NAN when running the second iteration. For your suggested solution, directly building a new weight file means adding the names of the new layers and vectors into the weight file, right? But how to initialize the weight of it? MMdetection uses the class "runner" to initialize the weights of the whole model and then load the checkpoint file to cover the previous initialization. Since the newly added layers and vectors don't exist in the checkpoint file, the weights of them are initialized by the global initialization of the class "runner".