Spaces:
Runtime error
Runtime error
Add basic app based on ECCV
Browse files- __pycache__/model_list.cpython-311.pyc +0 -0
- app.py +90 -0
- model_list.py +89 -0
- requirements.txt +2 -0
- style.css +20 -0
__pycache__/model_list.cpython-311.pyc
ADDED
|
Binary file (5.55 kB). View file
|
|
|
app.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import gradio as gr
|
| 6 |
+
|
| 7 |
+
from model_list import ModelList
|
| 8 |
+
|
| 9 |
+
DESCRIPTION = '# Clinical & Biomedical Language Models'
|
| 10 |
+
NOTES = '''
|
| 11 |
+
- Stanford HAI Article, ["The Shaky Foundations of Foundation Models in Healthcare"](https://hai.stanford.edu/news/shaky-foundations-foundation-models-healthcare)
|
| 12 |
+
'''
|
| 13 |
+
FOOTER = ''''''
|
| 14 |
+
|
| 15 |
+
def main():
|
| 16 |
+
model_list = ModelList()
|
| 17 |
+
|
| 18 |
+
with gr.Blocks(css='style.css') as demo:
|
| 19 |
+
gr.Markdown(DESCRIPTION)
|
| 20 |
+
|
| 21 |
+
search_box = gr.Textbox(
|
| 22 |
+
label='Search Model Name',
|
| 23 |
+
placeholder=
|
| 24 |
+
'You can search for titles with regular expressions. e.g. (?<!sur)face',
|
| 25 |
+
max_lines=1)
|
| 26 |
+
case_sensitive = gr.Checkbox(label='Case Sensitive')
|
| 27 |
+
filter_names = gr.CheckboxGroup(choices=[
|
| 28 |
+
'Paper',
|
| 29 |
+
'Code',
|
| 30 |
+
'Model Weights',
|
| 31 |
+
], label='Filter')
|
| 32 |
+
|
| 33 |
+
data_type_names = [
|
| 34 |
+
'Biomedical',
|
| 35 |
+
'Clinical',
|
| 36 |
+
'Scientific',
|
| 37 |
+
]
|
| 38 |
+
|
| 39 |
+
# prev: paper_sessions
|
| 40 |
+
data_types = gr.CheckboxGroup(choices=data_type_names,
|
| 41 |
+
value=data_type_names,
|
| 42 |
+
label='Training Data Type(s)')
|
| 43 |
+
search_button = gr.Button('Search')
|
| 44 |
+
|
| 45 |
+
number_of_models = gr.Textbox(label='Number of Models Found')
|
| 46 |
+
table = gr.HTML(show_label=False)
|
| 47 |
+
|
| 48 |
+
gr.Markdown(NOTES)
|
| 49 |
+
gr.Markdown(FOOTER)
|
| 50 |
+
|
| 51 |
+
demo.load(fn=model_list.render,
|
| 52 |
+
inputs=[
|
| 53 |
+
search_box,
|
| 54 |
+
case_sensitive,
|
| 55 |
+
filter_names,
|
| 56 |
+
data_types,
|
| 57 |
+
],
|
| 58 |
+
outputs=[
|
| 59 |
+
number_of_models,
|
| 60 |
+
table,
|
| 61 |
+
])
|
| 62 |
+
search_box.submit(fn=model_list.render,
|
| 63 |
+
inputs=[
|
| 64 |
+
search_box,
|
| 65 |
+
case_sensitive,
|
| 66 |
+
filter_names,
|
| 67 |
+
data_types,
|
| 68 |
+
],
|
| 69 |
+
outputs=[
|
| 70 |
+
number_of_models,
|
| 71 |
+
table,
|
| 72 |
+
])
|
| 73 |
+
|
| 74 |
+
search_button.click(fn=model_list.render,
|
| 75 |
+
inputs=[
|
| 76 |
+
search_box,
|
| 77 |
+
case_sensitive,
|
| 78 |
+
filter_names,
|
| 79 |
+
data_types,
|
| 80 |
+
],
|
| 81 |
+
outputs=[
|
| 82 |
+
number_of_models,
|
| 83 |
+
table,
|
| 84 |
+
])
|
| 85 |
+
|
| 86 |
+
demo.launch(enable_queue=True, share=False)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
if __name__ == '__main__':
|
| 90 |
+
main()
|
model_list.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
url = 'https://docs.google.com/spreadsheets/d/1fANyV8spnEGUBMevjnb1FupkbESq9lTM2CGQt413sXQ/edit#gid=874079331'
|
| 9 |
+
csv_url = url.replace('/edit#gid=', '/export?format=csv&gid=')
|
| 10 |
+
|
| 11 |
+
class ModelList:
|
| 12 |
+
def __init__(self):
|
| 13 |
+
self.table = pd.read_csv(csv_url)
|
| 14 |
+
self._preprocess_table()
|
| 15 |
+
|
| 16 |
+
self.table_header = '''
|
| 17 |
+
<tr>
|
| 18 |
+
<td width="40%">Model Name</td>
|
| 19 |
+
<td width="10%">Data Type(s)</td>
|
| 20 |
+
<td width="10%">Year Published</td>
|
| 21 |
+
<td width="10%">Paper</td>
|
| 22 |
+
<td width="10%">Code on Github</td>
|
| 23 |
+
<td width="10%">Weights on 🤗</td>
|
| 24 |
+
<td width="10%">Other Weights</td>
|
| 25 |
+
</tr>'''
|
| 26 |
+
|
| 27 |
+
def _preprocess_table(self) -> None:
|
| 28 |
+
self.table['name_lowercase'] = self.table.name.str.lower()
|
| 29 |
+
|
| 30 |
+
rows = []
|
| 31 |
+
for row in self.table.itertuples():
|
| 32 |
+
paper = f'<a href="{row.paper}" target="_blank">Paper</a>' if isinstance(
|
| 33 |
+
row.paper, str) else ''
|
| 34 |
+
github = f'<a href="{row.github}" target="_blank">GitHub</a>' if isinstance(
|
| 35 |
+
row.github, str) else ''
|
| 36 |
+
hf_model = f'<a href="{row.hub}" target="_blank">Hub Model</a>' if isinstance(
|
| 37 |
+
row.hub, str) else ''
|
| 38 |
+
other_model = f'<a href="{row.other}" target="_blank">Other Weights</a>' if isinstance(
|
| 39 |
+
row.other, str) else ''
|
| 40 |
+
row = f'''
|
| 41 |
+
<tr>
|
| 42 |
+
<td>{row.name}</td>
|
| 43 |
+
<td>{row.type}</td>
|
| 44 |
+
<td>{row.year}</td>
|
| 45 |
+
<td>{paper}</td>
|
| 46 |
+
<td>{github}</td>
|
| 47 |
+
<td>{hf_model}</td>
|
| 48 |
+
<td>{other_model}</td>
|
| 49 |
+
</tr>'''
|
| 50 |
+
rows.append(row)
|
| 51 |
+
self.table['html_table_content'] = rows
|
| 52 |
+
|
| 53 |
+
def render(self, search_query: str, case_sensitive: bool,
|
| 54 |
+
filter_names: list[str],
|
| 55 |
+
data_types: list[str]) -> tuple[int, str]:
|
| 56 |
+
df = self.table
|
| 57 |
+
if search_query:
|
| 58 |
+
if case_sensitive:
|
| 59 |
+
df = df[df.name.str.contains(search_query)]
|
| 60 |
+
else:
|
| 61 |
+
df = df[df.name_lowercase.str.contains(search_query.lower())]
|
| 62 |
+
has_paper = 'Paper' in filter_names
|
| 63 |
+
has_github = 'Github' in filter_names
|
| 64 |
+
has_model = 'Hub Model' in filter_names or 'Other Weights' in filter_names
|
| 65 |
+
df = self.filter_table(df, has_paper, has_github, has_model, data_types)
|
| 66 |
+
return len(df), self.to_html(df, self.table_header)
|
| 67 |
+
|
| 68 |
+
@staticmethod
|
| 69 |
+
def filter_table(df: pd.DataFrame, has_paper: bool, has_github: bool,
|
| 70 |
+
has_model: bool,
|
| 71 |
+
data_types: list[str]) -> pd.DataFrame:
|
| 72 |
+
if has_paper:
|
| 73 |
+
df = df[~df.paper.isna()]
|
| 74 |
+
if has_github:
|
| 75 |
+
df = df[~df.github.isna()]
|
| 76 |
+
if has_model:
|
| 77 |
+
df = df[~df.hub.isna() | ~df.other.isna()]
|
| 78 |
+
df = df[df.type.isin(set(data_types))]
|
| 79 |
+
return df
|
| 80 |
+
|
| 81 |
+
@staticmethod
|
| 82 |
+
def to_html(df: pd.DataFrame, table_header: str) -> str:
|
| 83 |
+
table_data = ''.join(df.html_table_content)
|
| 84 |
+
html = f'''
|
| 85 |
+
<table>
|
| 86 |
+
{table_header}
|
| 87 |
+
{table_data}
|
| 88 |
+
</table>'''
|
| 89 |
+
return html
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
pandas
|
style.css
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 20 |
+
|