Spaces:
Sleeping
Sleeping
File size: 872 Bytes
1de3f28 a58b6d3 1de3f28 | 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 26 27 28 29 | import gradio as gr
import numpy as np
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing import image
# Load your saved model (.keras file)
model = load_model("malaria_model.keras")
IMG_SIZE = (64, 64) # matches your training
def predict(img):
img = img.convert("RGB")
img = img.resize(IMG_SIZE)
img_array = image.img_to_array(img)
img_array = np.expand_dims(img_array, axis=0)
img_array = img_array / 255.0 # normalization
prediction = model.predict(img_array)[0][0]
label = "Uninfected" if prediction > 0.5 else "Infected"
return label
gr.Interface(
fn=predict,
inputs=gr.Image(type="pil"),
outputs=gr.Textbox(label="Prediction"),
title="Malaria Cell Image Predictor",
description="Upload a blood smear cell image to detect malaria (Infected/Uninfected)."
).launch(share=True)
|