From 283b2581a53a60aa073864e950f1317e53d2e8bc Mon Sep 17 00:00:00 2001 From: wangguanzhong Date: Thu, 25 Jul 2019 10:13:31 +0800 Subject: [PATCH] fix bug in py3 infer (#2913) --- tools/infer.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tools/infer.py b/tools/infer.py index 09e440e3e..902c8c555 100644 --- a/tools/infer.py +++ b/tools/infer.py @@ -109,17 +109,19 @@ def save_infer_model(FLAGS, exe, feed_vars, test_fetches, infer_prog): cfg_name = os.path.basename(FLAGS.config).split('.')[0] save_dir = os.path.join(FLAGS.output_dir, cfg_name) feeded_var_names = [var.name for var in feed_vars.values()] - target_vars = test_fetches.values() - feeded_var_names = prune_feed_vars(feeded_var_names, target_vars, infer_prog) + target_vars = list(test_fetches.values()) + feeded_var_names = prune_feed_vars(feeded_var_names, target_vars, + infer_prog) logger.info("Save inference model to {}, input: {}, output: " "{}...".format(save_dir, feeded_var_names, - [var.name for var in target_vars])) - fluid.io.save_inference_model(save_dir, - feeded_var_names=feeded_var_names, - target_vars=target_vars, - executor=exe, - main_program=infer_prog, - params_filename="__params__") + [var.name for var in target_vars])) + fluid.io.save_inference_model( + save_dir, + feeded_var_names=feeded_var_names, + target_vars=target_vars, + executor=exe, + main_program=infer_prog, + params_filename="__params__") def main(): -- GitLab