Jeysshon commited on
Commit
4422d9e
·
1 Parent(s): 0e2a413

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -0
app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ import tensorflow
4
+ from tensorflow.keras.models import load_model
5
+ from tensorflow.keras.preprocessing import image
6
+
7
+ MODEL_ISATRON_JEY = 'modelo_isatron_jeysshonl.h5'
8
+
9
+ cnn_model = load_model(MODEL_ISATRON_JEY)
10
+
11
+ def make_prediction(test_image):
12
+ test_image = test_image.name
13
+ test_image = image.load_img(test_image, target_size=(224, 224))
14
+ test_image = image.img_to_array(test_image) / 255.
15
+ test_image = np.expand_dims(test_image, axis=0)
16
+ result = cnn_model.predict(test_image)
17
+ return {"Normal": str(result[0][0]), "Neumonia": str(result[0][1])}
18
+
19
+
20
+ image_input = gr.inputs.Image(type="file")
21
+
22
+ 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 radiografia toráxica. En la parte inferior encontrará unas imágenes que pueden ser usadas para ejemplificar el funcionamiento del modelo."
23
+
24
+
25
+
26
+ enable_queue = True
27
+ examples = [
28
+ ['1normal.jpeg'],
29
+ ['image1_pneumonia_virus.jpeg'],
30
+ ['image1_pneumonia_bacteria.jpeg'],
31
+ ['image2_normal.jpeg'],
32
+ ['image2_pneumonia_bacteria.jpeg'],
33
+ ['image3_normal.jpeg'],
34
+ ['image4_normal.jpeg'],
35
+ ]
36
+
37
+ article= "<p style='text-align: center'><span style='font-size: 15pt;'>IsaTron . Jeysshon Bustos . 2022. </span></p>"
38
+
39
+
40
+ interface=gr.Interface(fn=make_prediction,
41
+ inputs=image_input,
42
+ outputs='label',
43
+ title="Modelo (CNN) IsaTron ",
44
+ interpretation = "default",
45
+ description=description,
46
+ theme="default",
47
+ article=article,
48
+ examples=examples,
49
+ enable_queue=enable_queue
50
+ )
51
+ interface.launch(share=True)