My code:
folder_angry = 'C:/Users/User/Desktop/test'
all_vald_img = []
for filename_valid in os.listdir(folder_angry):
img_valid = cv2.imread(os.path.join(folder_angry,filename_valid))
if img_valid is not None:
all_vald_img.append(img_valid)
true_image = image.load_img(img_valid)
img = image.load_img(img_valid, color_mode="grayscale", target_size=(48, 48))
Error message:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfd in position 1: invalid start byte
I encountered this error while looping through the entire folder of pictures using cv2.imread. I've tried solutions like
with open(path, 'rb') as f:
contents = f.read()
or any other solutions start with with open like many people suggested, but none of them really works. However, if I use picture one by one without loop, like
filename_valid = "path"
true_image = image.load_img(filename_valid)
img = image.load_img(filename_valid, color_mode="grayscale", target_size=(48, 48))
it works, but I have to do it one by one.
Is there any good way to tackle this down?