resnet-food101 / app.py
NikiTricky's picture
Update app.py
7fdcf83
raw
history blame
571 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]
print(prediction, model.config)
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=3)).launch()