File size: 1,292 Bytes
611b14d b4b06cd 611b14d edddebe 611b14d b4b06cd 611b14d edddebe 68260b3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import os
import gradio as gr
from pathlib import Path
os.system("git clone https://github.com/AK391/TokenCut.git")
os.chdir("TokenCut")
os.system("wget https://i.imgur.com/G4wpITa.jpg -O dog.jpg")
def inference(img):
os.system("python main_tokencut.py --image_path "+img+" --visualize all")
filename = Path(img).stem
return "./outputs/TokenCut-vit_small16_k/"+filename+"_TokenCut_attn.jpg","./outputs/TokenCut-vit_small16_k/"+filename+"_TokenCut_pred.jpg"
title="TokenCut"
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"
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>"
examples=[['dog.jpg']]
gr.Interface(inference,gr.inputs.Image(type="filepath"),[gr.outputs.Image(type="file",label="TokenCut_attn"),gr.outputs.Image(type="file",label="TokenCut_predication")],title=title,description=description,article=article,examples=examples).launch(enable_queue=True)
|