Repository: PaddlePaddle/PaddleDetection

Issue:
跑敏感度分析时报错
按文档执行如下指令：
python3 slim/sensitive/sensitive.py -c configs/yolov3_mobilenet_v1_voc.yml -o weights=https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_voc.tar --pruned_params "yolo_block.0.0.0.conv.weights,yolo_block.0.0.1.conv.weights,yolo_block.0.1.0.conv.weights,yolo_block.0.1.1.conv.weights,yolo_block.0.2.conv.weights,yolo_block.0.tip.conv.weights,yolo_block.1.0.0.conv.weights,yolo_block.1.0.1.conv.weights,yolo_block.1.1.0.conv.weights,yolo_block.1.1.1.conv.weights,yolo_block.1.2.conv.weights,yolo_block.1.tip.conv.weights,yolo_block.2.0.0.conv.weights,yolo_block.2.0.1.conv.weights,yolo_block.2.1.0.conv.weights,yolo_block.2.1.1.conv.weights,yolo_block.2.2.conv.weights,yolo_block.2.tip.conv.weights" --sensitivities_file "./demo.data"
报以下错误：2020-03-18 14:40:01,847-INFO: pruned params: ['yolo_block.0.0.0.conv.weights', 'yolo_block.0.0.1.conv.weights', 'yolo_block.0.1.0.conv.weights', 'yolo_block.0.1.1.conv.weights', 'yolo_block.0.2.conv.weights', 'yolo_block.0.tip.conv.weights', 'yolo_block.1.0.0.conv.weights', 'yolo_block.1.0.1.conv.weights', 'yolo_block.1.1.0.conv.weights', 'yolo_block.1.1.1.conv.weights', 'yolo_block.1.2.conv.weights', 'yolo_block.1.tip.conv.weights', 'yolo_block.2.0.0.conv.weights', 'yolo_block.2.0.1.conv.weights', 'yolo_block.2.1.0.conv.weights', 'yolo_block.2.1.1.conv.weights', 'yolo_block.2.2.conv.weights', 'yolo_block.2.tip.conv.weights']
2020-03-18 14:40:01,847-INFO: pruned ratios: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]
I0318 14:40:01.860719 14780 parallel_executor.cc:440] The Program will be executed on CUDA using ParallelExecutor, 1 cards are used, so 1 programs are executed in parallel.
I0318 14:40:01.868165 14780 build_strategy.cc:365] SeqOnlyAllReduceOps:0, num_trainers:1
I0318 14:40:01.874647 14780 parallel_executor.cc:307] Inplace strategy is enabled, when build_strategy.enable_inplace = True
I0318 14:40:01.879664 14780 parallel_executor.cc:375] Garbage collection strategy is enabled, when FLAGS_eager_delete_tensor_gb = 0
2020-03-18 14:40:02,443-INFO: Test iter 0
2020-03-18 14:40:10,603-INFO: Test iter 100
2020-03-18 14:40:21,551-INFO: Test iter 200
2020-03-18 14:40:28,985-INFO: Test iter 300
2020-03-18 14:39:54,955-INFO: Test iter 400
2020-03-18 14:40:02,477-INFO: Test iter 500
2020-03-18 14:40:09,807-INFO: Test iter 600
2020-03-18 14:40:11,114-INFO: Test finish iter 619
2020-03-18 14:40:11,114-INFO: Total number of images: 4952, inference time: 534.683212877132 fps.
2020-03-18 14:40:11,115-INFO: Start evaluate...
Traceback (most recent call last):
  File "slim/sensitive/sensitive.py", line 214, in <module>
    main()
  File "slim/sensitive/sensitive.py", line 172, in main
    pruned_ratios=pruned_ratios)
  File "/usr/local/lib/python3.5/dist-packages/paddleslim/prune/sensitive.py", line 86, in sensitivity
    baseline = eval_func(graph.program)
  File "slim/sensitive/sensitive.py", line 154, in test
    dataset=dataset)
  File "/home/chenchaocun/PaddleDetection_slim/slim/sensitive/ppdet/utils/eval_utils.py", line 222, in eval_results
    map_type=map_type)
  File "/home/chenchaocun/PaddleDetection_slim/slim/sensitive/ppdet/utils/voc_eval.py", line 72, in bbox_eval
    gt_boxes = t['gt_bbox'][0]
KeyError: 'gt_bbox'
这个voc_eval.py在其他任务验证时没有出现过错误，请请教下这是啥问题导致的？


Discussion:
@slf12 能否跟进下这个问题？
请问，您用的PaddleSlim和PaddleDetection的版本分别是？
> 请问，您用的PaddleSlim和PaddleDetection的版本分别是？

paddleslim 是1.0.1最新版 paddledetection是release/0.2 
@slf12 我出现的问题帮忙看下呗
> @slf12 我出现的问题帮忙看下呗

抱歉这块应该是我同事看，assign错了
@heavengate 
@wanghaoshuang 有时间帮忙看一下哈 感谢

Resolving patch:
diff --git a/slim/sensitive/sensitive.py b/slim/sensitive/sensitive.py
--- a/slim/sensitive/sensitive.py
+++ b/slim/sensitive/sensitive.py
@@ -82,7 +82,6 @@ def main():
             feed_vars, eval_loader = model.build_inputs(**inputs_def)
             fetches = model.eval(feed_vars)
     eval_prog = eval_prog.clone(True)
-
     if FLAGS.print_params:
         print(
             "-------------------------All parameters in current graph----------------------"
@@ -104,7 +103,7 @@ def main():
     if cfg.metric == 'COCO':
         extra_keys = ['im_info', 'im_id', 'im_shape']
     if cfg.metric == 'VOC':
-        extra_keys = ['gt_box', 'gt_label', 'is_difficult']
+        extra_keys = ['gt_bbox', 'gt_class', 'is_difficult']
     if cfg.metric == 'WIDERFACE':
         extra_keys = ['im_id', 'im_shape', 'gt_box']
     eval_keys, eval_values, eval_cls = parse_fetches(fetches, eval_prog,


Test patch: