PaddleDetection icon indicating copy to clipboard operation
PaddleDetection copied to clipboard

转换模型报错,AttributeError: module 'paddle.vision.ops' has no attribute 'generate_proposals'

Open monkeycc opened this issue 2 years ago • 1 comments

问题确认 Search before asking

  • [X] 我已经搜索过问题,但是没有找到解答。I have searched the question and found no related answer.

请提出你的问题 Please ask your question

Python 3.8.13 paddledet 2.5.0 paddlepaddle-gpu 2.2.2.post112

(PaddleDetection) PS I:\Paddle\PaddleDetection> python tools/export_model.py -c configs\mask_rcnn\mask_rcnn_r50_vd_fpn_2x_coco.yml  --output_dir=I:\Paddle\PaddleDetection\output\01_XIA  -o weights=I:\Paddle\PaddleDetection\output\01_XIA_mask_rcnn_r50_vd_fpn_2x_coco\19.pdparams

D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\vision\transforms\functional_pil.py:36: DeprecationWarning: NEAREST is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.NEAREST or Dither.NONE instead.
  'nearest': Image.NEAREST,
D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\vision\transforms\functional_pil.py:37: DeprecationWarning: BILINEAR is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BILINEAR instead.
  'bilinear': Image.BILINEAR,
D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\vision\transforms\functional_pil.py:38: DeprecationWarning: BICUBIC is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BICUBIC instead.
  'bicubic': Image.BICUBIC,
D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\vision\transforms\functional_pil.py:39: DeprecationWarning: BOX is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BOX instead.
  'box': Image.BOX,
D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\vision\transforms\functional_pil.py:40: DeprecationWarning: LANCZOS is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.LANCZOS instead.
  'lanczos': Image.LANCZOS,
D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\vision\transforms\functional_pil.py:41: DeprecationWarning: HAMMING is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.HAMMING instead.
  'hamming': Image.HAMMING
