提交 a3dee6a4 编写于 作者: Y yukavio

remove env flags

上级 b8bf9b2c
...@@ -23,20 +23,6 @@ sys.path.append(__dir__) ...@@ -23,20 +23,6 @@ sys.path.append(__dir__)
sys.path.append(os.path.join(__dir__, '..', '..', '..')) sys.path.append(os.path.join(__dir__, '..', '..', '..'))
sys.path.append(os.path.join(__dir__, '..', '..', '..', 'tools')) 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 import program
from paddle import fluid from paddle import fluid
from ppocr.utils.utility import initial_logger from ppocr.utils.utility import initial_logger
......
...@@ -24,20 +24,6 @@ sys.path.append(__dir__) ...@@ -24,20 +24,6 @@ sys.path.append(__dir__)
sys.path.append(os.path.join(__dir__, '..', '..', '..')) sys.path.append(os.path.join(__dir__, '..', '..', '..'))
sys.path.append(os.path.join(__dir__, '..', '..', '..', 'tools')) 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 import tools.program as program
from paddle import fluid from paddle import fluid
from ppocr.utils.utility import initial_logger from ppocr.utils.utility import initial_logger
......
...@@ -23,20 +23,6 @@ sys.path.append(__dir__) ...@@ -23,20 +23,6 @@ sys.path.append(__dir__)
sys.path.append(os.path.join(__dir__, '..', '..', '..')) sys.path.append(os.path.join(__dir__, '..', '..', '..'))
sys.path.append(os.path.join(__dir__, '..', '..', '..', 'tools')) 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 json
import cv2 import cv2
from paddle import fluid from paddle import fluid
......
...@@ -33,7 +33,6 @@ from eval_utils.eval_rec_utils import eval_rec_run ...@@ -33,7 +33,6 @@ from eval_utils.eval_rec_utils import eval_rec_run
from ppocr.utils.save_load import save_model from ppocr.utils.save_load import save_model
import numpy as np import numpy as np
from ppocr.utils.character import cal_predicts_accuracy, cal_predicts_accuracy_srn, CharacterOps from ppocr.utils.character import cal_predicts_accuracy, cal_predicts_accuracy_srn, CharacterOps
import paddleslim as slim
class ArgsParser(ArgumentParser): class ArgsParser(ArgumentParser):
...@@ -300,6 +299,7 @@ def train_eval_det_run(config, ...@@ -300,6 +299,7 @@ def train_eval_det_run(config,
best_epoch = epoch best_epoch = epoch
save_path = save_model_dir + "/best_accuracy" save_path = save_model_dir + "/best_accuracy"
if is_pruning: if is_pruning:
import paddleslim as slim
slim.prune.save_model( slim.prune.save_model(
exe, train_info_dict['train_program'], exe, train_info_dict['train_program'],
save_path) save_path)
...@@ -317,6 +317,7 @@ def train_eval_det_run(config, ...@@ -317,6 +317,7 @@ def train_eval_det_run(config,
if epoch == 0 and save_epoch_step == 1: if epoch == 0 and save_epoch_step == 1:
save_path = save_model_dir + "/iter_epoch_0" save_path = save_model_dir + "/iter_epoch_0"
if is_pruning: if is_pruning:
import paddleslim as slim
slim.prune.save_model(exe, train_info_dict['train_program'], slim.prune.save_model(exe, train_info_dict['train_program'],
save_path) save_path)
else: else:
...@@ -324,6 +325,7 @@ def train_eval_det_run(config, ...@@ -324,6 +325,7 @@ def train_eval_det_run(config,
if epoch > 0 and epoch % save_epoch_step == 0: if epoch > 0 and epoch % save_epoch_step == 0:
save_path = save_model_dir + "/iter_epoch_%d" % (epoch) save_path = save_model_dir + "/iter_epoch_%d" % (epoch)
if is_pruning: if is_pruning:
import paddleslim as slim
slim.prune.save_model(exe, train_info_dict['train_program'], slim.prune.save_model(exe, train_info_dict['train_program'],
save_path) save_path)
else: else:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册