PaddleVideo icon indicating copy to clipboard operation
PaddleVideo copied to clipboard

PPTSM模型无法导出

Open thunder95 opened this issue 4 years ago • 3 comments

模型已训练好,但是导出时出现以下错误信息:

使用导出命令: python tools/export_model.py -c ./configs/recognition/tsm/pptsm_rotate.yaml -p ./output/ppTSM/ppTSM_best.pdparams -o ./inference

Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations def convert_to_list(value, n, name, dtype=np.int): Building model(ppTSM)... W0317 09:32:40.905170 6888 device_context.cc:362] Please NOTE: device: 0, GPU Compute Capability: 7.5, Driver API Version: 11.2, Runtime API Version: 10.2 W0317 09:32:40.907907 6888 device_context.cc:372] device: 0, cuDNN Version: 7.6. Loading params from (./output/ppTSM/ppTSM_best.pdparams)... /home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/layers/utils.py:77: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working return (isinstance(seq, collections.Sequence) and Traceback (most recent call last): File "tools/export_model.py", line 106, in main() File "tools/export_model.py", line 100, in main paddle.jit.save(model, osp.join(args.output_path, model_name)) File "", line 2, in save File "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/wrapped_decorator.py", line 25, in impl return wrapped_func(*args, **kwargs) File "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/base.py", line 39, in impl return func(*args, **kwargs) File "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/jit.py", line 681, in save inner_input_spec) File "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 488, in concrete_program_specify_input_spec *desired_input_spec) File "/home/server/anaconda3/envs/paddle/lib/python3.7/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 "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 711, in getitem self._caches[item] = self._build_once(item) File "/home/server/anaconda3/envs/paddle/lib/python3.7/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 "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/wrapped_decorator.py", line 25, in impl return wrapped_func(*args, **kwargs) File "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/base.py", line 39, in impl return func(*args, **kwargs) File "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 658, in from_func_spec error_data.raise_new_exception() File "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/error.py", line 189, in raise_new_exception six.exec("raise new_exception from None") File "", line 1, in AttributeError: In transformed code:

File "/tmp/tmpm50wa5u_.py", line 24, in forward
true_fn_0, false_fn_0, (imgs,), (imgs,), (feature,))
File "/home/server/anaconda3/envs/paddle/lib/python3.7/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 "/home/server/anaconda3/envs/paddle/lib/python3.7/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 "/d/hulei/PaddleVideo/paddlevideo/modeling/framework/recognizers/base.py", line 66, in forward (* user code *)
feature = self.extract_feature(imgs)
File "/d/hulei/PaddleVideo/paddlevideo/modeling/framework/recognizers/base.py", line 55, in extract_feature (* user code *)
feature = self.backbone(imgs)
File "/home/server/anaconda3/envs/paddle/lib/python3.7/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 "/home/server/anaconda3/envs/paddle/lib/python3.7/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 "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 78, in convert_with_cache
static_func = self._convert(func)
File "/home/server/anaconda3/envs/paddle/lib/python3.7/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 "/home/server/anaconda3/envs/paddle/lib/python3.7/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 "/home/server/anaconda3/envs/paddle/lib/python3.7/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 "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/ast_transformer.py", line 65, in _apply
transformer(node_wrapper).transform()
File "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/loop_transformer.py", line 435, in transform
self.visit(self.root)
File "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/loop_transformer.py", line 438, in visit
self.generic_visit(node)
File "/home/server/anaconda3/envs/paddle/lib/python3.7/ast.py", line 326, in generic_visit
value = self.visit(value)
File "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/loop_transformer.py", line 441, in visit
self.replace_stmt_list(node.body)
File "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/loop_transformer.py", line 457, in replace_stmt_list
new_stmts = self.get_for_stmt_nodes(body_list[i])
File "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/loop_transformer.py", line 479, in get_for_stmt_nodes
stmts_tuple = current_for_node_parser.parse()
File "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/utils.py", line 1030, in parse
return self._parse_for_stmts()
File "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/utils.py", line 1094, in _parse_for_stmts
target_node, assign_node = self._build_assign_var_slice_node()
File "/home/server/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/utils.py", line 1245, in _build_assign_var_slice_node
slice=gast.Index(value=gast.Name(
AttributeError: module 'gast' has no attribute 'Index'

thunder95 avatar Mar 17 '21 01:03 thunder95

可以试试pip install gast==0.3.3

wgh1989 avatar Mar 24 '21 05:03 wgh1989

更新了inference部分代码,pr: #138 您可以重新尝试导出模型

huangjun12 avatar May 14 '21 08:05 huangjun12

可以试试pip install gast==0.3.3

这个是正解

ShawnZhang31 avatar Jul 24 '21 14:07 ShawnZhang31