未验证 提交 d42eb4ff 编写于 作者: S shaohua.zhang 提交者: GitHub

fix some bugs

上级 efa97b69
...@@ -13,20 +13,16 @@ ...@@ -13,20 +13,16 @@
#limitations under the License. #limitations under the License.
import os import os
import sys
import math
import random import random
import numpy as np import sys
import cv2
import string import cv2
import lmdb import lmdb
from ppocr.utils.utility import initial_logger
from ppocr.utils.utility import get_image_file_list from ppocr.utils.utility import get_image_file_list
logger = initial_logger() from ppocr.utils.utility import initial_logger
from .img_tools import process_image, process_image_srn, get_img_data from .img_tools import process_image, process_image_srn, get_img_data
logger = initial_logger()
class LMDBReader(object): class LMDBReader(object):
...@@ -268,7 +264,7 @@ class SimpleReader(object): ...@@ -268,7 +264,7 @@ class SimpleReader(object):
infer_mode=True) infer_mode=True)
yield norm_img yield norm_img
else: else:
with open(self.label_file_path, "rb") as fin: with open(self.label_file_path, "r", encoding="utf-8") as fin:
label_infor_list = fin.readlines() label_infor_list = fin.readlines()
img_num = len(label_infor_list) img_num = len(label_infor_list)
img_id_list = list(range(img_num)) img_id_list = list(range(img_num))
...@@ -285,8 +281,8 @@ class SimpleReader(object): ...@@ -285,8 +281,8 @@ class SimpleReader(object):
self.num_workers)) self.num_workers))
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.strip("\n").strip().split()
img_path = self.img_set_dir + "/" + substr[0] img_path = os.path.join(self.img_set_dir, substr[0])
img = cv2.imread(img_path) img = cv2.imread(img_path)
if img is None: if img is None:
logger.info("{} does not exist!".format(img_path)) logger.info("{} does not exist!".format(img_path))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册