Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,19 +8,23 @@ model = load_model('cnn_covid.keras')
|
|
8 |
|
9 |
# Funci贸n para hacer la predicci贸n
|
10 |
def predict_image(image):
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
18 |
|
19 |
-
# Interpretar la predicci贸n
|
20 |
-
result = 'COVID19' if prediction[0][0] < 0.5 else 'NORMAL'
|
21 |
-
return result, "If you don't have an image, please download one from this link: https://drive.google.com/drive/folders/1Dr11dKuSlgtWaTzNLRixzB19y588iNib?usp=sharing"
|
22 |
-
|
23 |
-
# Crear la interfaz de Gradio
|
24 |
-
iface = gr.Interface(fn=predict_image,inputs=gr.Image(type="pil"), outputs=[gr.Textbox(label="Prediction"), gr.Textbox(label="Download Link")], live=True)
|
25 |
# Lanzar la interfaz
|
26 |
-
iface.launch()
|
|
|
8 |
|
9 |
# Funci贸n para hacer la predicci贸n
|
10 |
def predict_image(image):
|
11 |
+
# Preprocesar la imagen
|
12 |
+
img = image.resize((200, 200)) # Redimensionar a 200x200
|
13 |
+
img_array = img_to_array(img)
|
14 |
+
img_array = np.expand_dims(img_array, axis=0) # A帽adir dimensi贸n para el batch
|
15 |
+
|
16 |
+
# Realizar la predicci贸n
|
17 |
+
prediction = model.predict(img_array)
|
18 |
+
|
19 |
+
# Interpretar la predicci贸n
|
20 |
+
result = 'COVID19' if prediction[0][0] < 0.5 else 'NORMAL'
|
21 |
+
return result, "If you don't have an image, please download one from this link: https://drive.google.com/drive/folders/1Dr11dKuSlgtWaTzNLRixzB19y588iNib?usp=sharing"
|
22 |
|
23 |
+
# Crear la interfaz de Gradio
|
24 |
+
iface = gr.Interface(fn=predict_image,
|
25 |
+
inputs=gr.Image(type="pil"),
|
26 |
+
outputs=[gr.Textbox(label="Prediction"), gr.Textbox(label="Download Link")],
|
27 |
+
live=True)
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
# Lanzar la interfaz
|
30 |
+
iface.launch()
|