Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -29,16 +29,11 @@ def build_model(img_height, img_width, n):
|
|
29 |
loaded_model = build_model(IMG_HEIGHT, IMG_WIDTH, 3)
|
30 |
loaded_model.load_weights('modelo_treinado.h5')
|
31 |
|
32 |
-
#
|
33 |
-
def
|
34 |
-
|
35 |
input_image = tf.image.resize(input_image, (IMG_HEIGHT, IMG_WIDTH))
|
36 |
-
|
37 |
-
# Normalização dos valores de pixel para o intervalo [0, 1]
|
38 |
input_image = input_image / 255.0
|
39 |
-
|
40 |
-
# Outras transformações, se necessárias (por exemplo, normalização adicional)
|
41 |
-
|
42 |
return input_image
|
43 |
|
44 |
# Função para fazer previsões usando o modelo treinado
|
@@ -63,7 +58,7 @@ def predict_image(input_image):
|
|
63 |
# Crie uma interface Gradio para fazer previsões
|
64 |
iface = gr.Interface(
|
65 |
fn=predict_image,
|
66 |
-
inputs=gr.inputs.Image(label="Upload an Image", type="file"
|
67 |
outputs=gr.outputs.Text(label="Prediction", type="markdown"),
|
68 |
interpretation="default",
|
69 |
title="Image Classifier",
|
|
|
29 |
loaded_model = build_model(IMG_HEIGHT, IMG_WIDTH, 3)
|
30 |
loaded_model.load_weights('modelo_treinado.h5')
|
31 |
|
32 |
+
# Function to preprocess the uploaded image
|
33 |
+
def preprocess_uploaded_image(input_image):
|
34 |
+
input_image = tf.image.decode_image(input_image.read(), channels=3)
|
35 |
input_image = tf.image.resize(input_image, (IMG_HEIGHT, IMG_WIDTH))
|
|
|
|
|
36 |
input_image = input_image / 255.0
|
|
|
|
|
|
|
37 |
return input_image
|
38 |
|
39 |
# Função para fazer previsões usando o modelo treinado
|
|
|
58 |
# Crie uma interface Gradio para fazer previsões
|
59 |
iface = gr.Interface(
|
60 |
fn=predict_image,
|
61 |
+
inputs=gr.inputs.Image(label="Upload an Image", type="file"),
|
62 |
outputs=gr.outputs.Text(label="Prediction", type="markdown"),
|
63 |
interpretation="default",
|
64 |
title="Image Classifier",
|