Pneumonia / app.py
DHEIVER's picture
Update app.py
ae2057d
raw
history blame
1.61 kB
import tensorflow as tf
import keras
import gradio as gr
import numpy as np
import cv2
import os
model=tf.keras.models.load_model('model.h5')
def predict_pneumonia(image):
resized_img = cv2.resize(image, (180, 180))
img_array = np.array(resized_img).reshape((1, 180, 180, 3))
prediction = model.predict(img_array)[0][0]
pneumonia_percent = prediction*1
normal_percent = (1 - prediction)*1
return {"Pneumonia ": pneumonia_percent, "Normal ": normal_percent}
inputs = gr.inputs.Image(shape=(180, 180))
outputs = gr.outputs.Label(num_top_classes=2)
gradio_interface = gr.Interface(fn=predict_pneumonia, inputs=inputs, outputs=outputs,
title="Classification of pneumonia in chest X-ray",
#description = "A simple app to classify chest X-ray images into normal and pneumonia and show the percentage of each",
examples = ["person1946_bacteria_4875.jpeg", "person1952_bacteria_4883.jpeg", "NORMAL2-IM-1427-0001.jpeg", "NORMAL2-IM-1431-0001.jpeg"],
article = "<p style='text-align: center'>Lior Cohen & Arad Peleg | Final Project 2023</p>"
"<p style='text-align: center'>Supervisor: Dr. Dima Alberg</p>",
theme = gr.themes.Monochrome(),)
# gr.themes.Soft() 讻讞讜诇
# gr.themes.Monochrome() 砖讞讜专
# gr.themes.Glass() 讗驻讜专
gradio_interface.launch()
# share=True
# live=True
# enable_queue=True