akhaliq HF staff commited on
Commit
9b9f2a4
1 Parent(s): 16c6ef6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -1
app.py CHANGED
@@ -5,4 +5,28 @@ description="Gradio Demo for Swin Transformer: Hierarchical Vision Transformer u
5
 
6
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2103.14030' target='_blank'>Swin Transformer: Hierarchical Vision Transformer using Shifted Windows</a> | <a href='https://github.com/microsoft/Swin-Transformer' target='_blank'>Github Repo</a></p>"
7
 
8
- gr.Interface.load("huggingface/microsoft/swin-large-patch4-window12-384-in22k",title=title, article=article,description=description,examples=[["tiger.jpeg"]]).launch(enable_queue=True,cache_examples=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2103.14030' target='_blank'>Swin Transformer: Hierarchical Vision Transformer using Shifted Windows</a> | <a href='https://github.com/microsoft/Swin-Transformer' target='_blank'>Github Repo</a></p>"
7
 
8
+ gr.Interface.load("huggingface/microsoft/swin-large-patch4-window12-384-in22k",title=title, article=article,description=description,examples=[["tiger.jpeg"]]).launch(enable_queue=True,cache_examples=True)
9
+
10
+ io1 = gr.Interface.load("huggingface/microsoft/swin-large-patch4-window12-384-in22k")
11
+
12
+ io2 = gr.Interface.load("huggingface/microsoft/swin-base-patch4-window7-224-in22k")
13
+
14
+
15
+ def inference(image, model):
16
+ if model == "swin-large-patch4-window12-384-in22k":
17
+ outtext = io1(image)
18
+ else:
19
+ outtext = io2(image)
20
+ return outtext
21
+
22
+
23
+ examples=[['tiger.jpeg',"swin-large-patch4-window12-384-in22k"]]
24
+ gr.Interface(
25
+ inference,
26
+ [gr.inputs.Image(label="Input Image"),gr.inputs.Dropdown(choices=["swin-large-patch4-window12-384-in22k","swin-base-patch4-window7-224-in22k"], type="value", default="swin-large-patch4-window12-384-in22k", label="model")
27
+ ],
28
+ gr.outputs.Label(label="Classification"),
29
+ examples=examples,
30
+ article=article,
31
+ title=title,
32
+ description=description).launch(enable_queue=True, cache_examples=True)