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 = "

Lior Cohen & Arad Peleg | Final Project 2023

" "

Supervisor: Dr. Dima Alberg

", theme = gr.themes.Monochrome(),) # gr.themes.Soft() כחול # gr.themes.Monochrome() שחור # gr.themes.Glass() אפור gradio_interface.launch() # share=True # live=True # enable_queue=True