Spaces:
Runtime error
Runtime error
Yangtao Wang
commited on
Commit
·
69f833d
1
Parent(s):
f555962
init
Browse files- app.py +33 -12
- packages.txt +0 -4
- requirements.txt +0 -14
app.py
CHANGED
@@ -1,22 +1,43 @@
|
|
1 |
import os
|
|
|
|
|
2 |
import gradio as gr
|
|
|
3 |
from pathlib import Path
|
4 |
-
|
5 |
-
|
|
|
6 |
os.system("git clone https://github.com/YangtaoWANG95/TokenCut.git")
|
7 |
os.chdir("TokenCut")
|
8 |
os.system("wget https://raw.githubusercontent.com/YangtaoWANG95/TokenCut/master/examples/VOC07_000064.jpg -O parrot.jpg")
|
9 |
|
10 |
-
def inference(img):
|
11 |
-
os.system("python main_tokencut.py --image_path "+img+" --visualize all --resize 480")
|
12 |
-
filename = Path(img).stem
|
13 |
-
return "./outputs/TokenCut-vit_small16_k/"+filename+"_TokenCut_attn.jpg","./outputs/TokenCut-vit_small16_k/"+filename+"_TokenCut_pred.jpg"
|
14 |
-
|
15 |
-
title="TokenCut"
|
16 |
-
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. We resize the smaller edge of the image to 480 to accelerate inference time. Read more at the links below"
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
|
|
|
|
|
1 |
import os
|
2 |
+
import requests
|
3 |
+
import pandas as pd
|
4 |
import gradio as gr
|
5 |
+
from huggingface_hub.hf_api import SpaceInfo
|
6 |
from pathlib import Path
|
7 |
+
|
8 |
+
|
9 |
+
path = f"https://huggingface.co/api/spaces"
|
10 |
os.system("git clone https://github.com/YangtaoWANG95/TokenCut.git")
|
11 |
os.chdir("TokenCut")
|
12 |
os.system("wget https://raw.githubusercontent.com/YangtaoWANG95/TokenCut/master/examples/VOC07_000064.jpg -O parrot.jpg")
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
|
16 |
+
def get_blocks_party_spaces():
|
17 |
+
r = requests.get(path)
|
18 |
+
d = r.json()
|
19 |
+
spaces = [SpaceInfo(**x) for x in d]
|
20 |
+
blocks_spaces = {}
|
21 |
+
for i in range(0,len(spaces)):
|
22 |
+
if spaces[i].id.split('/')[0] == 'CVPR' and hasattr(spaces[i], 'likes') and spaces[i].id != 'CVPR/Leaderboard' and spaces[i].id != 'CVPR/README':
|
23 |
+
blocks_spaces[spaces[i].id]=spaces[i].likes
|
24 |
+
df = pd.DataFrame(
|
25 |
+
[{"Spaces_Name": Spaces, "likes": likes} for Spaces,likes in blocks_spaces.items()])
|
26 |
+
df = df.sort_values(by=['likes'],ascending=False)
|
27 |
+
return df
|
28 |
+
|
29 |
+
|
30 |
+
block = gr.Blocks()
|
31 |
|
32 |
+
with block:
|
33 |
+
gr.Markdown("""Leaderboard for the most popular CVPR Spaces. To learn more and join, see <a href="https://huggingface.co/CVPR" target="_blank" style="text-decoration: underline">CVPR Event</a>""")
|
34 |
+
with gr.Tabs():
|
35 |
+
with gr.TabItem("CVPR Leaderboard"):
|
36 |
+
with gr.Row():
|
37 |
+
data = gr.outputs.Dataframe(type="pandas")
|
38 |
+
with gr.Row():
|
39 |
+
data_run = gr.Button("Refresh")
|
40 |
+
data_run.click(get_blocks_party_spaces, inputs=None, outputs=data)
|
41 |
|
42 |
+
block.load(get_blocks_party_spaces, inputs=None, outputs=data)
|
43 |
+
block.launch()
|
packages.txt
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
ffmpeg
|
2 |
-
libsm6
|
3 |
-
libxext6
|
4 |
-
|
|
|
|
|
|
|
|
|
|
requirements.txt
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
torch
|
2 |
-
torchvision
|
3 |
-
scipy>=1.5.0
|
4 |
-
matplotlib>=3.2.2
|
5 |
-
opencv-python>=4.1.2
|
6 |
-
tqdm>=4.41.0
|
7 |
-
scikit-image
|
8 |
-
catalyst
|
9 |
-
scikit-learn
|
10 |
-
pycocotools
|
11 |
-
matplotlib
|
12 |
-
pandas
|
13 |
-
timm==0.3.2
|
14 |
-
tensorboard
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|