Spaces:
Sleeping
Sleeping
File size: 686 Bytes
447ad7c 7bf3aad 447ad7c 7bf3aad 447ad7c 7bf3aad d1a8798 04864f5 7bf3aad 34ba7da bde552e 04864f5 7bf3aad 447ad7c 7bf3aad dcadd9e 1d8353f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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() |