File size: 569 Bytes
834b6ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Use a pipeline as a high-level helper
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()