Spaces:
Runtime error
Runtime error
Download app.py from BharathyVinothKumar/DLA_projects: direct link, hf CLI and curl.
- Browser
- Download file 465 Bytes
-
https://huggingface.co/spaces/BharathyVinothKumar/DLA_projects/resolve/main/app.py
- Command line
-
hf download hf://spaces/BharathyVinothKumar/DLA_projects/app.py
-
curl -L -o app.py https://huggingface.co/spaces/BharathyVinothKumar/DLA_projects/resolve/main/app.py
465 Bytes
| import gradio as gr | |
| import tensorflow as tf | |
| import numpy as np | |
| from PIL import Image | |
| # Load model | |
| model = tf.keras.models.load_model("model.h5") | |
| # Prediction function | |
| def predict(image): | |
| image = image.resize((48,48)) # change size if needed | |
| image = np.array(image)/255.0 | |
| image = np.expand_dims(image, axis=0) | |
| pred = model.predict(image) | |
| return str(np.argmax(pred)) | |
| # UI | |
| gr.Interface(fn=predict, inputs="image", outputs="text").launch() |