Spaces:
Sleeping
Sleeping
Jeysshon
commited on
Commit
•
da9ab10
1
Parent(s):
5e49b71
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) que ayuda al personal médico a predecir si una radiografía pediátrica muestra alguna anomalía"\
|
23 |
+
" , el paciente pediátrico puede tener neumonía o no y para verificar la predicción del modelo IsaTron se crea un porcentaje." \
|
24 |
+
" Para el funcionamiento del algoritmo se agregaron algunas imágenes de ejemplos que he proporcionado."
|
25 |
+
|
26 |
+
enable_queue = True
|
27 |
+
examples = [
|
28 |
+
['1normal.jpeg'],
|
29 |
+
['neumo1.jpeg'],
|
30 |
+
['image1_pneumonia_virus.jpeg'],
|
31 |
+
['image1_pneumonia_bacteria.jpeg'],
|
32 |
+
['image2_normal.jpeg'],
|
33 |
+
['image2_pneumonia_bacteria.jpeg'],
|
34 |
+
['image3_normal.jpeg'],
|
35 |
+
['image4_normal.jpeg'],
|
36 |
+
]
|
37 |
+
|
38 |
+
texto_jey = "<p style='text-align: center'><span style='font-size: 15pt;'>IsaTron . Jeysshon Bustos . 2022. </span></p>"
|
39 |
+
|
40 |
+
|
41 |
+
interface=gr.Interface(fn=make_prediction,
|
42 |
+
inputs=image_input,
|
43 |
+
outputs='label',
|
44 |
+
title="Neumonia Detección IsaTron",
|
45 |
+
##interpretation = "default",
|
46 |
+
description=description,
|
47 |
+
theme="dark-huggingface",
|
48 |
+
texto_jey=texto_jey,
|
49 |
+
examples=examples,
|
50 |
+
enable_queue=enable_queue
|
51 |
+
)
|
52 |
+
interface.launch(share=True,debug=True)
|