Spaces:
Build error
Build error
Download preprocess.py from maverick1729/image_captioning: direct link, hf CLI and curl.
- Browser
- Download file 309 Bytes
-
https://huggingface.co/spaces/maverick1729/image_captioning/resolve/main/preprocess.py
- Command line
-
hf download hf://spaces/maverick1729/image_captioning/preprocess.py
-
curl -L -o preprocess.py https://huggingface.co/spaces/maverick1729/image_captioning/resolve/main/preprocess.py
309 Bytes
| import tensorflow as tf | |
| def preprocess_image(img): | |
| img = tf.convert_to_tensor(img) | |
| # img = tf.io.decode_jpeg(img, channels=3) | |
| img = tf.keras.layers.Resizing(224, 224)(img) | |
| img = tf.cast(img, tf.float32) | |
| img = tf.keras.applications.efficientnet.preprocess_input(img) | |
| return img |