Spaces:
Runtime error
Runtime error
katielink
commited on
Commit
•
3c2822a
0
Parent(s):
Duplicate from hf-ml4h/biomedical-language-models
Browse files- .gitattributes +34 -0
- README.md +13 -0
- __pycache__/model_list.cpython-311.pyc +0 -0
- app.py +92 -0
- model_list.py +89 -0
- requirements.txt +2 -0
- style.css +20 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt 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 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Explore Biomedical Language Models
|
3 |
+
emoji: 🗺️
|
4 |
+
colorFrom: indigo
|
5 |
+
colorTo: green
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.19.1
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
duplicated_from: hf-ml4h/biomedical-language-models
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
__pycache__/model_list.cpython-311.pyc
ADDED
Binary file (5.52 kB). View file
|
|
app.py
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 = '# Explore 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 |
+
|
27 |
+
case_sensitive = gr.Checkbox(label='Case Sensitive')
|
28 |
+
|
29 |
+
filter_names = gr.CheckboxGroup(choices=[
|
30 |
+
'Paper',
|
31 |
+
'Code',
|
32 |
+
'Model Weights',
|
33 |
+
], label='Filter')
|
34 |
+
|
35 |
+
data_type_names = [
|
36 |
+
'Biomedical',
|
37 |
+
'Clinical',
|
38 |
+
'Scientific',
|
39 |
+
]
|
40 |
+
|
41 |
+
data_types = gr.CheckboxGroup(choices=data_type_names,
|
42 |
+
value=data_type_names,
|
43 |
+
label='Training Data Type(s)')
|
44 |
+
|
45 |
+
search_button = gr.Button('Search')
|
46 |
+
|
47 |
+
number_of_models = gr.Textbox(label='Number of Models Found')
|
48 |
+
table = gr.HTML(show_label=False)
|
49 |
+
|
50 |
+
gr.Markdown(NOTES)
|
51 |
+
gr.Markdown(FOOTER)
|
52 |
+
|
53 |
+
demo.load(fn=model_list.render,
|
54 |
+
inputs=[
|
55 |
+
search_box,
|
56 |
+
case_sensitive,
|
57 |
+
filter_names,
|
58 |
+
data_types,
|
59 |
+
],
|
60 |
+
outputs=[
|
61 |
+
number_of_models,
|
62 |
+
table,
|
63 |
+
])
|
64 |
+
search_box.submit(fn=model_list.render,
|
65 |
+
inputs=[
|
66 |
+
search_box,
|
67 |
+
case_sensitive,
|
68 |
+
filter_names,
|
69 |
+
data_types,
|
70 |
+
],
|
71 |
+
outputs=[
|
72 |
+
number_of_models,
|
73 |
+
table,
|
74 |
+
])
|
75 |
+
|
76 |
+
search_button.click(fn=model_list.render,
|
77 |
+
inputs=[
|
78 |
+
search_box,
|
79 |
+
case_sensitive,
|
80 |
+
filter_names,
|
81 |
+
data_types,
|
82 |
+
],
|
83 |
+
outputs=[
|
84 |
+
number_of_models,
|
85 |
+
table,
|
86 |
+
])
|
87 |
+
|
88 |
+
demo.launch(enable_queue=True, share=False)
|
89 |
+
|
90 |
+
|
91 |
+
if __name__ == '__main__':
|
92 |
+
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="20%">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,
|
54 |
+
case_sensitive: bool,
|
55 |
+
filter_names: list[str],
|
56 |
+
data_types: list[str]) -> tuple[int, str]:
|
57 |
+
df = self.table
|
58 |
+
if search_query:
|
59 |
+
if case_sensitive:
|
60 |
+
df = df[df.name.str.contains(search_query)]
|
61 |
+
else:
|
62 |
+
df = df[df.name_lowercase.str.contains(search_query.lower())]
|
63 |
+
has_paper = 'Paper' in filter_names
|
64 |
+
has_github = 'Code' in filter_names
|
65 |
+
has_model = 'Model Weights' in filter_names
|
66 |
+
df = self.filter_table(df, has_paper, has_github, has_model, data_types)
|
67 |
+
return len(df), self.to_html(df, self.table_header)
|
68 |
+
|
69 |
+
@staticmethod
|
70 |
+
def filter_table(df: pd.DataFrame, has_paper: bool, has_github: bool,
|
71 |
+
has_model: bool, 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 |
+
|