From a3dee6a4b17f1e321d3951195cc1e70d0521f115 Mon Sep 17 00:00:00 2001 From: yukavio Date: Wed, 16 Sep 2020 11:48:51 +0000 Subject: [PATCH] remove env flags --- deploy/slim/prune/export_prune_model.py | 14 -------------- deploy/slim/prune/pruning_and_finetune.py | 14 -------------- deploy/slim/prune/sensitivity_anal.py | 14 -------------- tools/program.py | 4 +++- 4 files changed, 3 insertions(+), 43 deletions(-) diff --git a/deploy/slim/prune/export_prune_model.py b/deploy/slim/prune/export_prune_model.py index b3ca4abc..0603966f 100644 --- a/deploy/slim/prune/export_prune_model.py +++ b/deploy/slim/prune/export_prune_model.py @@ -23,20 +23,6 @@ sys.path.append(__dir__) sys.path.append(os.path.join(__dir__, '..', '..', '..')) sys.path.append(os.path.join(__dir__, '..', '..', '..', 'tools')) - -def set_paddle_flags(**kwargs): - for key, value in kwargs.items(): - if os.environ.get(key, None) is None: - os.environ[key] = str(value) - - -# NOTE(paddle-dev): All of these flags should be -# set before `import paddle`. Otherwise, it would -# not take any effect. -set_paddle_flags( - FLAGS_eager_delete_tensor_gb=0, # enable GC to save memory -) - import program from paddle import fluid from ppocr.utils.utility import initial_logger diff --git a/deploy/slim/prune/pruning_and_finetune.py b/deploy/slim/prune/pruning_and_finetune.py index d0b65724..0a03cb44 100644 --- a/deploy/slim/prune/pruning_and_finetune.py +++ b/deploy/slim/prune/pruning_and_finetune.py @@ -24,20 +24,6 @@ sys.path.append(__dir__) sys.path.append(os.path.join(__dir__, '..', '..', '..')) sys.path.append(os.path.join(__dir__, '..', '..', '..', 'tools')) - -def set_paddle_flags(**kwargs): - for key, value in kwargs.items(): - if os.environ.get(key, None) is None: - os.environ[key] = str(value) - - -# NOTE(paddle-dev): All of these flags should be -# set before `import paddle`. Otherwise, it would -# not take any effect. -set_paddle_flags( - FLAGS_eager_delete_tensor_gb=0, # enable GC to save memory -) - import tools.program as program from paddle import fluid from ppocr.utils.utility import initial_logger diff --git a/deploy/slim/prune/sensitivity_anal.py b/deploy/slim/prune/sensitivity_anal.py index 4a55e066..b416f09a 100644 --- a/deploy/slim/prune/sensitivity_anal.py +++ b/deploy/slim/prune/sensitivity_anal.py @@ -23,20 +23,6 @@ sys.path.append(__dir__) sys.path.append(os.path.join(__dir__, '..', '..', '..')) sys.path.append(os.path.join(__dir__, '..', '..', '..', 'tools')) - -def set_paddle_flags(**kwargs): - for key, value in kwargs.items(): - if os.environ.get(key, None) is None: - os.environ[key] = str(value) - - -# NOTE(paddle-dev): All of these flags should be -# set before `import paddle`. Otherwise, it would -# not take any effect. -set_paddle_flags( - FLAGS_eager_delete_tensor_gb=0, # enable GC to save memory -) - import json import cv2 from paddle import fluid diff --git a/tools/program.py b/tools/program.py index 7c017733..62192431 100755 --- a/tools/program.py +++ b/tools/program.py @@ -33,7 +33,6 @@ from eval_utils.eval_rec_utils import eval_rec_run from ppocr.utils.save_load import save_model import numpy as np from ppocr.utils.character import cal_predicts_accuracy, cal_predicts_accuracy_srn, CharacterOps -import paddleslim as slim class ArgsParser(ArgumentParser): @@ -300,6 +299,7 @@ def train_eval_det_run(config, best_epoch = epoch save_path = save_model_dir + "/best_accuracy" if is_pruning: + import paddleslim as slim slim.prune.save_model( exe, train_info_dict['train_program'], save_path) @@ -317,6 +317,7 @@ def train_eval_det_run(config, if epoch == 0 and save_epoch_step == 1: save_path = save_model_dir + "/iter_epoch_0" if is_pruning: + import paddleslim as slim slim.prune.save_model(exe, train_info_dict['train_program'], save_path) else: @@ -324,6 +325,7 @@ def train_eval_det_run(config, if epoch > 0 and epoch % save_epoch_step == 0: save_path = save_model_dir + "/iter_epoch_%d" % (epoch) if is_pruning: + import paddleslim as slim slim.prune.save_model(exe, train_info_dict['train_program'], save_path) else: -- GitLab