Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- from PIL import Image
- import numpy as np
- os.chdir("./data")
- files = os.listdir()
- final = []
- for i in range (10):
- im = Image.open(files[i])
- threshold = 252
- im=im.resize((28,28), Image.ANTIALIAS)
- im = im.point(lambda p: p > threshold and 255)
- na = np.array(im)
- img=(na > na.mean())*255
- np.place(na,na<255,1)
- np.place(na,na==255,0)
- fa=na.reshape([1,784])
- fa = list(fa)
- final = final + fa
- print(final[3])
- im.show(final[6].reshape(28,28))
Advertisement
Add Comment
Please, Sign In to add comment