Skip to content

Commit

Permalink
Merge pull request #420 from BeyondYourself/develop
Browse files Browse the repository at this point in the history
Common modules do not need to be executed repeatedly
  • Loading branch information
tink2123 committed Aug 2, 2020
2 parents 5a0a193 + 1a0848a commit 06b943f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
18 changes: 9 additions & 9 deletions ppocr/data/det/dataset_traversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ def __init__(self, params):
"absence process_function in Reader"
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():
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)
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):
label_infor = label_infor_list[img_id_list[img_id]]
outs = self.process(label_infor)
Expand Down
3 changes: 0 additions & 3 deletions ppocr/utils/save_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import shutil
import tempfile

import paddle
import paddle.fluid as fluid

from .utility import initial_logger
Expand Down Expand Up @@ -113,14 +112,12 @@ def init_model(config, program, exe):
path = checkpoints
fluid.load(program, path, exe)
logger.info("Finish initing model from {}".format(path))
return

pretrain_weights = config['Global'].get('pretrain_weights')
if pretrain_weights:
path = pretrain_weights
load_params(exe, program, path)
logger.info("Finish initing model from {}".format(path))
return


def save_model(program, model_path):
Expand Down

0 comments on commit 06b943f

Please sign in to comment.