Spaces:
Sleeping

nivith's picture
Update app.py
d9330de
Raw History Blame Contribute Delete
782 Bytes
import os
import gradio as gr
import numpy as np
from PIL import Image
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing.image import img_to_array
# Define the paths and filenames
model_path = "skin_model.h5"
# Load the model and label encoder
model = load_model(model_path)
class_names = ['Non_Cancer','Cancer']
def predict_input_image(img):
img_4d=img.reshape(-1,100,100,3)
prediction=model.predict(img_4d)[0]
return {class_names[i]: float(prediction[i]) for i in range(1)}
image = gr.Image(shape=(100,100))
label = gr.Label(num_top_classes=2)
iface = gr.Interface(fn=predict_input_image, inputs=image, outputs=label,title="Cancer Vs Non Cancer",interpretation='default').launch(debug='True')
# Run the Gradio interface
iface.launch()