提交 15fd0b31 编写于 作者: T tink2123

add error message

上级 f7b5edcc
...@@ -185,6 +185,7 @@ class SimpleReader(object): ...@@ -185,6 +185,7 @@ class SimpleReader(object):
if params['mode'] != 'test': if params['mode'] != 'test':
self.img_set_dir = params['img_set_dir'] self.img_set_dir = params['img_set_dir']
self.label_file_path = params['label_file_path'] self.label_file_path = params['label_file_path']
self.use_gpu = params['use_gpu']
self.char_ops = params['char_ops'] self.char_ops = params['char_ops']
self.image_shape = params['image_shape'] self.image_shape = params['image_shape']
self.loss_type = params['loss_type'] self.loss_type = params['loss_type']
...@@ -213,6 +214,15 @@ class SimpleReader(object): ...@@ -213,6 +214,15 @@ class SimpleReader(object):
if self.mode != 'train': if self.mode != 'train':
process_id = 0 process_id = 0
def get_device_num():
if self.use_gpu:
gpus = os.environ.get("CUDA_VISIBLE_DEVICES", 1)
gpu_num = len(gpus.split(','))
return gpu_num
else:
cpu_num = os.environ.get("CPU_NUM", 1)
return int(cpu_num)
def sample_iter_reader(): def sample_iter_reader():
if self.mode != 'train' and self.infer_img is not None: if self.mode != 'train' and self.infer_img is not None:
image_file_list = get_image_file_list(self.infer_img) image_file_list = get_image_file_list(self.infer_img)
...@@ -237,6 +247,10 @@ class SimpleReader(object): ...@@ -237,6 +247,10 @@ class SimpleReader(object):
print("multiprocess is not fully compatible with Windows." print("multiprocess is not fully compatible with Windows."
"num_workers will be 1.") "num_workers will be 1.")
self.num_workers = 1 self.num_workers = 1
if self.batch_size * get_device_num() > img_num:
logger.error(
"The number of the whole data ({}) is smaller than the batch_size * devices_num ({})".
format(img_num, self.batch_size * get_device_num()))
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]]
substr = label_infor.decode('utf-8').strip("\n").split("\t") substr = label_infor.decode('utf-8').strip("\n").split("\t")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册