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.81k stars 2.89k forks source link

RTDETR模型导出存在BUG #8184

Open neverstoplearn opened 1 year ago

neverstoplearn commented 1 year ago

问题确认 Search before asking

Bug组件 Bug Component

Export

Bug描述 Describe the Bug

利用python tools/export_model.py -c configs/rtdetr/rtdetr_hgnetv2_l_6x_coco.yml -o weights=output/rtdetr_hgnetv2_l_6x_coco/best_model.pdparams trt=True --output_dir=output_inference导出模型。 报告: Traceback (most recent call last): File "tools/export_model.py", line 116, in main() File "tools/export_model.py", line 112, in main run(FLAGS, cfg) File "tools/export_model.py", line 79, in run trainer.export(FLAGS.output_dir) File "/home/root123/zx/PaddleDetection/ppdet/engine/trainer.py", line 1177, in export static_model, pruned_input_spec = self._get_infer_cfg_and_input_spec( File "/home/root123/zx/PaddleDetection/ppdet/engine/trainer.py", line 1137, in _get_infer_cfg_and_input_spec input_spec, static_model.forward.main_program, File "/home/root123/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 580, in main_program concrete_program = self.concrete_program File "/home/root123/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 488, in concrete_program return self.concrete_program_specify_input_spec(input_spec=None) File "/home/root123/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 527, in concrete_program_specify_input_spec concreteprogram, = self.get_concrete_program( File "/home/root123/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 436, in get_concrete_program concrete_program, partial_program_layer = self._program_cache[cache_key] File "/home/root123/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 801, in getitem self._caches[item_id] = self._build_once(item) File "/home/root123/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 785, in _build_once concrete_program = ConcreteProgram.from_func_spec( File "/home/root123/anaconda3/envs/paddle/lib/python3.8/site-packages/decorator.py", line 232, in fun return caller(func, *(extras + args), kw) File "/home/root123/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/wrapped_decorator.py", line 25, in impl return wrapped_func(*args, *kwargs) File "/home/root123/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/base.py", line 51, in impl return func(args, kwargs) File "/home/root123/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 740, in from_func_spec error_data.raise_new_exception() File "/home/root123/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/error.py", line 336, in raise_newexception six.exec("raise new_exception from None") File "", line 1, in UnboundLocalError: In transformed code:

File "/home/root123/zx/PaddleDetection/ppdet/modeling/architectures/meta_arch.py", line 76, in forward
outs.append(self.get_pred())
File "/home/root123/zx/PaddleDetection/ppdet/modeling/architectures/detr.py", line 116, in get_pred
return self._forward()
File "/home/root123/zx/PaddleDetection/ppdet/modeling/architectures/detr.py", line 83, in _forward
    # Neck
    if self.neck is not None:
        body_feats = self.neck(body_feats)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE

    # Transformer

File "/home/root123/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 930, in __call__
return self._dygraph_call_func(*inputs, **kwargs)
File "/home/root123/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 915, in _dygraph_call_func
outputs = self.forward(*inputs, **kwargs)
File "/tmp/tmpzpdjy4xc.py", line 65, in forward
num_encoder_layers > 0, true_fn_16, false_fn_16, (i, proj_feats,

UnboundLocalError: local variable 'i' referenced before assignment

复现环境 Environment

OS:Linux CUDA: 11.1 PaddlePaddle: 2.3.2 Python: 3.8.16

Bug描述确认 Bug description confirmation

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

lyuwenyu commented 1 year ago

paddle版本 >= 2.4.1

neverstoplearn commented 1 year ago

paddle版本 >= 2.4.1

已解决