Spaces:
Runtime error
Runtime error
Download classifier.py from sabre-code/Flower-Classification: direct link, hf CLI and curl.
- Browser
- Download file 573 Bytes
-
https://huggingface.co/spaces/sabre-code/Flower-Classification/resolve/ca01b1df640954ea838fd38998e50d855a3bf574/classifier.py
- Command line
-
hf download hf://spaces/sabre-code/Flower-Classification@ca01b1df640954ea838fd38998e50d855a3bf574/classifier.py
-
curl -L -o classifier.py https://huggingface.co/spaces/sabre-code/Flower-Classification/resolve/ca01b1df640954ea838fd38998e50d855a3bf574/classifier.py
573 Bytes
| import tensorflow as tf | |
| from tf.keras.models import load_model | |
| model = load_model('myModel.hdf5') | |
| import gradio as gr | |
| def classify(inp): | |
| img_array = tf.keras.utils.img_to_array(img) | |
| img_array = tf.expand_dims(img_array, 0) # Create a batch | |
| predictions = model.predict(img_array) | |
| score = tf.nn.softmax(predictions[0]) | |
| confidences = {class_names[i]: float(score[i]) for i in range(5)} | |
| return confidences | |
| gr.Interface(fn=classify, | |
| inputs=gr.Image(shape=(180, 180)), | |
| outputs=gr.Label(num_top_classes=5)).launch(debug=True) | |