import gradio as gr import numpy as np import tensorflow 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 = test_image.name 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])} image_input = gr.inputs.Image(type="file") 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"\ " , el paciente pediátrico puede tener neumonía o no y para verificar la predicción del modelo IsaTron se crea un porcentaje." \ " Para el funcionamiento del algoritmo se agregaron algunas imágenes de ejemplos que he proporcionado." enable_queue = True examples = [ ['1normal.jpeg'], ['neumo1.jpeg'], ['image1_pneumonia_virus.jpeg'], ['image1_pneumonia_bacteria.jpeg'], ['image2_normal.jpeg'], ['image2_pneumonia_bacteria.jpeg'], ['image3_normal.jpeg'], ['image4_normal.jpeg'], ] texto_jey = "
IsaTron . Jeysshon Bustos . 2022.
" interface=gr.Interface(fn=make_prediction, inputs=image_input, outputs='label', title="Neumonia Detección IsaTron", ##interpretation = "default", description=description, theme="dark-huggingface", texto_jey=texto_jey, examples=examples, enable_queue=enable_queue ) interface.launch(share=True,debug=True)