From 72ebbf2de1cfb94d97aee53359f2db0146988b72 Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Fri, 15 May 2020 16:51:45 +0800 Subject: [PATCH] sorted outputs when export model --- tools/infer/predict_det.py | 17 +++++------------ tools/infer/predict_rec.py | 1 - tools/program.py | 4 ++-- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/tools/infer/predict_det.py b/tools/infer/predict_det.py index dd1fbaa5..cbed5a4a 100755 --- a/tools/infer/predict_det.py +++ b/tools/infer/predict_det.py @@ -142,8 +142,8 @@ class TextDetector(object): outputs.append(output) outs_dict = {} if self.det_algorithm == "EAST": - outs_dict['f_score'] = outputs[0] - outs_dict['f_geo'] = outputs[1] + outs_dict['f_geo'] = outputs[0] + outs_dict['f_score'] = outputs[1] else: outs_dict['maps'] = outputs[0] dt_boxes_list = self.postprocess_op(outs_dict, [ratio_list]) @@ -169,14 +169,7 @@ if __name__ == "__main__": total_time += elapse count += 1 print("Predict time of %s:" % image_file, elapse) - img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) - draw_img = draw_ocr(img, dt_boxes, None, None, False) - draw_img_save = "./inference_results/" - if not os.path.exists(draw_img_save): - os.makedirs(draw_img_save) - cv2.imwrite( - os.path.join(draw_img_save, os.path.basename(image_file)), - draw_img[:, :, ::-1]) - print("The visualized image saved in {}".format( - os.path.join(draw_img_save, os.path.basename(image_file)))) + """ + add visualized code + """ print("Avg Time:", total_time / (count - 1)) diff --git a/tools/infer/predict_rec.py b/tools/infer/predict_rec.py index caab4eac..0681cfb5 100755 --- a/tools/infer/predict_rec.py +++ b/tools/infer/predict_rec.py @@ -114,7 +114,6 @@ if __name__ == "__main__": valid_image_file_list.append(image_file) img_list.append(img) rec_res, predict_time = text_recognizer(img_list) - rec_res, predict_time = text_recognizer(img_list) for ino in range(len(img_list)): print("Predicts of %s:%s" % (valid_image_file_list[ino], rec_res[ino])) print("Total predict time for %d images:%.3f" % diff --git a/tools/program.py b/tools/program.py index 6c9e9904..b6318c3b 100755 --- a/tools/program.py +++ b/tools/program.py @@ -191,8 +191,8 @@ def build_export(config, main_prog, startup_prog): func_infor = config['Architecture']['function'] model = create_module(func_infor)(params=config) image, outputs = model(mode='export') - fetches_var = [outputs[name] for name in outputs] - fetches_var_name = [name for name in outputs] + fetches_var = sorted([outputs[name] for name in outputs]) + fetches_var_name = [name for name in fetches_var] feeded_var_names = [image.name] target_vars = fetches_var return feeded_var_names, target_vars, fetches_var_name -- GitLab