Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
import tensorflow as tf
|
|
|
3 |
|
4 |
-
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
labels = [
|
10 |
'Acné / Rosácea', 'Queratosis Actínica / Carcinoma Basocelular',
|
@@ -25,7 +39,7 @@ def classify_image(image):
|
|
25 |
image = tf.image.resize(image, (224, 224))
|
26 |
image = tf.expand_dims(image, axis=0)
|
27 |
prediction = model.predict(image).flatten()
|
28 |
-
confidences = {labels[i]: float(prediction[i]) for i in range(
|
29 |
return confidences
|
30 |
|
31 |
title = "AI-DERM DETECTION"
|
@@ -39,7 +53,7 @@ article = (
|
|
39 |
"5. Celulitis / Impétigo (Infecciones Bacterianas)\n"
|
40 |
"6. Eccema\n"
|
41 |
"7. Exantemas (Erupciones Cutáneas por Medicamentos)\n"
|
42 |
-
"8.
|
43 |
"9. Herpes / VPH\n"
|
44 |
"10. Trastornos de la Pigmentación\n"
|
45 |
"11. Lupus\n"
|
@@ -87,3 +101,4 @@ gr.Interface(
|
|
87 |
outputs=gr.outputs.Label(num_top_classes=4),
|
88 |
examples=examples
|
89 |
).launch()
|
|
|
|
1 |
import gradio as gr
|
2 |
import tensorflow as tf
|
3 |
+
from tensorflow.keras.layers import DepthwiseConv2D
|
4 |
|
5 |
+
# Función personalizada para DepthwiseConv2D
|
6 |
+
def custom_depthwise_conv2d(**kwargs):
|
7 |
+
kwargs.pop('groups', None) # Eliminar el argumento 'groups'
|
8 |
+
return DepthwiseConv2D(**kwargs)
|
9 |
|
10 |
+
custom_objects = {'DepthwiseConv2D': custom_depthwise_conv2d}
|
11 |
+
|
12 |
+
# Ruta del modelo
|
13 |
+
path_to_model = "modelo_jeysshon_iaderm.h5"
|
14 |
+
|
15 |
+
# Cargar el modelo con custom_objects
|
16 |
+
try:
|
17 |
+
model = tf.keras.models.load_model(path_to_model, custom_objects=custom_objects)
|
18 |
+
print("Modelo cargado exitosamente.")
|
19 |
+
except Exception as e:
|
20 |
+
print(f"Error al cargar el modelo: {e}")
|
21 |
+
raise
|
22 |
|
23 |
labels = [
|
24 |
'Acné / Rosácea', 'Queratosis Actínica / Carcinoma Basocelular',
|
|
|
39 |
image = tf.image.resize(image, (224, 224))
|
40 |
image = tf.expand_dims(image, axis=0)
|
41 |
prediction = model.predict(image).flatten()
|
42 |
+
confidences = {labels[i]: float(prediction[i]) for i in range(len(labels))}
|
43 |
return confidences
|
44 |
|
45 |
title = "AI-DERM DETECTION"
|
|
|
53 |
"5. Celulitis / Impétigo (Infecciones Bacterianas)\n"
|
54 |
"6. Eccema\n"
|
55 |
"7. Exantemas (Erupciones Cutáneas por Medicamentos)\n"
|
56 |
+
"8. Pérdida de Cabello (Alopecia)\n"
|
57 |
"9. Herpes / VPH\n"
|
58 |
"10. Trastornos de la Pigmentación\n"
|
59 |
"11. Lupus\n"
|
|
|
101 |
outputs=gr.outputs.Label(num_top_classes=4),
|
102 |
examples=examples
|
103 |
).launch()
|
104 |
+
|