gpantaz commited on
Commit
79ba67c
·
1 Parent(s): 737c454

Add application file

Browse files
Files changed (1) hide show
  1. app.py +17 -17
app.py CHANGED
@@ -1,25 +1,25 @@
1
- import os
2
-
3
  import gradio as gr
4
- from huggingface_hub import login
5
 
6
- from playground_app import demo as playground_tab
7
 
8
- auth_token = os.environ.get("HF_TOKEN", None)
9
- if auth_token:
10
- login(token=auth_token)
11
 
 
 
 
12
 
13
- title = """
14
- <div align="center">
15
- <span>Tokenization Playground</span>
16
- </div>
17
- """
18
 
19
- with gr.Blocks() as demo:
20
- _ = gr.HTML(f"<h1 style='text-align: center; margin-bottom: 1rem'>{title}</h1>")
21
- _ = playground_tab.render()
 
 
 
 
 
 
 
 
22
 
23
  if __name__ == "__main__":
24
- demo.launch()
25
- # demo.launch(share=True)
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
5
 
 
 
 
6
 
7
+ def predict(input_img):
8
+ predictions = pipeline(input_img)
9
+ return input_img, {p["label"]: p["score"] for p in predictions}
10
 
 
 
 
 
 
11
 
12
+ gradio_app = gr.Interface(
13
+ predict,
14
+ inputs=gr.Image(
15
+ label="Select hot dog candidate", sources=["upload", "webcam"], type="pil"
16
+ ),
17
+ outputs=[
18
+ gr.Image(label="Processed Image"),
19
+ gr.Label(label="Result", num_top_classes=2),
20
+ ],
21
+ title="Hot Dog? Or Not?",
22
+ )
23
 
24
  if __name__ == "__main__":
25
+ gradio_app.launch()