Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Ground Controller Lvl 1
Message 1 of 1

Could not open the image using MNIST method for digital recognition in deep learning

I use python 3.7 in windows 7. When I tried to convert the image to MNIST format, I use the following code, how ever, I could not open the generated images.

When I tried to open the generated images, it says: the images appears to be damaged

 

def load_data(path):

idx = 0
total_imgs = len([img_name for img_name in os.listdir(path) if img_name.endswith('.png')])
data = np.zeros((total_imgs,28,28), dtype=np.uint8)
for img_name in os.listdir(path):
    if not img_name.endswith('.png'):
        continue

    img_path = os.path.join(path, img_name)
    img = cv.imread(img_path)
    resized_img = resize(img)
    data[idx,:]=resized_img
    idx+=1

return  data

data = load_data('D:\\EPS_projects\\AI\\2_CV\\MNIST\\work200306\\0')



import pickle
with open('D:\\EPS_projects\\AI\\2_CV\\MNIST\\work200306\\0\\1.PNG', 'wb') as f:
    pickle.dump(data, f)