File size: 648 Bytes
fef9706 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import gradio as gr
from tensorflow.keras.models import load_model
from PIL import Image
import numpy as np
model = load_model('xray_image_classifier_model.keras')
def predict_image(img):
img = img.resize((150, 150))
img = np.array(img) / 255.0
img = np.expand_dims(img, axis=0)
prediction = model.predict(img)
label = 'Pneumonia' if prediction > 0.5 else 'Normal'
return label
iface = gr.Interface(
fn=predict_image,
inputs=gr.inputs.Image(type="pil"),
outputs="text",
title="X-ray Image Classifier",
description="Upload an X-ray image to classify it as 'Pneumonia' or 'Normal'."
)
iface.launch()
|