未验证 提交 06b943f9 编写于 作者: X xiaoting 提交者: GitHub

Merge pull request #420 from BeyondYourself/develop

Common modules do not need to be executed repeatedly
...@@ -36,17 +36,17 @@ class TrainReader(object): ...@@ -36,17 +36,17 @@ class TrainReader(object):
"absence process_function in Reader" "absence process_function in Reader"
self.process = create_module(params['process_function'])(params) self.process = create_module(params['process_function'])(params)
def __call__(self, process_id): def __call__(self, process_id):
with open(self.label_file_path, "rb") as fin:
label_infor_list = fin.readlines()
img_num = len(label_infor_list)
img_id_list = list(range(img_num))
if sys.platform == "win32" and self.num_workers != 1:
print("multiprocess is not fully compatible with Windows."
"num_workers will be 1.")
self.num_workers = 1
def sample_iter_reader(): def sample_iter_reader():
with open(self.label_file_path, "rb") as fin:
label_infor_list = fin.readlines()
img_num = len(label_infor_list)
img_id_list = list(range(img_num))
random.shuffle(img_id_list) random.shuffle(img_id_list)
if sys.platform == "win32" and self.num_workers != 1:
print("multiprocess is not fully compatible with Windows."
"num_workers will be 1.")
self.num_workers = 1
for img_id in range(process_id, img_num, self.num_workers): for img_id in range(process_id, img_num, self.num_workers):
label_infor = label_infor_list[img_id_list[img_id]] label_infor = label_infor_list[img_id_list[img_id]]
outs = self.process(label_infor) outs = self.process(label_infor)
......
...@@ -21,7 +21,6 @@ import os ...@@ -21,7 +21,6 @@ import os
import shutil import shutil
import tempfile import tempfile
import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
from .utility import initial_logger from .utility import initial_logger
...@@ -113,14 +112,12 @@ def init_model(config, program, exe): ...@@ -113,14 +112,12 @@ def init_model(config, program, exe):
path = checkpoints path = checkpoints
fluid.load(program, path, exe) fluid.load(program, path, exe)
logger.info("Finish initing model from {}".format(path)) logger.info("Finish initing model from {}".format(path))
return
pretrain_weights = config['Global'].get('pretrain_weights') pretrain_weights = config['Global'].get('pretrain_weights')
if pretrain_weights: if pretrain_weights:
path = pretrain_weights path = pretrain_weights
load_params(exe, program, path) load_params(exe, program, path)
logger.info("Finish initing model from {}".format(path)) logger.info("Finish initing model from {}".format(path))
return
def save_model(program, model_path): def save_model(program, model_path):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册