From 4de489248b4d72ca78c0ee605ea17ad2bb1a1d2d Mon Sep 17 00:00:00 2001 From: Y <35826375+BeGentleman@users.noreply.github.com> Date: Mon, 27 Jun 2022 14:54:24 +0800 Subject: [PATCH] fix two Type errors 1. file should be read as 'rb' method; 2.'face' need to be changed into byte type --- widerface_To_TFRecord.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/widerface_To_TFRecord.py b/widerface_To_TFRecord.py index 5251bfe..f535741 100644 --- a/widerface_To_TFRecord.py +++ b/widerface_To_TFRecord.py @@ -40,7 +40,7 @@ def parse_example(f): print(filepath) image_raw = cv2.imread(filepath) - encoded_image_data = open(filepath).read() + encoded_image_data = open(filepath, 'rb').read()# incase TypeError showed up key = hashlib.sha256(encoded_image_data).hexdigest() height, width, channel = image_raw.shape @@ -58,7 +58,7 @@ def parse_example(f): ymins.append( max(0.005, (float(annot[1]) / height) ) ) xmaxs.append( min(0.995, ((float(annot[0]) + float(annot[2])) / width) ) ) ymaxs.append( min(0.995, ((float(annot[1]) + float(annot[3])) / height) ) ) - classes_text.append('face') + classes_text.append('face'.encode('utf-8'))# string type 'face' need to be changed into byte type classes.append(1) poses.append("front".encode('utf8')) truncated.append(int(0))