akhaliq HF staff commited on
Commit
611b14d
1 Parent(s): fe39d40

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+
4
+ os.system("git clone https://github.com/AK391/TokenCut.git")
5
+ os.chdir("TokenCut")
6
+
7
+ def inference(img):
8
+ os.system("python main_tokencut.py --image_path "+img+" --visualize all")
9
+ return "./outputs/TokenCut-vit_small16_k/test_TokenCut_attn.jpg","./outputs/TokenCut-vit_small16_k/test_TokenCut_pred.jpg"
10
+
11
+ title="TokenCut"
12
+ description="Gradio demo for TokenCut: Self-Supervised Transformers for Unsupervised Object Discovery using Normalized Cut. To use it, simply upload your image or click on one of the examples to load them. Read more at the links below"
13
+
14
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2202.11539' target='_blank'>Self-Supervised Transformers for Unsupervised Object Discovery using Normalized Cut</a> | <a href='https://github.com/YangtaoWANG95/TokenCut' target='_blank'>Github Repo</a></p>"
15
+
16
+ examples=[['dog.jpg']]
17
+ gr.Interface(inference,gr.inputs.Image(type="file"),[gr.outputs.Image(type="file"),gr.outputs.Image(type="file")],title=title,description=description,article=article,examples=examples).launch()