Download model/preprocess_input.py from weryques/pinas: direct link, hf CLI and curl.
- Browser
- Download file 409 Bytes
-
https://huggingface.co/spaces/weryques/pinas/resolve/main/model/preprocess_input.py
- Command line
-
hf download hf://spaces/weryques/pinas/model/preprocess_input.py
-
curl -L -o preprocess_input.py https://huggingface.co/spaces/weryques/pinas/resolve/main/model/preprocess_input.py
409 Bytes
| from PIL import Image | |
| from tensorflow.keras.utils import img_to_array | |
| from tensorflow.keras.applications import inception_resnet_v2 | |
| import numpy as np | |
| def preprocess_image(image): | |
| img = Image.open(image) | |
| # converting image to array | |
| x = img.resize((299, 299)) | |
| x = img_to_array(x) | |
| # reshaping the image | |
| x = np.expand_dims(x, axis=0) | |
| return inception_resnet_v2.preprocess_input(x) | |