akhaliq HF staff commited on
Commit
b4b06cd
·
1 Parent(s): a9bedda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -1,5 +1,7 @@
1
  import os
2
  import gradio as gr
 
 
3
 
4
  os.system("git clone https://github.com/AK391/TokenCut.git")
5
  os.chdir("TokenCut")
@@ -8,7 +10,8 @@ os.system("wget https://i.imgur.com/G4wpITa.jpg -O dog.jpg")
8
 
9
  def inference(img):
10
  os.system("python main_tokencut.py --image_path "+img+" --visualize all")
11
- return "./outputs/TokenCut-vit_small16_k/test_TokenCut_attn.jpg","./outputs/TokenCut-vit_small16_k/test_TokenCut_pred.jpg"
 
12
 
13
  title="TokenCut"
14
  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"
 
1
  import os
2
  import gradio as gr
3
+ from pathlib import Path
4
+
5
 
6
  os.system("git clone https://github.com/AK391/TokenCut.git")
7
  os.chdir("TokenCut")
 
10
 
11
  def inference(img):
12
  os.system("python main_tokencut.py --image_path "+img+" --visualize all")
13
+ filename = Path(img).stem
14
+ return "./outputs/TokenCut-vit_small16_k/"+filename+"_TokenCut_attn.jpg","./outputs/TokenCut-vit_small16_k/"+filename+"_TokenCut_pred.jpg"
15
 
16
  title="TokenCut"
17
  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"