Can't call main_program when full_graph=False. Use paddle.jit.to_static(full_graph=True) instead.
zhenzi0322 opened this issue · 2 comments
zhenzi0322 commented
问题确认 Search before asking
Bug组件 Bug Component
No response
Bug描述 Describe the Bug
使用导出模型发生异常:
python tools/export_model.py -c configs/yolov3/yolov3_mobilenet_v1_roadsign.yml --output_dir=inference_model -o weights=https://paddledet.bj.bcebos.com/models/yolov3_mobilenet_v1_270e_coco.pdparams
异常如下:
Traceback (most recent call last):
File "E:\python\test\PaddleDetection\tools\export_model.py", line 118, in <module>
main()
File "E:\python\test\PaddleDetection\tools\export_model.py", line 114, in main
run(FLAGS, cfg)
File "E:\python\test\PaddleDetection\tools\export_model.py", line 80, in run
trainer.export(FLAGS.output_dir, for_fd=FLAGS.for_fd)
File "E:\python\test\PaddleDetection\ppdet\engine\trainer.py", line 1229, in export
static_model, pruned_input_spec = self._get_infer_cfg_and_input_spec(
File "E:\python\test\PaddleDetection\ppdet\engine\trainer.py", line 1181, in _get_infer_cfg_and_input_spec
input_spec, static_model.forward.main_program,
File "D:\python\Envs\test-2Ti2Q\lib\site-packages\paddle\jit\dy2static\program_translator.py", line 768, in main_program
raise_error_template("main_program")()
File "D:\python\Envs\test-2Ti2Q\lib\site-packages\paddle\jit\dy2static\program_translator.py", line 704, in _raise_error
raise RuntimeError(error_template.format(func=func_str))
RuntimeError: Can't call main_program when full_graph=False. Use paddle.jit.to_static(full_graph=True) instead.
复现环境 Environment
拉取分支release/2.7
代码。然后按下面的步骤进行即可复现异常。
python tools/train.py -c configs/yolov3/yolov3_mobilenet_v1_roadsign.yml --eval -o use_gpu=true
python tools/export_model.py -c configs/yolov3/yolov3_mobilenet_v1_roadsign.yml --output_dir=inference_model -o weights=https://paddledet.bj.bcebos.com/models/yolov3_mobilenet_v1_270e_coco.pdparams
Bug描述确认 Bug description confirmation
- 我确认已经提供了Bug复现步骤、代码改动说明、以及环境信息,确认问题是可以复现的。I confirm that the bug replication steps, code change instructions, and environment information have been provided, and the problem can be reproduced.
是否愿意提交PR? Are you willing to submit a PR?
- 我愿意提交PR!I'd like to help by submitting a PR!
zhiboniu commented
可能版本有更新,加上full_graph=True这个参数试一下呢
Dat0901 commented
In ppdet/engine/trainer.py
find
if prune_input:
static_model = paddle.jit.to_static(
self.model, input_spec=input_spec)
change to
if prune_input:
static_model = paddle.jit.to_static(
self.model, input_spec=input_spec, full_graph=True)