rishabh5752's picture
Update app.py
17ca5e5
raw
history blame
1.35 kB
import gradio as gr
import numpy as np
from tensorflow.keras.models import load_model
# Load the trained model
model = load_model('skin_model.h5')
# Define a function to make predictions
def predict(image):
# Preprocess the image
image = image / 255.0
image = np.expand_dims(image, axis=0)
# Make a prediction using the model
prediction = model.predict(image)
# Get the predicted class label
if prediction[0][0] < 0.5:
label = 'Benign'
else:
label = 'Malignant'
return label
examples = [["benign.jpg"], ["malignant.jpg"]]
# Customized layout and style for improved UI
interface_layout = [
gr.Interface(
fn=predict,
inputs=gr.inputs.Image(shape=(150, 150)),
outputs=gr.outputs.Label(),
examples=examples,
title="Skin Cancer Classification",
description="Predicts whether a skin image is cancerous or not.",
theme="default", # Choose a theme: "default", "compact", "huggingface"
layout="vertical", # Choose a layout: "vertical", "horizontal", "double"
live=False # Set to True for live updates without clicking "Submit"
)
]
gr.Interface(
layout="colab", # Choose a layout: "colab", "colab-sandbox", "textbox"
layout_options={"fullscreen": True},
interfaces=interface_layout
).launch()