Created
June 16, 2023 10:46
-
-
Save devmnj/c0c1e5975c252a6dd87753c696d931df to your computer and use it in GitHub Desktop.
Function for load image from url for classification (Keras) - Python
This file contains 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
def loadImage(url): | |
response = requests.get(url) | |
img_bytes = BytesIO(response.content) | |
img = Image.open(img_bytes) | |
img = img.convert('L') | |
# img = img.convert('1') | |
# img = img.convert('RGB') | |
img = img.resize((28, 28), Image.NEAREST) | |
img = keras.utils.img_to_array(img) | |
return img |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment