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.85k stars 2.9k forks source link

RT-DETR ONNX Conversion #8157

Open Simardeep27 opened 1 year ago

Simardeep27 commented 1 year ago

问题确认 Search before asking

Bug组件 Bug Component

Export

Bug描述 Describe the Bug

Error while exporting RT-DETR using export_model.py:

Warning: Unable to use numba in PP-Tracking, please install numba, for example(python3.7): pip install numba==0.56.4 Warning: Unable to use numba in PP-Tracking, please install numba, for example(python3.7): pip install numba==0.56.4 W0426 23:04:56.929657 2076642 dynamic_loader.cc:305] The third-party dynamic library (libcudnn.so) that Paddle depends on is not configured correctly. (error code is /usr/local/cuda/lib64/libcudnn.so: cannot open shared object file: No such file or directory) Suggestions:

  1. Check if the third-party dynamic library (e.g. CUDA, CUDNN) is installed correctly and its version is matched with paddlepaddle you installed.
  2. Configure third-party dynamic library environment variables as follows:

    • Linux: set LD_LIBRARY_PATH by export LD_LIBRARY_PATH=...
    • Windows: set PATH by `set PATH=XXX; [04/26 23:04:58] ppdet.utils.checkpoint INFO: Finish loading model weights: /home/simardeep/scratch/Paddle/PaddleDetection/ckpt/rtdetr_r50vd_6x_coco.pdparams [04/26 23:04:58] ppdet.data.source.category WARNING: anno_file 'dataset/coco/annotations/instances_val2017.json' is None or not set or not exist, please recheck TrainDataset/EvalDataset/TestDataset.anno_path, otherwise the default categories will be used by metric_type. [04/26 23:04:58] ppdet.data.source.category WARNING: metric_type: COCO, load default categories of COCO. [04/26 23:04:58] ppdet.engine INFO: Export inference config file to output_inference/rtdetr_r50vd_6x_coco/infer_cfg.yml Traceback (most recent call last): File "tools/export_model.py", line 117, in main() File "tools/export_model.py", line 113, in main run(FLAGS, cfg) File "tools/export_model.py", line 80, in run trainer.export(FLAGS.output_dir) File "/DATA/scratch/simardeep/Paddle/PaddleDetection/ppdet/engine/trainer.py", line 1189, in export static_model, pruned_input_spec = self._get_infer_cfg_and_input_spec( File "/DATA/scratch/simardeep/Paddle/PaddleDetection/ppdet/engine/trainer.py", line 1144, in _get_infer_cfg_and_input_spec print(static_model.forward.main_program) File "/home/simardeep/scratch/miniconda3/envs/Paddleenv/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/simardeep/scratch/miniconda3/envs/Paddleenv/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/simardeep/scratch/miniconda3/envs/Paddleenv/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/simardeep/scratch/miniconda3/envs/Paddleenv/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/simardeep/scratch/miniconda3/envs/Paddleenv/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/simardeep/scratch/miniconda3/envs/Paddleenv/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/simardeep/scratch/miniconda3/envs/Paddleenv/lib/python3.8/site-packages/decorator.py", line 232, in fun return caller(func, *(extras + args), kw) File "/home/simardeep/scratch/miniconda3/envs/Paddleenv/lib/python3.8/site-packages/paddle/fluid/wrapped_decorator.py", line 25, in impl return wrapped_func(*args, *kwargs) File "/home/simardeep/scratch/miniconda3/envs/Paddleenv/lib/python3.8/site-packages/paddle/fluid/dygraph/base.py", line 51, in impl return func(args, kwargs) File "/home/simardeep/scratch/miniconda3/envs/Paddleenv/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/simardeep/scratch/miniconda3/envs/Paddleenv/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 /Paddle/PaddleDetection/ppdet/modeling/architectures/meta_arch.py", line 76, in forward outs.append(self.get_pred()) File "/Paddle/PaddleDetection/ppdet/modeling/architectures/detr.py", line 116, in get_pred return self._forward() File "/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 "/envs/Paddleenv/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 930, in call return self._dygraph_call_func(*inputs, *kwargs) File "/envs/Paddleenv/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 915, in _dygraph_call_func outputs = self.forward(inputs, **kwargs) File "/tmp/tmpba1nmme5.py", line 65, in forward num_encoder_layers > 0, true_fn_17, false_fn_17, (i, proj_feats,

    UnboundLocalError: local variable 'i' referenced before assignment.

Command for this output: python tools/export_model.py -c configs/rtdetr/rtdetr_r50vd_6x_coco.yml -o weights=Paddle/PaddleDetection/ckpt/rtdetr_r50vd_6x_coco.pdparams trt=True --output_dir=output_inference

Any method to solve this error?

lyuwenyu commented 1 year ago
image
tim120526 commented 1 year ago
image

请问你解决了吗

whale1008 commented 1 year ago

更新paddlepaddle-gpu到2.42即可