TokenCut / app.py
akhaliq's picture
akhaliq HF staff
Create app.py
611b14d
raw history blame
No virus
1.09 kB
import os
import gradio as gr
os.system("git clone https://github.com/AK391/TokenCut.git")
os.chdir("TokenCut")
def inference(img):
os.system("python main_tokencut.py --image_path "+img+" --visualize all")
return "./outputs/TokenCut-vit_small16_k/test_TokenCut_attn.jpg","./outputs/TokenCut-vit_small16_k/test_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="file"),[gr.outputs.Image(type="file"),gr.outputs.Image(type="file")],title=title,description=description,article=article,examples=examples).launch()