sensei-ml's picture
Add first model of the interface and incorporate the CNN model
d60e533
raw
history blame
677 Bytes
from model import model
import gradio as gr
import numpy as np
def classify_image(image):
probabilities = model.predict(image.name) # Call prediction function
labels = ["Category1", "Category2", "Category3", "Category4"] # Assing labels
top_labels = [labels[i] for i in np.argsort(probabilities)[::-1][:4]]
top_probs = [round(float(probabilities[i]), 4) for i in np.argsort(probabilities)[::-1][:4]]
demo = gr.Interface(
fn=classify_image,
inputs=gr.inputs.Image(),
outputs=gr.outputs.Label(num_top_classes=4),
title="Image Classifier",
description="Upload an image and get the top 4 predicted labels with probabilities.",)
demo.launch()