Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -100,12 +100,63 @@ def image_classifier1(img):
|
|
| 100 |
prediction_percentage = {'PNEUMONIA': float(prediction), 'NORMAL': float(1 - prediction)}
|
| 101 |
return overlayed_img, prediction_percentage
|
| 102 |
|
| 103 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
demo_model1 = gr.Interface(
|
| 105 |
fn=image_classifier1,
|
| 106 |
-
inputs="
|
| 107 |
-
outputs=[
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
)
|
| 110 |
|
| 111 |
# Ejecutar la interfaz
|
|
|
|
| 100 |
prediction_percentage = {'PNEUMONIA': float(prediction), 'NORMAL': float(1 - prediction)}
|
| 101 |
return overlayed_img, prediction_percentage
|
| 102 |
|
| 103 |
+
# Definir CSS personalizado
|
| 104 |
+
custom_css = """
|
| 105 |
+
body {
|
| 106 |
+
background-color: #e6f2ff;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
h1 {
|
| 110 |
+
color: #003366;
|
| 111 |
+
text-align: center;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
.gradio-container {
|
| 115 |
+
font-family: 'Arial', sans-serif;
|
| 116 |
+
max-width: 800px;
|
| 117 |
+
margin: auto;
|
| 118 |
+
padding: 20px;
|
| 119 |
+
background-color: #ffffff;
|
| 120 |
+
border-radius: 10px;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
.footer {
|
| 124 |
+
text-align: center;
|
| 125 |
+
margin-top: 20px;
|
| 126 |
+
color: #003366;
|
| 127 |
+
font-size: 14px;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
label {
|
| 131 |
+
font-weight: bold;
|
| 132 |
+
color: #003366;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
button {
|
| 136 |
+
background-color: #0059b3;
|
| 137 |
+
color: white;
|
| 138 |
+
border: none;
|
| 139 |
+
padding: 10px 20px;
|
| 140 |
+
cursor: pointer;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
button:hover {
|
| 144 |
+
background-color: #004080;
|
| 145 |
+
}
|
| 146 |
+
"""
|
| 147 |
+
|
| 148 |
+
# Crear interfaz Gradio con CSS personalizado y pie de página
|
| 149 |
demo_model1 = gr.Interface(
|
| 150 |
fn=image_classifier1,
|
| 151 |
+
inputs=gr.Image(type="pil", label="Sube una imagen de radiografía"),
|
| 152 |
+
outputs=[
|
| 153 |
+
gr.Image(type="numpy", label="Imagen con Mapa de Calor"),
|
| 154 |
+
gr.Label(num_top_classes=2, label="Resultados de Predicción")
|
| 155 |
+
],
|
| 156 |
+
title="IsaTron V2 con Mapa de Calor",
|
| 157 |
+
description="Esta aplicación detecta neumonía a partir de imágenes de radiografías de tórax.",
|
| 158 |
+
article="<div class='footer'>Jeysshon 2024</div>",
|
| 159 |
+
css=custom_css
|
| 160 |
)
|
| 161 |
|
| 162 |
# Ejecutar la interfaz
|