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.68k stars 2.87k forks source link

pp-picodet 主体检测导出模型后 执行python deploy/python/infer.py 遇到问题 ValueError: cannot reshape array of size 1 into shape (4) #6208

Open yuanjim opened 2 years ago

yuanjim commented 2 years ago

问题确认 Search before asking

bug描述 Describe the Bug

aistudio中使用pp-picodet训练了自己的数据,主体检测导出模型:

python tools/export_model.py -c configs/picodet/picodet_lcnet_x2_5_640_mainbody_patrol_develop.yml --output_dir=./inference_model -o weights=output/picodet_lcnet_x2_5_640_mainbody_patrol_2.4/best_model.pdparams

导出后执行推理预测:

python deploy/python/infer.py --model_dir=./inference_model/picodet_lcnet_x2_5_640_mainbody_patrol_develop --image_file=./coco/val/01.mp4#t=2.933333.jpg --device=GPU

结果出错:

-----------  Running Arguments -----------
action_file: None
batch_size: 1
camera_id: -1
cpu_threads: 1
device: GPU
enable_mkldnn: False
enable_mkldnn_bfloat16: False
image_dir: None
image_file: ./coco/val/01.mp4#t=2.933333.jpg
model_dir: ./inference_model/picodet_lcnet_x2_5_640_mainbody_patrol_develop
output_dir: output
random_pad: False
reid_batch_size: 50
reid_model_dir: None
run_benchmark: False
run_mode: paddle
save_images: False
save_mot_txt_per_img: False
save_mot_txts: False
save_results: False
scaled: False
threshold: 0.5
tracker_config: None
trt_calib_mode: False
trt_max_shape: 1280
trt_min_shape: 1
trt_opt_shape: 640
use_dark: True
use_gpu: False
video_file: None
window_size: 50
------------------------------------------
-----------  Model Configuration -----------
Model Arch: PicoDet
Transform Order: 
--transform op: Resize
--transform op: NormalizeImage
--transform op: Permute
--transform op: PadStride
--------------------------------------------
Traceback (most recent call last):
  File "deploy/python/infer.py", line 918, in <module>
    main()
  File "deploy/python/infer.py", line 891, in main
    img_list, FLAGS.run_benchmark, repeats=100, save_file=save_file)
  File "deploy/python/infer.py", line 286, in predict_image
    result = self.postprocess(inputs, result)
  File "deploy/python/infer.py", line 550, in postprocess
    np_boxes, np_boxes_num = postprocessor(np_score_list, np_boxes_list)
  File "/home/aistudio/work/PaddleDetection-develop/deploy/python/picodet_postprocess.py", line 160, in __call__
    box_distance = np.sum(box_distance, axis=1).reshape((-1, 4))
ValueError: cannot reshape array of size 1 into shape (4)

复现环境 Environment

No response

是否愿意提交PR Are you willing to submit a PR?

heavengate commented 2 years ago

是否是导出模型的时候权重没有加载对,看着像图片里没有检测出来bbox,导致shape不匹配

yuanjim commented 2 years ago

我已收到您的邮件。谢谢!