Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,11 +10,17 @@ import io
|
|
10 |
model = load_model('model_1.0000.h5')
|
11 |
|
12 |
def predict_and_invert(input_image):
|
13 |
-
#
|
|
|
|
|
|
|
14 |
img = image.img_to_array(input_image)
|
15 |
-
img = np.expand_dims(img, axis=0)
|
16 |
img = img / 255.0 # Normalizar a imagem (como fizemos durante o treinamento)
|
17 |
|
|
|
|
|
|
|
|
|
18 |
prediction = model.predict(img)
|
19 |
|
20 |
# Interpretar o resultado
|
@@ -34,7 +40,6 @@ def predict_and_invert(input_image):
|
|
34 |
return result, img_inverted_pil
|
35 |
|
36 |
# Criar uma interface Gradio
|
37 |
-
# ...
|
38 |
iface = gr.Interface(
|
39 |
fn=predict_and_invert,
|
40 |
inputs=gr.inputs.Image(type="pil", label="Carregar uma imagem"),
|
@@ -42,6 +47,5 @@ iface = gr.Interface(
|
|
42 |
title="Modelo de Classificação de Anomalias Cardíacas"
|
43 |
)
|
44 |
|
45 |
-
# Executar a interface Gradio
|
46 |
iface.launch()
|
47 |
-
|
|
|
10 |
model = load_model('model_1.0000.h5')
|
11 |
|
12 |
def predict_and_invert(input_image):
|
13 |
+
# Redimensionar a imagem para (224, 224) - o tamanho esperado pelo modelo
|
14 |
+
input_image = input_image.resize((224, 224))
|
15 |
+
|
16 |
+
# Converter a imagem para o formato correto
|
17 |
img = image.img_to_array(input_image)
|
|
|
18 |
img = img / 255.0 # Normalizar a imagem (como fizemos durante o treinamento)
|
19 |
|
20 |
+
# Ajustar a imagem para o tamanho correto (224, 224, 3)
|
21 |
+
img = np.expand_dims(img, axis=0)
|
22 |
+
img = img[:, :224, :224, :] # Ajustar para 224x224 pixels
|
23 |
+
|
24 |
prediction = model.predict(img)
|
25 |
|
26 |
# Interpretar o resultado
|
|
|
40 |
return result, img_inverted_pil
|
41 |
|
42 |
# Criar uma interface Gradio
|
|
|
43 |
iface = gr.Interface(
|
44 |
fn=predict_and_invert,
|
45 |
inputs=gr.inputs.Image(type="pil", label="Carregar uma imagem"),
|
|
|
47 |
title="Modelo de Classificação de Anomalias Cardíacas"
|
48 |
)
|
49 |
|
50 |
+
# Executar a interface Gradio
|
51 |
iface.launch()
|
|