akhaliq HF staff hysts HF staff commited on
Commit
5092824
0 Parent(s):

Duplicate from ICML2022/ICML2022_papers

Browse files

Co-authored-by: hysts <[email protected]>

Files changed (8) hide show
  1. .gitattributes +28 -0
  2. .pre-commit-config.yaml +35 -0
  3. .style.yapf +5 -0
  4. README.md +13 -0
  5. app.py +70 -0
  6. paper_list.py +122 -0
  7. papers.csv +3 -0
  8. style.css +22 -0
.gitattributes ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.csv filter=lfs diff=lfs merge=lfs -text
2
+ *.7z filter=lfs diff=lfs merge=lfs -text
3
+ *.arrow filter=lfs diff=lfs merge=lfs -text
4
+ *.bin filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.wasm filter=lfs diff=lfs merge=lfs -text
25
+ *.xz filter=lfs diff=lfs merge=lfs -text
26
+ *.zip filter=lfs diff=lfs merge=lfs -text
27
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
28
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
.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 ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: ICML2022 Papers
3
+ emoji: 🦀
4
+ colorFrom: green
5
+ colorTo: gray
6
+ sdk: gradio
7
+ sdk_version: 3.0.24
8
+ app_file: app.py
9
+ pinned: true
10
+ duplicated_from: ICML2022/ICML2022_papers
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = '# ICML 2022 Papers'
10
+ NOTES = '''
11
+ - [ICML 2022](https://icml.cc/Conferences/2022/)
12
+ - [Proceedings](https://proceedings.mlr.press/v162/)
13
+ '''
14
+ FOOTER = '<img id="visitor-badge" alt="visitor badge" src="https://visitor-badge.glitch.me/badge?page_id=hysts.icml2022_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
+ )
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
+ search_button = gr.Button('Search')
38
+
39
+ number_of_papers = gr.Textbox(label='Number of Papers Found')
40
+ table = gr.HTML(show_label=False)
41
+
42
+ gr.Markdown(NOTES)
43
+ gr.Markdown(FOOTER)
44
+
45
+ demo.load(paper_list.render,
46
+ inputs=[
47
+ search_box,
48
+ case_sensitive,
49
+ filter_names,
50
+ ],
51
+ outputs=[
52
+ number_of_papers,
53
+ table,
54
+ ])
55
+ search_button.click(paper_list.render,
56
+ inputs=[
57
+ search_box,
58
+ case_sensitive,
59
+ filter_names,
60
+ ],
61
+ outputs=[
62
+ number_of_papers,
63
+ table,
64
+ ])
65
+
66
+ demo.launch(enable_queue=True, share=False)
67
+
68
+
69
+ if __name__ == '__main__':
70
+ main()
paper_list.py ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = 'ICML2022'
12
+ self.table = pd.read_csv('papers.csv')
13
+ self._preprcess_table()
14
+
15
+ self.table_header = '''
16
+ <tr>
17
+ <td width="50%">Paper</td>
18
+ <td width="26%">Authors</td>
19
+ <td width="4%">pdf</td>
20
+ <td width="4%">arXiv</td>
21
+ <td width="4%">GitHub</td>
22
+ <td width="4%">HF Spaces</td>
23
+ <td width="4%">HF Models</td>
24
+ <td width="4%">HF Datasets</td>
25
+ </tr>'''
26
+
27
+ @staticmethod
28
+ def load_space_info(author: str) -> list[SpaceInfo]:
29
+ path = 'https://huggingface.co/api/spaces'
30
+ r = requests.get(path, params={'author': author})
31
+ d = r.json()
32
+ return [SpaceInfo(**x) for x in d]
33
+
34
+ def add_spaces_to_table(self, organization_name: str,
35
+ df: pd.DataFrame) -> pd.DataFrame:
36
+ spaces = self.load_space_info(organization_name)
37
+ name2space = {
38
+ s.id.split('/')[1].lower(): f'https://huggingface.co/spaces/{s.id}'
39
+ for s in spaces
40
+ }
41
+ df['hf_space'] = df.loc[:, ['hf_space', 'github']].apply(
42
+ lambda x: x[0] if isinstance(x[0], str) else name2space.get(
43
+ x[1].split('/')[-1].lower()
44
+ if isinstance(x[1], str) else '', np.nan),
45
+ axis=1)
46
+ return df
47
+
48
+ def _preprcess_table(self) -> None:
49
+ self.table = self.add_spaces_to_table(self.organization_name,
50
+ self.table)
51
+ self.table['title_lowercase'] = self.table.title.str.lower()
52
+
53
+ rows = []
54
+ for row in self.table.itertuples():
55
+ paper = f'<a href="{row.url}" target="_blank">{row.title}</a>'
56
+ pdf = f'<a href="{row.pdf}" target="_blank">pdf</a>'
57
+ arxiv = f'<a href="{row.arxiv}" target="_blank">arXiv</a>' if isinstance(
58
+ row.arxiv, str) else ''
59
+ github = f'<a href="{row.github}" target="_blank">GitHub</a>' if isinstance(
60
+ row.github, str) else ''
61
+ hf_space = f'<a href="{row.hf_space}" target="_blank">Space</a>' if isinstance(
62
+ row.hf_space, str) else ''
63
+ hf_model = f'<a href="{row.hf_model}" target="_blank">Model</a>' if isinstance(
64
+ row.hf_model, str) else ''
65
+ hf_dataset = f'<a href="{row.hf_dataset}" target="_blank">Dataset</a>' if isinstance(
66
+ row.hf_dataset, str) else ''
67
+ row = f'''
68
+ <tr>
69
+ <td>{paper}</td>
70
+ <td>{row.authors}</td>
71
+ <td>{pdf}</td>
72
+ <td>{arxiv}</td>
73
+ <td>{github}</td>
74
+ <td>{hf_space}</td>
75
+ <td>{hf_model}</td>
76
+ <td>{hf_dataset}</td>
77
+ </tr>'''
78
+ rows.append(row)
79
+ self.table['html_table_content'] = rows
80
+
81
+ def render(self, search_query: str, case_sensitive: bool,
82
+ filter_names: list[str]) -> tuple[int, str]:
83
+ df = self.add_spaces_to_table(self.organization_name, self.table)
84
+ if search_query:
85
+ if case_sensitive:
86
+ df = df[df.title.str.contains(search_query)]
87
+ else:
88
+ df = df[df.title_lowercase.str.contains(search_query.lower())]
89
+ has_arxiv = 'arXiv' in filter_names
90
+ has_github = 'GitHub' in filter_names
91
+ has_hf_space = 'HF Space' in filter_names
92
+ has_hf_model = 'HF Model' in filter_names
93
+ has_hf_dataset = 'HF Dataset' in filter_names
94
+ df = self.filter_table(df, has_arxiv, has_github, has_hf_space,
95
+ has_hf_model, has_hf_dataset)
96
+ return len(df), self.to_html(df, self.table_header)
97
+
98
+ @staticmethod
99
+ def filter_table(df: pd.DataFrame, has_arxiv: bool, has_github: bool,
100
+ has_hf_space: bool, has_hf_model: bool,
101
+ has_hf_dataset: bool) -> pd.DataFrame:
102
+ if has_arxiv:
103
+ df = df[~df.arxiv.isna()]
104
+ if has_github:
105
+ df = df[~df.github.isna()]
106
+ if has_hf_space:
107
+ df = df[~df.hf_space.isna()]
108
+ if has_hf_model:
109
+ df = df[~df.hf_model.isna()]
110
+ if has_hf_dataset:
111
+ df = df[~df.hf_dataset.isna()]
112
+ return df
113
+
114
+ @staticmethod
115
+ def to_html(df: pd.DataFrame, table_header: str) -> str:
116
+ table_data = ''.join(df.html_table_content)
117
+ html = f'''
118
+ <table>
119
+ {table_header}
120
+ {table_data}
121
+ </table>'''
122
+ return html
papers.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ddf0077cfd7ce2b23ad1813e47fc3f3efcdeefb25d50447d51da9e3bdea6e3f4
3
+ size 335527
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
+ }