Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,13 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
gr.Interface(fn=predict_image,
|
| 4 |
inputs=gr.Image(shape=(180, 180)),
|
| 5 |
outputs=[gr.Label(num_top_classes=5), "text"],
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
def predict_image(opened_image):
|
| 4 |
+
img_array = tf.keras.utils.img_to_array(opened_image)
|
| 5 |
+
img_array = tf.expand_dims(img_array, 0) #Convert image to one empty batch -> Model was trained on batches
|
| 6 |
+
prediction = model.predict(img_array)
|
| 7 |
+
score = tf.nn.softmax(prediction[0])
|
| 8 |
+
return ("Class of Flower: " + str(class_names[np.argmax(score)]), "Confidence level: " + str(100 * np.max(score)))
|
| 9 |
+
|
| 10 |
+
|
| 11 |
gr.Interface(fn=predict_image,
|
| 12 |
inputs=gr.Image(shape=(180, 180)),
|
| 13 |
outputs=[gr.Label(num_top_classes=5), "text"],
|