Spaces:
Sleeping
Sleeping
Download app.py from ncncomplete/mini-image-classifier: direct link, hf CLI and curl.
- Browser
- Download file 495 Bytes
-
https://huggingface.co/spaces/ncncomplete/mini-image-classifier/resolve/main/app.py
- Command line
-
hf download hf://spaces/ncncomplete/mini-image-classifier/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ncncomplete/mini-image-classifier/resolve/main/app.py
495 Bytes
| import gradio as gr | |
| import tensorflow as tf | |
| import numpy as np | |
| model = tf.keras.models.load_model('model.h5') | |
| labels = ['Class_A', 'Class_B'] # Update this after training | |
| def predict(image): | |
| image = tf.image.resize(image, (224, 224)) | |
| image = np.expand_dims(image, axis=0) / 255.0 | |
| prediction = model.predict(image)[0] | |
| return {labels[i]: float(prediction[i]) for i in range(len(labels))} | |
| interface = gr.Interface(fn=predict, inputs='image', outputs='label') | |
| interface.launch() | |