def LoadData(FP = '.'):
'''
Loads the OCR dataset. A is matrix of images (NIMG, Height, Width, Channel).
Y is matrix of characters (NIMG, MAX_CHAR)
FP: Path to OCR data folder
return: Data Matrix, Target Matrix, Target Strings
'''
TFP = os.path.join(FP, 'Train.csv')
A, Y, T, FN = [], [], [], []
with open(TFP) as F:
for Li in F:
FNi, Yi = Li.strip().split(',') #filename,string
T.append(Yi)
A.append(imread(os.path.join(FP, 'Out', FNi)))
Y.append(list(Yi) + [' '] * (MAX_CHAR - len(Yi))) #Pad strings with spaces
FN.append(FNi)
return np.stack(A), np.stack(Y), np.stack(T), np.stack(FN)
评论列表
文章目录