Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import tensorflow as tf
|
|
2 |
import efficientnet.tfkeras as efn
|
3 |
import numpy as np
|
4 |
import gradio as gr
|
|
|
5 |
|
6 |
# Dimensões da imagem
|
7 |
IMG_HEIGHT = 224
|
@@ -55,18 +56,19 @@ def predict_image(input_image):
|
|
55 |
predicted_class = class_names[np.argmax(prediction)]
|
56 |
probability = prediction[0][np.argmax(prediction)]
|
57 |
|
58 |
-
#
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
return formatted_text
|
64 |
|
65 |
# Crie uma interface Gradio para fazer previsões
|
66 |
iface = gr.Interface(
|
67 |
fn=predict_image,
|
68 |
inputs=gr.inputs.Image(label="Upload an Image", type="pil"),
|
69 |
-
outputs=gr.outputs.
|
|
|
|
|
70 |
)
|
71 |
|
72 |
# Execute a interface Gradio
|
|
|
2 |
import efficientnet.tfkeras as efn
|
3 |
import numpy as np
|
4 |
import gradio as gr
|
5 |
+
import plotly.express as px
|
6 |
|
7 |
# Dimensões da imagem
|
8 |
IMG_HEIGHT = 224
|
|
|
56 |
predicted_class = class_names[np.argmax(prediction)]
|
57 |
probability = prediction[0][np.argmax(prediction)]
|
58 |
|
59 |
+
# Retorna a previsão em formato de string
|
60 |
+
return f"""
|
61 |
+
Predicted Class: {predicted_class}
|
62 |
+
Probability: {probability:.2%}
|
63 |
+
"""
|
|
|
64 |
|
65 |
# Crie uma interface Gradio para fazer previsões
|
66 |
iface = gr.Interface(
|
67 |
fn=predict_image,
|
68 |
inputs=gr.inputs.Image(label="Upload an Image", type="pil"),
|
69 |
+
outputs=gr.outputs.Output(label="Prediction", type="string"),
|
70 |
+
interpretation="text",
|
71 |
+
custom_interpretation_fn=predict_image
|
72 |
)
|
73 |
|
74 |
# Execute a interface Gradio
|