resnet-food101 / app.py
NikiTricky's picture
Update app.py
1d8353f
raw
history blame contribute delete
686 Bytes
import gradio as gr
from huggingface_hub import from_pretrained_keras
model = from_pretrained_keras("NikiTricky/resnet50-food101")
def classify_image(inp):
print("Classifying image...")
inp = inp.reshape((-1, 224, 224, 3))
inp = inp/255
prediction = model.predict(inp)[0]
confidences = {model.config['id2label'][str(i)]: float(prediction[i]) for i in range(101)}
return confidences
gr.Interface(fn=classify_image,
inputs=gr.Image(shape=(224, 224)),
outputs=gr.Label(num_top_classes=5),
examples=["./examples/chocolate cake.jpg", "./examples/cup cakes.jpg", "./examples/mac and cheese.jpg", "./examples/sashimi.jpg"]).launch()