Jedav commited on
Commit
51a9d6e
verified
1 Parent(s): 18b877c

Create Prototipe

Browse files
Files changed (1) hide show
  1. Prototipe +39 -0
Prototipe ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ from PIL import Image
4
+ import tensorflow as tf
5
+ from tensorflow.keras.applications.mobilenet_v2 import preprocess_input
6
+
7
+ # Cargar modelo
8
+ model = tf.keras.models.load_model("modelo.h5")
9
+
10
+ # Clases (aj煤stalas seg煤n tu dataset)
11
+ clases = ["Nevo", "Queratosis", "Carcinoma", "Melanoma", "Dermatitis"]
12
+
13
+ # Funci贸n de predicci贸n
14
+ def predict(image):
15
+ image = image.resize((224, 224))
16
+ img = np.array(image)
17
+
18
+ # Preprocesamiento correcto para MobileNetV2
19
+ img = preprocess_input(img)
20
+ img = np.expand_dims(img, axis=0)
21
+
22
+ pred = model.predict(img)
23
+ idx = np.argmax(pred)
24
+ confianza = float(np.max(pred))
25
+
26
+ return {
27
+ clases[i]: float(pred[0][i]) for i in range(len(clases))
28
+ }
29
+
30
+ # Interfaz
31
+ interface = gr.Interface(
32
+ fn=predict,
33
+ inputs=gr.Image(type="pil"),
34
+ outputs=gr.Label(num_top_classes=3),
35
+ title="馃 Derm-IA",
36
+ description="Asistente de diagn贸stico dermatol贸gico basado en IA"
37
+ )
38
+
39
+ interface.launch()