File size: 1,783 Bytes
da9ab10
 
75dd026
da9ab10
 
 
820dedb
da9ab10
5523171
da9ab10
5523171
 
 
 
 
 
 
75dd026
 
7b23309
 
 
 
 
 
5523171
 
7b23309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14a7ef2
7b23309
 
5523171
75dd026
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import gradio as gr
import numpy as np
import tensorflow as tf
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing import image

MODEL_ISATRON_JEY = 'modelo_isatron_jeysshonl.h5'

cnn_model = load_model(MODEL_ISATRON_JEY)

def make_prediction(test_image):
    test_image = image.load_img(test_image, target_size=(224, 224))
    test_image = image.img_to_array(test_image) / 255.
    test_image = np.expand_dims(test_image, axis=0)
    result = cnn_model.predict(test_image)
    return {"Normal": str(result[0][0]), "Neumonia": str(result[0][1])}

# Actualización del tipo de entrada de imagen
image_input = gr.Image(type="filepath")

description = ("El modelo IsaTron es una Red Neuronal Convolucional (CNN) diseñada como un método de apoyo medico "
               "para el diagnóstico en imágenes radiológicas de neumonía pediátrica. Isatron arroja un porcentaje para "
               "lograr interpretar la radiografía torácica. En la parte inferior encontrará unas imágenes que pueden "
               "ser usadas para ejemplificar el funcionamiento del modelo. "
               "https://repositorio.unbosque.edu.co/handle/20.500.12495/9514")

examples = [
    ['1normal.jpeg'],
    ['image1_pneumonia_virus.jpeg'],
    ['image1_pneumonia_bacteria.jpeg'],
    ['image2_normal.jpeg'],
    ['image2_pneumonia_bacteria.jpeg'],
    ['image3_normal.jpeg'],
    ['image4_normal.jpeg'],
]

article = "<p style='text-align: center'><span style='font-size: 15pt;'>IsaTron . Jeysshon Bustos . 2022. </span></p>"

interface = gr.Interface(
    fn=make_prediction,
    inputs=image_input,
    outputs='label',
    title="Modelo (CNN) IsaTron",
    description=description,
    article=article,
    examples=examples
)

interface.launch(share=True)