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.47k stars 2.85k forks source link

模型导出与不导出时预测的class_id差1 #3764

Closed xzkzdx closed 2 years ago

xzkzdx commented 3 years ago

不导出模型的时候使用tools/infer.py识别的物体class_id正确, python tools/export_model.py导出模型后,使用python deploy/python/infer.py --model_dir=模型导出位置发现class_id少1

yghstill commented 3 years ago

@xzkzdx 哪个模型?配置文件改过吗?

xzkzdx commented 3 years ago

cascade_rcnn_cls_aware_r200_vd_fpn_dcnv2_nonlocal_softnms.yml architecture: CascadeRCNNClsAware max_iters: 100000 snapshot_iter: 100000 use_gpu: true log_iter: 100 save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet200_vd_pretrained.tar weights: output/cascade_rcnn_cls_aware_r200_vd_fpn_dcnv2_nonlocal_softnms/model_final

obj365 dataset format and its eval method are same as those for coco

metric: COCO num_classes: 366

CascadeRCNNClsAware: backbone: ResNet fpn: FPN rpn_head: FPNRPNHead roi_extractor: FPNRoIAlign bbox_head: CascadeBBoxHead bbox_assigner: CascadeBBoxAssigner

ResNet: norm_type: bn depth: 200 feature_maps: [2, 3, 4, 5] freeze_at: 2 variant: d dcn_v2_stages: [3, 4, 5] nonlocal_stages: [4]

FPN: min_level: 2 max_level: 6 num_chan: 256 spatial_scale: [0.03125, 0.0625, 0.125, 0.25]

FPNRPNHead: anchor_generator: anchor_sizes: [32, 64, 128, 256, 512] aspect_ratios: [0.5, 1.0, 2.0] stride: [16.0, 16.0] variance: [1.0, 1.0, 1.0, 1.0] anchor_start_size: 32 min_level: 2 max_level: 6 num_chan: 256 rpn_target_assign: rpn_batch_size_per_im: 256 rpn_fg_fraction: 0.5 rpn_positive_overlap: 0.7 rpn_negative_overlap: 0.3 rpn_straddle_thresh: 0.0 train_proposal: min_size: 0.0 nms_thresh: 0.7 pre_nms_top_n: 2000 post_nms_top_n: 2000 test_proposal: min_size: 0.0 nms_thresh: 0.7 pre_nms_top_n: 1000 post_nms_top_n: 1000

FPNRoIAlign: canconical_level: 4 canonical_size: 224 min_level: 2 max_level: 5 box_resolution: 14 sampling_ratio: 2

CascadeBBoxAssigner: batch_size_per_im: 512 bbox_reg_weights: [10, 20, 30] bg_thresh_lo: [0.0, 0.0, 0.0] bg_thresh_hi: [0.5, 0.6, 0.7] fg_thresh: [0.5, 0.6, 0.7] fg_fraction: 0.25 class_aware: True

CascadeBBoxHead: head: CascadeTwoFCHead

nms: MultiClassSoftNMS

nms: MultiClassNMS

CascadeTwoFCHead: mlp_dim: 1024

MultiClassSoftNMS: score_threshold: 0.001 keep_top_k: 300 softnms_sigma: 0.15

LearningRate: base_lr: 0.0001 schedulers:

OptimizerBuilder: optimizer: momentum: 0.9 type: Momentum regularizer: factor: 0.0001 type: L2

TrainReader: inputs_def: fields: ['image', 'im_info', 'im_id', 'gt_bbox', 'gt_class', 'is_crowd'] dataset: !COCODataSet dataset_dir: /export/dataset/obj365 anno_path: train.json image_dir: train sample_transforms:

EvalReader: inputs_def: fields: ['image', 'im_info', 'im_id', 'im_shape'] dataset: !COCODataSet dataset_dir: /export/dataset/obj365 anno_path: val.json image_dir: val sample_transforms:

TestReader: inputs_def: fields: ['image', 'im_info', 'im_id', 'im_shape'] dataset: !ImageFolder dataset_dir: dataset/obj365/annotations anno_path: annotations.json

anno_path: annotations/instances_val2017.json

sample_transforms:

导出的yml文件:

inference_model/cascade_rcnn_cls_aware_r200_vd_fpn_dcnv2_nonlocal_softnms/infer_cfg.yml

use_python_inference: false mode: fluid draw_threshold: 0.5 metric: COCO arch: RCNN min_subgraph_size: 40 with_background: true Preprocess:

yghstill commented 3 years ago

@xzkzdx 将导出的infer_cfg.yml中label_list中的最后background放在第一位,再试下,这个问题我们跟进排查下。

xzkzdx commented 3 years ago

怎样配置多卡预测,文档里找不到

houxiaonan commented 2 years ago

@xzkzdx 将导出的infer_cfg.yml中label_list中的最后background放在第一位,再试下,这个问题我们跟进排查下。

我也遇到同样的问题,麻烦帮忙解答一下,多谢。

paddle-bot-old[bot] commented 2 years ago

Since this issue has not been updated for more than three months, it will be closed, if it is not solved or there is a follow-up one, please reopen it at any time and we will continue to follow up. It is recommended to pull and try the latest code first. 由于该问题超过三个月未更新,将会被关闭,若问题未解决或有后续问题,请随时重新打开(建议先拉取最新代码进行尝试),我们会继续跟进。