Warning: Unable to use JDE/FairMOT/ByteTrack, please install lap, for example: `pip install lap`, see https://github.com/gatagat/lap
[09/21 19:30:43] ppdet.utils.checkpoint INFO: Finish loading model weights: I:\Paddle\PaddleDetection\output\01_XIA_mask_rcnn_r50_vd_fpn_2x_coco\19.pdparams
loading annotations into memory...
Done (t=0.09s)
creating index...
index created!
[09/21 19:30:44] ppdet.engine INFO: Export inference config file to I:\Paddle\PaddleDetection\output\01_XIA\mask_rcnn_r50_vd_fpn_2x_coco\infer_cfg.yml
Traceback (most recent call last):
  File "tools/export_model.py", line 108, in <module>
    main()
  File "tools/export_model.py", line 104, in main
    run(FLAGS, cfg)
  File "tools/export_model.py", line 73, in run
    trainer.export(FLAGS.output_dir)
  File "I:\Paddle\PaddleDetection\ppdet\engine\trainer.py", line 1059, in export
    static_model, pruned_input_spec = self._get_infer_cfg_and_input_spec(
  File "I:\Paddle\PaddleDetection\ppdet\engine\trainer.py", line 1019, in _get_infer_cfg_and_input_spec
    input_spec, static_model.forward.main_program,
  File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 563, in main_program
    concrete_program = self.concrete_program
  File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 479, in concrete_program
    return self.concrete_program_specify_input_spec(input_spec=None)
  File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 516, in concrete_program_specify_input_spec
    concrete_program, _ = self.get_concrete_program(
  File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 427, in get_concrete_program
    concrete_program, partial_program_layer = self._program_cache[cache_key]
  File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 723, in __getitem__
    self._caches[item] = self._build_once(item)
  File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 709, in _build_once
    concrete_program = ConcreteProgram.from_func_spec(
  File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
  File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\wrapped_decorator.py", line 25, in __impl__
    return wrapped_func(*args, **kwargs)
  File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\base.py", line 51, in __impl__
    return func(*args, **kwargs)
  File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 668, in from_func_spec
    error_data.raise_new_exception()
  File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\error.py", line 336, in raise_new_exception
    six.exec_("raise new_exception from None")
  File "<string>", line 1, in <module>
AttributeError: In transformed code:

    File "I:\Paddle\PaddleDetection\ppdet\modeling\architectures\meta_arch.py", line 74, in forward
        self.inputs = inp
    File "I:\Paddle\PaddleDetection\ppdet\modeling\architectures\mask_rcnn.py", line 133, in get_pred
        bbox_pred, bbox_num, mask_pred = self._forward()
    File "I:\Paddle\PaddleDetection\ppdet\modeling\architectures\mask_rcnn.py", line 102, in _forward
        else:
    File "I:\Paddle\PaddleDetection\ppdet\modeling\proposal_generator\rpn_head.py", line 141, in forward
        rois, rois_num = self._gen_proposal(scores, deltas, anchors, inputs)
    File "I:\Paddle\PaddleDetection\ppdet\modeling\proposal_generator\rpn_head.py", line 197, in _gen_proposal
        batch_size = paddle.slice(paddle.shape(im_shape), [0], [0], [1])

        # Generate proposals for each level and each batch.
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
        # Discard batch-computing to avoid sorting bbox cross different batches.
        for i in range(batch_size):

    File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\convert_call_func.py", line 258, in convert_call
        converted_call = convert_to_static(call_func)
    File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 140, in convert_to_static
        static_func = _FUNCTION_CACHE.convert_with_cache(function)
    File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 77, in convert_with_cache
        static_func = self._convert(func)
    File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 115, in _convert
        root_wrapper = self._dygraph_to_static.get_static_ast(root)
    File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\ast_transformer.py", line 58, in get_static_ast
        self.static_analysis_visitor = StaticAnalysisVisitor(root)
    File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\static_analysis.py", line 207, in __init__
        self.run(ast_root)
    File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\static_analysis.py", line 215, in run
        self.dfs_visit(ast_root)
    File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\static_analysis.py", line 241, in dfs_visit
        func_type = self.dfs_visit(child)
    File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\static_analysis.py", line 244, in dfs_visit
        self.dfs_visit(child)
    File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\static_analysis.py", line 244, in dfs_visit
        self.dfs_visit(child)
    File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\static_analysis.py", line 244, in dfs_visit
        self.dfs_visit(child)
    File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\static_analysis.py", line 247, in dfs_visit
        cur_wrapper.node_var_type = self._get_node_var_type(cur_wrapper)
    File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\static_analysis.py", line 359, in _get_node_var_type
        if is_dygraph_api(node):
    File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\utils.py", line 201, in is_dygraph_api
        if is_api_in_module(node, DYGRAPH_TO_STATIC_MODULE_PREFIX):
    File "D:\anaconda308\envs\PaddleDetection\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\utils.py", line 192, in is_api_in_module
        return eval("_is_api_in_module_helper({}, '{}')".format(func_str,
    File "<string>", line 1, in <module>


    AttributeError: module 'paddle.vision.ops' has no attribute 'generate_proposals'

monkeycc avatar Sep 21 '22 11:09 monkeycc

试试paddledet 2.4.0,或把PaddleDetection代码切换到release/2.4 分支

nemonameless avatar Sep 22 '22 07:09 nemonameless

paddlepaddle-gpu==2.3.2.post116 训练报错

[Hint: 'cudaErrorIllegalAddress'. The device encountered a load or store instruction on an invalid memory address. This leaves the process in an inconsistentstate and any further CUDA work will return the same error. To continue using CUDA, the process must be terminated and relaunched. ] (at ..\paddle\phi\backends\gpu\cuda\cuda_info.cc:258)

所以要切换到 paddlepaddle-gpu==2.2.2.post112

但是paddlepaddle-gpu==2.2.2.post112 又不能用2.5 AttributeError: module 'paddle.vision.ops' has no attribute 'generate_proposals' 转换模型又会报错

要用2.4

....

确实不容易啊

monkeycc avatar Nov 16 '22 07:11 monkeycc

win下请安装最新develop版本的paddle。 https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/develop/install/pip/windows-pip.html 建议换linux去跑代码吧。。

nemonameless avatar Nov 16 '22 09:11 nemonameless

paddlepaddle-gpu==2.3.2.post116 训练报错

[Hint: 'cudaErrorIllegalAddress'. The device encountered a load or store instruction on an invalid memory address. This leaves the process in an inconsistentstate and any further CUDA work will return the same error. To continue using CUDA, the process must be terminated and relaunched. ] (at ..\paddle\phi\backends\gpu\cuda\cuda_info.cc:258)

所以要切换到 paddlepaddle-gpu==2.2.2.post112

但是paddlepaddle-gpu==2.2.2.post112 又不能用2.5 AttributeError: module 'paddle.vision.ops' has no attribute 'generate_proposals' 转换模型又会报错

要用2.4

....

确实不容易啊

请问,换成ppdet2.4就好了吗?还是用paddel2.2.2?

cunjing56 avatar Dec 29 '22 09:12 cunjing56

#6940

https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/INSTALL.md 请先尝试按照这个版本说明去安装环境。 自测cascade rcnn训练测试导出均ok:PaddleDetection 2.5,paddle 2.3.2,linux。 此外develop分支的PaddleDetection + develop版本的paddle每天都是有CI流程监测的肯定是没问题的。可以参考下。

win下请安装最新develop版本的paddle。 https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/develop/install/pip/windows-pip.html

nemonameless avatar Dec 29 '22 15:12 nemonameless

#6940

https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/INSTALL.md 请先尝试按照这个版本说明去安装环境。 自测cascade rcnn训练测试导出均ok:PaddleDetection 2.5,paddle 2.3.2,linux。 此外develop分支的PaddleDetection + develop版本的paddle每天都是有CI流程监测的肯定是没问题的。可以参考下。

win下请安装最新develop版本的paddle。 https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/develop/install/pip/windows-pip.html

我在AIStudio平台上跑的,PaddleDetection 2.5,paddle 2.3.2,和你的一样。但就是报错 faster_rcnn_swin_tiny_fpn_3x_coco

YanTianlong-01 avatar May 22 '23 11:05 YanTianlong-01