File size: 590 Bytes
e65ec4c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from transformers import pipeline
import gradio as gr

pipe = pipeline("image-classification", model="julien-c/hotdog-not-hotdog")

def predict(img):
  predictions = pipe(img)
  return img, {p["label"]: p["score"] for p in predictions}

interface = gr.Interface(fn = predict,
                         inputs = gr.Image(label = "select hot dog image", sources = ['upload', 'webcam'], type='pil'),
                         outputs = [gr.Image(label = "processed image"), gr.Label(label = "result", num_top_classes = 2)],
                         title = "hot dog or not")

interface.launch()