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

PP-YOLO tiny 模型导出报错 #2815

Closed liuzheng081 closed 3 years ago

liuzheng081 commented 3 years ago

(paddle2.0) (base) [root@vm10-70-61-171 PaddleDetection]# python tools/export_model.py -c configs/ppyolo/ppyolo_tiny_650e_coco.yml -o weights=./output/ppyolo_tiny_650e_coco_bak/model_final [04/29 14:54:07] ppdet.utils.checkpoint INFO: Finish loading model weights: ./output/ppyolo_tiny_650e_coco_bak/model_final.pdparams loading annotations into memory... Done (t=0.11s) creating index... index created! [04/29 14:54:07] ppdet.engine INFO: Export inference config file to output_inference/ppyolo_tiny_650e_coco/infer_cfg.yml Traceback (most recent call last): File "tools/export_model.py", line 105, in main() File "tools/export_model.py", line 101, in main run(FLAGS, cfg) File "tools/export_model.py", line 69, in run trainer.export(FLAGS.output_dir) File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/ppdet/engine/trainer.py", line 460, in export input_spec, static_model.forward.main_program, File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 534, in main_program concrete_program = self.concrete_program File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 454, in concrete_program return self.concrete_program_specify_input_spec(input_spec=None) File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 488, in concrete_program_specify_input_spec desired_input_spec) File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 402, in get_concrete_program concrete_program, partial_program_layer = self._program_cache[cache_key] File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 711, in getitem self._caches[item] = self._build_once(item) File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 702, in _build_once class_instance=cache_key.class_instance) File "", line 2, in from_func_spec File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/wrapped_decorator.py", line 25, in impl return wrapped_func(args, *kwargs) File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/base.py", line 39, in impl return func(args, **kwargs) File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 658, in from_func_spec error_data.raise_new_exception() File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/error.py", line 189, in raise_newexception six.exec("raise new_exception from None") File "", line 1, in SyntaxError: In transformed code:

File "/tmp/tmp9z4ngv1f.py", line 27, in forward
    false_fn_1, (), (), (out,))
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py", line 210, in convert_ifelse
    return _run_py_ifelse(pred, true_fn, false_fn, true_args, false_args)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py", line 235, in _run_py_ifelse
    return true_fn(*true_args) if pred else false_fn(*false_args)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/ppdet/modeling/architectures/meta_arch.py", line 29, in forward (* user code *)
    out = self.get_pred()
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/ppdet/modeling/architectures/yolo.py", line 75, in get_pred (* user code *)
    bbox_pred, bbox_num = self._forward()
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/ppdet/modeling/architectures/yolo.py", line 60, in _forward (* user code *)
    body_feats = self.neck(body_feats)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/layers.py", line 891, in __call__
    outputs = self.forward(*inputs, **kwargs)
File "/tmp/tmp166krom3.py", line 73, in forward
    for_loop_body_2, [route, blocks, i, __for_loop_var_index_2])
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py", line 44, in convert_while_loop
    loop_vars = _run_py_while(cond, body, loop_vars)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py", line 58, in _run_py_while
    loop_vars = body(*loop_vars)
File "/tmp/tmp166krom3.py", line 55, in for_loop_body_2
    __for_loop_iter_var_2)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/layers.py", line 891, in __call__
    outputs = self.forward(*inputs, **kwargs)
File "/tmp/tmpdhvris78.py", line 12, in forward
    true_fn_22, false_fn_22, (inputs,), (inputs,), (inputs,))
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py", line 210, in convert_ifelse
    return _run_py_ifelse(pred, true_fn, false_fn, true_args, false_args)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py", line 235, in _run_py_ifelse
    return true_fn(*true_args) if pred else false_fn(*false_args)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/ppdet/modeling/necks/yolo_fpn.py", line 341, in forward (* user code *)
    inputs = self.drop_block(inputs)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_call_func.py", line 220, in convert_call
    forward_func = convert_to_static(forward_func)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 141, in convert_to_static
    static_func = _FUNCTION_CACHE.convert_with_cache(function)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 78, in convert_with_cache
    static_func = self._convert(func)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 116, in _convert
    root_wrapper = self._dygraph_to_static.get_static_ast(root)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/ast_transformer.py", line 61, in get_static_ast
    self.transfer_from_node_type(self.static_analysis_root)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/ast_transformer.py", line 92, in transfer_from_node_type
    self._apply(transformer, node_wrapper, log_level=index + 1)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/ast_transformer.py", line 65, in _apply
    transformer(node_wrapper).transform()
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/tensor_shape_transformer.py", line 72, in transform
    self.visit(self.root)
File "/data/anaconda3/lib/python3.6/ast.py", line 253, in visit
    return visitor(node)
File "/data/anaconda3/lib/python3.6/ast.py", line 308, in generic_visit
    value = self.visit(value)
File "/data/anaconda3/lib/python3.6/ast.py", line 253, in visit
    return visitor(node)
File "/data/anaconda3/lib/python3.6/ast.py", line 308, in generic_visit
    value = self.visit(value)
File "/data/anaconda3/lib/python3.6/ast.py", line 253, in visit
    return visitor(node)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/tensor_shape_transformer.py", line 119, in visit_If
    self.generic_visit(node)
File "/data/anaconda3/lib/python3.6/ast.py", line 308, in generic_visit
    value = self.visit(value)
File "/data/anaconda3/lib/python3.6/ast.py", line 253, in visit
    return visitor(node)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/tensor_shape_transformer.py", line 134, in visit_For
    self._transform_var_shape_if_necessary(iter)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/tensor_shape_transformer.py", line 175, in _transform_var_shape_if_necessary
    True))
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/tensor_shape_transformer.py", line 46, in create_convert_shape_node
    result_node.value, result_node.slice, in_control_flow)
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/tensor_shape_transformer.py", line 40, in create_convert_shape_node
    api_shape_node = gast.parse(convert_var_shape_func).body[0].value
File "/data/PaddleOCR-2.0/paddle2.0/lib/python3.6/site-packages/gast/gast.py", line 298, in parse
    return ast_to_gast(_ast.parse(*args, **kwargs))
File "/data/anaconda3/lib/python3.6/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 1
liuhuiCNN commented 3 years ago

(1)请问您使用的paddle版本,以及ppdet版本分别是多少呢? (2)看日志您是用的Paddle2.0版本吗?ppdet release/2.0 需要paddle 版本>= 2.0.1 版本依赖 ,建议您使用最新的Paddle版本试一下。

justiceeem commented 3 years ago

我也遇到了相同的问题...

liuhuiCNN commented 3 years ago

我也遇到了相同的问题...

Paddle 版本是2.0.1及以后吗?

justiceeem commented 3 years ago

@liuhuiCNN 是版本问题。更新后可以导出了!谢谢

liuhuiCNN commented 3 years ago

@liuzheng081 您的问题解决了吗,如果解决麻烦close一下 iusse,谢谢~

liuzheng081 commented 3 years ago

@liuzheng081 您的问题解决了吗,如果解决麻烦close一下 iusse,谢谢~

解决了 是版本问题 谢谢了