Spaces:
Running
Running
Add filter for links
Browse files
app.py
CHANGED
@@ -16,9 +16,21 @@ def main():
|
|
16 |
|
17 |
with gr.Blocks(css='style.css') as demo:
|
18 |
gr.Markdown(DESCRIPTION)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
table = gr.HTML(html_text, show_label=False)
|
20 |
gr.Markdown(FOOTER)
|
21 |
|
|
|
|
|
|
|
|
|
|
|
22 |
demo.launch(enable_queue=True, share=False)
|
23 |
|
24 |
|
|
|
16 |
|
17 |
with gr.Blocks(css='style.css') as demo:
|
18 |
gr.Markdown(DESCRIPTION)
|
19 |
+
names_with_link = gr.CheckboxGroup(choices=[
|
20 |
+
'Supp',
|
21 |
+
'arXiv',
|
22 |
+
'GitHub',
|
23 |
+
'HF Space',
|
24 |
+
],
|
25 |
+
label='With')
|
26 |
table = gr.HTML(html_text, show_label=False)
|
27 |
gr.Markdown(FOOTER)
|
28 |
|
29 |
+
demo.load(paper_list.render, inputs=names_with_link, outputs=table)
|
30 |
+
names_with_link.change(paper_list.render,
|
31 |
+
inputs=names_with_link,
|
32 |
+
outputs=table)
|
33 |
+
|
34 |
demo.launch(enable_queue=True, share=False)
|
35 |
|
36 |
|
papers.py
CHANGED
@@ -5,7 +5,7 @@ import pandas as pd
|
|
5 |
|
6 |
class PaperList:
|
7 |
def __init__(self):
|
8 |
-
self.table = pd.read_csv('papers.csv')
|
9 |
self.table_header = '''
|
10 |
<tr>
|
11 |
<td width="50%">Paper</td>
|
@@ -17,6 +17,27 @@ class PaperList:
|
|
17 |
<td width="5%">Hugging Face Spaces</td>
|
18 |
</tr>'''
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
def to_html(self, df: pd.DataFrame) -> str:
|
21 |
table_rows = self.generate_table_rows(df)
|
22 |
table_data = ''.join(table_rows)
|
@@ -31,10 +52,14 @@ class PaperList:
|
|
31 |
for row in df.itertuples():
|
32 |
paper = f'<a href="{row.url}">{row.title}</a>'
|
33 |
pdf = f'<a href="{row.pdf}">pdf</a>'
|
34 |
-
supp = f'<a href="{row.supp}">supp</a>' if
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
38 |
row = f'''
|
39 |
<tr>
|
40 |
<td>{paper}</td>
|
|
|
5 |
|
6 |
class PaperList:
|
7 |
def __init__(self):
|
8 |
+
self.table = pd.read_csv('papers.csv')
|
9 |
self.table_header = '''
|
10 |
<tr>
|
11 |
<td width="50%">Paper</td>
|
|
|
17 |
<td width="5%">Hugging Face Spaces</td>
|
18 |
</tr>'''
|
19 |
|
20 |
+
def render(self, names_with_link: list[str]) -> str:
|
21 |
+
has_supp = 'Supp' in names_with_link
|
22 |
+
has_arxiv = 'arXiv' in names_with_link
|
23 |
+
has_github = 'GitHub' in names_with_link
|
24 |
+
has_hf_space = 'HF Space' in names_with_link
|
25 |
+
df = self.filter_table(self.table, has_supp, has_arxiv, has_github,
|
26 |
+
has_hf_space)
|
27 |
+
return self.to_html(df)
|
28 |
+
|
29 |
+
def filter_table(self, df: pd.DataFrame, has_supp: bool, has_arxiv: bool,
|
30 |
+
has_github: bool, has_hf_space: bool) -> pd.DataFrame:
|
31 |
+
if has_supp:
|
32 |
+
df = df[~df.supp.isna()]
|
33 |
+
if has_arxiv:
|
34 |
+
df = df[~df.arxiv.isna()]
|
35 |
+
if has_github:
|
36 |
+
df = df[~df.github.isna()]
|
37 |
+
if has_hf_space:
|
38 |
+
df = df[~df.hf_space.isna()]
|
39 |
+
return df
|
40 |
+
|
41 |
def to_html(self, df: pd.DataFrame) -> str:
|
42 |
table_rows = self.generate_table_rows(df)
|
43 |
table_data = ''.join(table_rows)
|
|
|
52 |
for row in df.itertuples():
|
53 |
paper = f'<a href="{row.url}">{row.title}</a>'
|
54 |
pdf = f'<a href="{row.pdf}">pdf</a>'
|
55 |
+
supp = f'<a href="{row.supp}">supp</a>' if isinstance(
|
56 |
+
row.supp, str) else ''
|
57 |
+
arxiv = f'<a href="{row.arxiv}">arXiv</a>' if isinstance(
|
58 |
+
row.arxiv, str) else ''
|
59 |
+
github = f'<a href="{row.github}">GitHub</a>' if isinstance(
|
60 |
+
row.github, str) else ''
|
61 |
+
hf_space = f'<a href="{row.hf_space}">Space</a>' if isinstance(
|
62 |
+
row.hf_space, str) else ''
|
63 |
row = f'''
|
64 |
<tr>
|
65 |
<td>{paper}</td>
|