From fce0a57dec5635022d4170ba4a15e32a432b9cc7 Mon Sep 17 00:00:00 2001 From: "shaohua.zhang" Date: Thu, 30 Jul 2020 22:29:19 +0800 Subject: [PATCH] move the shuffer into def sample_iter_reader --- ppocr/data/det/dataset_traversal.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ppocr/data/det/dataset_traversal.py b/ppocr/data/det/dataset_traversal.py index 76e298c2..c4ad5ced 100644 --- a/ppocr/data/det/dataset_traversal.py +++ b/ppocr/data/det/dataset_traversal.py @@ -36,18 +36,17 @@ class TrainReader(object): "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() + label_infor_list = fin.readlines() img_num = len(label_infor_list) - img_id_list = list(range(img_num)) - if sys.platform == "win32": - random.shuffle(img_id_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(): + random.shuffle(img_id_list) 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) -- GitLab