From ad2e966bcff4d0e63a42d208b5adc04d297a2a09 Mon Sep 17 00:00:00 2001 From: Light-- <714022695@qq.com> Date: Wed, 8 Jul 2020 16:48:50 +0800 Subject: [PATCH] sovle the prepare_data error when convert bin datasets to folders, it will report: ``` Traceback (most recent call last): File "prepare_data.py", line 12, in load_mx_rec(rec_path) File "/home/user1/InsightFace_Pytorch/data/data_pipe.py", line 92, in load_mx_rec label = int(header.label) TypeError: only size-1 arrays can be converted to Python scalars ``` --- data/data_pipe.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/data/data_pipe.py b/data/data_pipe.py index bd67f02c..6b5d4898 100644 --- a/data/data_pipe.py +++ b/data/data_pipe.py @@ -88,7 +88,8 @@ def load_mx_rec(rec_path): for idx in tqdm(range(1,max_idx)): img_info = imgrec.read_idx(idx) header, img = mx.recordio.unpack_img(img_info) - label = int(header.label) + # label = int(header.label) + label = int(header.label[0]) img = Image.fromarray(img) label_path = save_path/str(label) if not label_path.exists(): @@ -119,4 +120,4 @@ def load_mx_rec(rec_path): # if self.h_flip: # img = de_preprocess(img) # img = self.transform(img) -# return img, label \ No newline at end of file +# return img, label