Spaces:
Running
Running
hysts
commited on
Commit
•
0702f61
1
Parent(s):
c5f73de
Add files
Browse files- .pre-commit-config.yaml +35 -0
- .style.yapf +5 -0
- README.md +1 -1
- app.py +91 -0
- paper_list.py +129 -0
- papers.csv +0 -0
- style.css +22 -0
.pre-commit-config.yaml
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
repos:
|
2 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
3 |
+
rev: v4.2.0
|
4 |
+
hooks:
|
5 |
+
- id: check-executables-have-shebangs
|
6 |
+
- id: check-json
|
7 |
+
- id: check-merge-conflict
|
8 |
+
- id: check-shebang-scripts-are-executable
|
9 |
+
- id: check-toml
|
10 |
+
- id: check-yaml
|
11 |
+
- id: double-quote-string-fixer
|
12 |
+
- id: end-of-file-fixer
|
13 |
+
- id: mixed-line-ending
|
14 |
+
args: ['--fix=lf']
|
15 |
+
- id: requirements-txt-fixer
|
16 |
+
- id: trailing-whitespace
|
17 |
+
- repo: https://github.com/myint/docformatter
|
18 |
+
rev: v1.4
|
19 |
+
hooks:
|
20 |
+
- id: docformatter
|
21 |
+
args: ['--in-place']
|
22 |
+
- repo: https://github.com/pycqa/isort
|
23 |
+
rev: 5.10.1
|
24 |
+
hooks:
|
25 |
+
- id: isort
|
26 |
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
27 |
+
rev: v0.812
|
28 |
+
hooks:
|
29 |
+
- id: mypy
|
30 |
+
args: ['--ignore-missing-imports']
|
31 |
+
- repo: https://github.com/google/yapf
|
32 |
+
rev: v0.32.0
|
33 |
+
hooks:
|
34 |
+
- id: yapf
|
35 |
+
args: ['--parallel', '--in-place']
|
.style.yapf
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[style]
|
2 |
+
based_on_style = pep8
|
3 |
+
blank_line_before_nested_class_or_def = false
|
4 |
+
spaces_before_comment = 2
|
5 |
+
split_before_logical_operator = true
|
README.md
CHANGED
@@ -6,7 +6,7 @@ colorTo: indigo
|
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.1.7
|
8 |
app_file: app.py
|
9 |
-
pinned:
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.1.7
|
8 |
app_file: app.py
|
9 |
+
pinned: true
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
|
3 |
+
from __future__ import annotations
|
4 |
+
|
5 |
+
import gradio as gr
|
6 |
+
|
7 |
+
from paper_list import PaperList
|
8 |
+
|
9 |
+
DESCRIPTION = '# ECCV 2022 Papers'
|
10 |
+
NOTES = '''
|
11 |
+
- [ECCV 2022](https://eccv2022.ecva.net/)
|
12 |
+
- [List of accepted papers](https://docs.google.com/spreadsheets/d/1PvvnVAuG9TDov1rBQcLhH5noIM4INTfLhKwrk6ESDFU/edit?usp=sharing)
|
13 |
+
'''
|
14 |
+
FOOTER = '<img id="visitor-badge" alt="visitor badge" src="https://visitor-badge.glitch.me/badge?page_id=hysts.eccv2022_papers" />'
|
15 |
+
|
16 |
+
|
17 |
+
def main():
|
18 |
+
paper_list = PaperList()
|
19 |
+
|
20 |
+
with gr.Blocks(css='style.css') as demo:
|
21 |
+
gr.Markdown(DESCRIPTION)
|
22 |
+
|
23 |
+
search_box = gr.Textbox(
|
24 |
+
label='Search Title',
|
25 |
+
placeholder=
|
26 |
+
'You can search for titles with regular expressions. e.g. (?<!sur)face',
|
27 |
+
max_lines=1)
|
28 |
+
case_sensitive = gr.Checkbox(label='Case Sensitive')
|
29 |
+
filter_names = gr.CheckboxGroup(choices=[
|
30 |
+
'arXiv',
|
31 |
+
'GitHub',
|
32 |
+
'HF Space',
|
33 |
+
'HF Model',
|
34 |
+
'HF Dataset',
|
35 |
+
],
|
36 |
+
label='Filter')
|
37 |
+
session_names = [
|
38 |
+
'Oral',
|
39 |
+
'Poster',
|
40 |
+
]
|
41 |
+
paper_sessions = gr.CheckboxGroup(choices=session_names,
|
42 |
+
value=session_names,
|
43 |
+
label='Session')
|
44 |
+
search_button = gr.Button('Search')
|
45 |
+
|
46 |
+
number_of_papers = gr.Textbox(label='Number of Papers Found')
|
47 |
+
table = gr.HTML(show_label=False)
|
48 |
+
|
49 |
+
gr.Markdown(NOTES)
|
50 |
+
gr.Markdown(FOOTER)
|
51 |
+
|
52 |
+
demo.load(fn=paper_list.render,
|
53 |
+
inputs=[
|
54 |
+
search_box,
|
55 |
+
case_sensitive,
|
56 |
+
filter_names,
|
57 |
+
paper_sessions,
|
58 |
+
],
|
59 |
+
outputs=[
|
60 |
+
number_of_papers,
|
61 |
+
table,
|
62 |
+
])
|
63 |
+
search_box.submit(fn=paper_list.render,
|
64 |
+
inputs=[
|
65 |
+
search_box,
|
66 |
+
case_sensitive,
|
67 |
+
filter_names,
|
68 |
+
paper_sessions,
|
69 |
+
],
|
70 |
+
outputs=[
|
71 |
+
number_of_papers,
|
72 |
+
table,
|
73 |
+
])
|
74 |
+
|
75 |
+
search_button.click(fn=paper_list.render,
|
76 |
+
inputs=[
|
77 |
+
search_box,
|
78 |
+
case_sensitive,
|
79 |
+
filter_names,
|
80 |
+
paper_sessions,
|
81 |
+
],
|
82 |
+
outputs=[
|
83 |
+
number_of_papers,
|
84 |
+
table,
|
85 |
+
])
|
86 |
+
|
87 |
+
demo.launch(enable_queue=True, share=False)
|
88 |
+
|
89 |
+
|
90 |
+
if __name__ == '__main__':
|
91 |
+
main()
|
paper_list.py
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import annotations
|
2 |
+
|
3 |
+
import numpy as np
|
4 |
+
import pandas as pd
|
5 |
+
import requests
|
6 |
+
from huggingface_hub.hf_api import SpaceInfo
|
7 |
+
|
8 |
+
|
9 |
+
class PaperList:
|
10 |
+
def __init__(self):
|
11 |
+
self.organization_name = 'ECCV2022'
|
12 |
+
self.table = pd.read_csv('papers.csv')
|
13 |
+
self._preprcess_table()
|
14 |
+
|
15 |
+
self.table_header = '''
|
16 |
+
<tr>
|
17 |
+
<td width="50%">Paper Title</td>
|
18 |
+
<td width="22%">Authors</td>
|
19 |
+
<td width="4%">pdf</td>
|
20 |
+
<td width="4%">Session</td>
|
21 |
+
<td width="4%">arXiv</td>
|
22 |
+
<td width="4%">GitHub</td>
|
23 |
+
<td width="4%">HF Spaces</td>
|
24 |
+
<td width="4%">HF Models</td>
|
25 |
+
<td width="4%">HF Datasets</td>
|
26 |
+
</tr>'''
|
27 |
+
|
28 |
+
@staticmethod
|
29 |
+
def load_space_info(author: str) -> list[SpaceInfo]:
|
30 |
+
path = 'https://huggingface.co/api/spaces'
|
31 |
+
r = requests.get(path, params={'author': author})
|
32 |
+
d = r.json()
|
33 |
+
return [SpaceInfo(**x) for x in d]
|
34 |
+
|
35 |
+
def add_spaces_to_table(self, organization_name: str,
|
36 |
+
df: pd.DataFrame) -> pd.DataFrame:
|
37 |
+
spaces = self.load_space_info(organization_name)
|
38 |
+
name2space = {
|
39 |
+
s.id.split('/')[1].lower(): f'https://huggingface.co/spaces/{s.id}'
|
40 |
+
for s in spaces
|
41 |
+
}
|
42 |
+
df['hf_space'] = df.loc[:, ['hf_space', 'github']].apply(
|
43 |
+
lambda x: x[0] if isinstance(x[0], str) else name2space.get(
|
44 |
+
x[1].split('/')[-1].lower()
|
45 |
+
if isinstance(x[1], str) else '', np.nan),
|
46 |
+
axis=1)
|
47 |
+
return df
|
48 |
+
|
49 |
+
def _preprcess_table(self) -> None:
|
50 |
+
self.table = self.add_spaces_to_table(self.organization_name,
|
51 |
+
self.table)
|
52 |
+
self.table['title_lowercase'] = self.table.title.str.lower()
|
53 |
+
|
54 |
+
rows = []
|
55 |
+
for row in self.table.itertuples():
|
56 |
+
paper = f'<a href="{row.url}" target="_blank">{row.title}</a>' if isinstance(
|
57 |
+
row.url, str) else row.title
|
58 |
+
pdf = f'<a href="{row.pdf}" target="_blank">pdf</a>' if isinstance(
|
59 |
+
row.pdf, str) else ''
|
60 |
+
arxiv = f'<a href="{row.arxiv}" target="_blank">arXiv</a>' if isinstance(
|
61 |
+
row.arxiv, str) else ''
|
62 |
+
github = f'<a href="{row.github}" target="_blank">GitHub</a>' if isinstance(
|
63 |
+
row.github, str) else ''
|
64 |
+
hf_space = f'<a href="{row.hf_space}" target="_blank">Space</a>' if isinstance(
|
65 |
+
row.hf_space, str) else ''
|
66 |
+
hf_model = f'<a href="{row.hf_model}" target="_blank">Model</a>' if isinstance(
|
67 |
+
row.hf_model, str) else ''
|
68 |
+
hf_dataset = f'<a href="{row.hf_dataset}" target="_blank">Dataset</a>' if isinstance(
|
69 |
+
row.hf_dataset, str) else ''
|
70 |
+
row = f'''
|
71 |
+
<tr>
|
72 |
+
<td>{paper}</td>
|
73 |
+
<td>{row.authors}</td>
|
74 |
+
<td>{pdf}</td>
|
75 |
+
<td>{row.session}</td>
|
76 |
+
<td>{arxiv}</td>
|
77 |
+
<td>{github}</td>
|
78 |
+
<td>{hf_space}</td>
|
79 |
+
<td>{hf_model}</td>
|
80 |
+
<td>{hf_dataset}</td>
|
81 |
+
</tr>'''
|
82 |
+
rows.append(row)
|
83 |
+
self.table['html_table_content'] = rows
|
84 |
+
|
85 |
+
def render(self, search_query: str, case_sensitive: bool,
|
86 |
+
filter_names: list[str],
|
87 |
+
paper_sessions: list[str]) -> tuple[int, str]:
|
88 |
+
df = self.add_spaces_to_table(self.organization_name, self.table)
|
89 |
+
if search_query:
|
90 |
+
if case_sensitive:
|
91 |
+
df = df[df.title.str.contains(search_query)]
|
92 |
+
else:
|
93 |
+
df = df[df.title_lowercase.str.contains(search_query.lower())]
|
94 |
+
has_arxiv = 'arXiv' in filter_names
|
95 |
+
has_github = 'GitHub' in filter_names
|
96 |
+
has_hf_space = 'HF Space' in filter_names
|
97 |
+
has_hf_model = 'HF Model' in filter_names
|
98 |
+
has_hf_dataset = 'HF Dataset' in filter_names
|
99 |
+
df = self.filter_table(df, has_arxiv, has_github, has_hf_space,
|
100 |
+
has_hf_model, has_hf_dataset, paper_sessions)
|
101 |
+
return len(df), self.to_html(df, self.table_header)
|
102 |
+
|
103 |
+
@staticmethod
|
104 |
+
def filter_table(df: pd.DataFrame, has_arxiv: bool, has_github: bool,
|
105 |
+
has_hf_space: bool, has_hf_model: bool,
|
106 |
+
has_hf_dataset: bool,
|
107 |
+
paper_sessions: list[str]) -> pd.DataFrame:
|
108 |
+
if has_arxiv:
|
109 |
+
df = df[~df.arxiv.isna()]
|
110 |
+
if has_github:
|
111 |
+
df = df[~df.github.isna()]
|
112 |
+
if has_hf_space:
|
113 |
+
df = df[~df.hf_space.isna()]
|
114 |
+
if has_hf_model:
|
115 |
+
df = df[~df.hf_model.isna()]
|
116 |
+
if has_hf_dataset:
|
117 |
+
df = df[~df.hf_dataset.isna()]
|
118 |
+
df = df[df.session.isin(set(paper_sessions))]
|
119 |
+
return df
|
120 |
+
|
121 |
+
@staticmethod
|
122 |
+
def to_html(df: pd.DataFrame, table_header: str) -> str:
|
123 |
+
table_data = ''.join(df.html_table_content)
|
124 |
+
html = f'''
|
125 |
+
<table>
|
126 |
+
{table_header}
|
127 |
+
{table_data}
|
128 |
+
</table>'''
|
129 |
+
return html
|
papers.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
style.css
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
h1 {
|
2 |
+
text-align: center;
|
3 |
+
}
|
4 |
+
table a {
|
5 |
+
background-color: transparent;
|
6 |
+
color: #58a6ff;
|
7 |
+
text-decoration: none;
|
8 |
+
}
|
9 |
+
a:active,
|
10 |
+
a:hover {
|
11 |
+
outline-width: 0;
|
12 |
+
}
|
13 |
+
a:hover {
|
14 |
+
text-decoration: underline;
|
15 |
+
}
|
16 |
+
table, th, td {
|
17 |
+
border: 1px solid;
|
18 |
+
}
|
19 |
+
img#visitor-badge {
|
20 |
+
display: block;
|
21 |
+
margin: auto;
|
22 |
+
}
|