Spaces:
Sleeping
Sleeping
Download utils.py from ShamsKhan404/Emotion-detect: direct link, hf CLI and curl.
- Browser
- Download file 268 Bytes
-
https://huggingface.co/spaces/ShamsKhan404/Emotion-detect/resolve/main/utils.py
- Command line
-
hf download hf://spaces/ShamsKhan404/Emotion-detect/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/ShamsKhan404/Emotion-detect/resolve/main/utils.py
268 Bytes
| import tensorflow as tf | |
| import numpy as np | |
| from PIL import Image | |
| def preprocess_image(image_file): | |
| img = Image.open(image_file).convert("RGB") | |
| img = img.resize((256, 256)) | |
| img = np.array(img) / 255.0 | |
| img = np.expand_dims(img, axis=0) | |
| return img | |