Created
November 1, 2018 13:06
-
-
Save malnakli/f6efb2474e071f27a381e58864b30931 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urllib import request | |
from PIL import Image | |
image_url = "https://cdn.shopify.com/s/files/1/2029/4253/products/[email protected]" | |
image_path = f"tmp/{image_url.split('/')[-1]}" | |
# download image | |
with request.urlopen(url=image_url, timeout=10) as response: | |
data = response.read() | |
with open(image_path, 'wb') as f: | |
f.write(data) | |
# convert image to grayscale. | |
image = Image.open(image_path).convert('L') | |
# resize the image to 28 28 to make sure it is similar to our dataset | |
image.thumbnail((28,28)) | |
image = preprocess_image(np.array(image)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment