sketch / app.py
shivakumar4147's picture
Update app.py
9fb0182 verified
raw
history blame
708 Bytes
import gradio as gr
import tensorflow as tf
import numpy as np
import cv2
# Load your trained model
model = tf.keras.models.load_model("model_244.h5")
def predict_image(image):
img = cv2.resize(image, (244, 244))
img = img.astype(np.float32) / 255.0
img = np.expand_dims(img, axis=0)
p = model.predict(img)[0][0]
risk = "High" if p > 0.7 else "Medium" if p > 0.4 else "Low"
return f"Risk: {risk} (Probability: {p:.3f})"
iface = gr.Interface(
fn=predict_image,
inputs=gr.Image(type="numpy"),
outputs="text",
title="Cancer Risk Detector (244×244)",
description="Upload an image to get a cancer risk prediction."
)
if __name__ == "__main__":
iface.launch()