Skip to content

Commit 8e3983c

Browse files
committed
Correct error in font_one_hot and fontVariant_one_hot
1 parent 9b3e16f commit 8e3983c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ocr_utils.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,15 @@ def apply_column_filters(df, input_filters_dict ):
324324
def convert_to_unique(t1):
325325
''' convert unique values in an numpy.array into
326326
indices into the unique array
327+
327328
arguments:
328329
t1 numpy scalar array
330+
329331
return
330332
t1 with each value changed to an index 0 to number of unique
331333
values in t1-1
332334
'''
333-
t2 = t1
335+
t2 = np.zeros((len(t1),),dtype=np.int32)
334336
unique = np.unique(t1)
335337
for i,u in enumerate(unique):
336338
t2[t1==u]=i
@@ -519,19 +521,19 @@ class DataSets(object):
519521
feature_name.append(colName)
520522

521523
elif colName=='m_label_one_hot':
522-
t1 = np.array(df['m_label'] , dtype=np.uint16)
524+
t1 = np.array(df['m_label'] )
523525
t1 = convert_to_unique(t1)
524526
one_hot_map[-1] = len(np.unique(t1))
525527
feature_name.append(colName)
526528

527529
elif colName=='font_one_hot':
528-
t1 = np.array(df['font'] , dtype=np.uint16)
530+
t1 = np.array(df['font'])
529531
t1 = convert_to_unique(t1)
530532
one_hot_map[-1] = len(np.unique(t1))
531533
feature_name.append(colName)
532534

533535
elif colName=='fontVariant_one_hot':
534-
t1 = np.array(df['fontVariant'] , dtype=np.uint16)
536+
t1 = np.array(df['fontVariant'] )
535537
t1 = convert_to_unique(t1)
536538
one_hot_map[-1] = len(np.unique(t1))
537539
feature_name.append(colName)

0 commit comments

Comments
 (0)