Dawa2000 commited on
Commit
33021f2
1 Parent(s): 202356d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -12
app.py CHANGED
@@ -1,17 +1,15 @@
1
- import gradio as gr
2
  from transformers import pipeline
 
 
3
  pipe = pipeline("image-classification", model="julien-c/hotdog-not-hotdog")
4
 
5
- def predict(input_img):
6
- predictions = pipeline(input_img)
7
- return input_img, {p["label"]:p["score"] for p in predictions}
8
 
9
- gradio_app = gr.Interface(
10
- predict,
11
- inputs = gr.Image(label="Select hot dog candidate", sources=['upload','webcam'],type="pil"),
12
- outputs=[gr.Image(label="Processed Image"),gr.Label(label="Result",num_top_classes=2)],
13
- title = "Hot Dog? or Not?"
14
- )
15
 
16
- if __name__ == "__main__":
17
- gradio_app.launch()
 
 
1
  from transformers import pipeline
2
+ import gradio as gr
3
+
4
  pipe = pipeline("image-classification", model="julien-c/hotdog-not-hotdog")
5
 
6
+ def predict(img):
7
+ predictions = pipe(img)
8
+ return img, {p["label"]: p["score"] for p in predictions}
9
 
10
+ interface = gr.Interface(fn = predict,
11
+ inputs = gr.Image(label = "select hot dog image", sources = ['upload', 'webcam'], type='pil'),
12
+ outputs = [gr.Image(label = "processed image"), gr.Label(label = "result", num_top_classes = 2)],
13
+ title = "hot dog or not")
 
 
14
 
15
+ interface.launch()