Spaces:
Sleeping
Sleeping
Version demo ready
Browse files- 1_π_form.py +72 -84
- current_card.md +55 -196
- middleMan.py +36 -24
- pages/1_π_Technical_Specifications.py +8 -7
- pages/2_ποΈββοΈ_Model_training.py +4 -2
1_π_form.py
CHANGED
@@ -9,6 +9,7 @@ from huggingface_hub import hf_hub_download, upload_file
|
|
9 |
import pandas as pd
|
10 |
from huggingface_hub import create_repo
|
11 |
import os
|
|
|
12 |
from middleMan import parse_into_jinja_markdown as pj
|
13 |
|
14 |
import requests
|
@@ -95,6 +96,27 @@ def card_upload(card_info,repo_id,token):
|
|
95 |
)
|
96 |
return url
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
def validate(self, repo_type="model"):
|
99 |
"""Validates card against Hugging Face Hub's model card validation logic.
|
100 |
Using this function requires access to the internet, so it is only called
|
@@ -134,84 +156,55 @@ def validate(self, repo_type="model"):
|
|
134 |
|
135 |
## Save uploaded [markdown] file to directory to be used by jinja parser function
|
136 |
def save_uploadedfile(uploadedfile):
|
137 |
-
with open(
|
138 |
f.write(uploadedfile.getbuffer())
|
139 |
st.success("Saved File:{} to temp_uploaded_filed_Dir".format(uploadedfile.name))
|
140 |
return uploadedfile.name
|
141 |
|
142 |
|
143 |
def main_page():
|
144 |
-
|
145 |
|
146 |
if "model_name" not in st.session_state:
|
147 |
# Initialize session state.
|
148 |
st.session_state.update({
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
"license": "",
|
151 |
-
"
|
152 |
-
"
|
153 |
-
"
|
154 |
-
|
155 |
-
"
|
156 |
-
"
|
157 |
-
"
|
158 |
-
"
|
159 |
-
"
|
160 |
-
"
|
161 |
-
"
|
162 |
-
"
|
163 |
-
"
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
"
|
168 |
-
"
|
169 |
-
"
|
170 |
-
"
|
171 |
-
|
172 |
-
"
|
173 |
-
"
|
174 |
-
|
175 |
-
"training_Data": "",
|
176 |
-
"model_preprocessing":"",
|
177 |
-
"Speeds_Sizes_Times":"",
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
"Model_Eval": "",
|
182 |
-
"Testing_Data":"",
|
183 |
-
"Factors":"",
|
184 |
-
"Metrics":"",
|
185 |
-
"Model_Results":"",
|
186 |
-
|
187 |
-
"Model_c02_emitted": "",
|
188 |
-
"Model_hardware":"",
|
189 |
-
"hours_used":"",
|
190 |
-
"Model_cloud_provider":"",
|
191 |
-
"Model_cloud_region":"",
|
192 |
-
|
193 |
-
"Model_cite": "",
|
194 |
-
"paper_url": "",
|
195 |
-
"github_url": "",
|
196 |
-
"bibtex_citation": "",
|
197 |
-
"APA_citation":"",
|
198 |
-
|
199 |
-
"Model_examin":"",
|
200 |
-
"Model_card_contact":"",
|
201 |
-
"Model_card_authors":"",
|
202 |
-
"Glossary":"",
|
203 |
-
"More_info":"",
|
204 |
-
|
205 |
-
"Model_specs":"",
|
206 |
-
"compute_infrastructure":"",
|
207 |
-
"technical_specs_software":"",
|
208 |
-
|
209 |
-
"check_box": bool,
|
210 |
-
"markdown_upload":" ",
|
211 |
-
"legal_view":bool,
|
212 |
-
"researcher_view":bool,
|
213 |
-
"beginner_technical_view":bool,
|
214 |
-
"markdown_state":"",
|
215 |
})
|
216 |
## getting cache for each warnings
|
217 |
languages_map, license_map, available_metrics, libraries, tasks, icd_map, treatment_mod = get_cached_data()
|
@@ -222,11 +215,11 @@ def main_page():
|
|
222 |
warning_placeholder = st.empty()
|
223 |
|
224 |
st.text_input("Model Name", key=persist("model_name"))
|
225 |
-
st.number_input("Version",key=persist("
|
226 |
st.text("Intended use:")
|
227 |
left, right = st.columns([4,2])
|
228 |
-
left.multiselect("Treatment site ICD10",list(icd_map), help="Reference ICD10 WHO: https://icd.who.int/icdapi")
|
229 |
-
right.multiselect("Treatment modality", list(treatment_mod), help="Reference LOINC Modality Radiation treatment: https://loinc.org/21964-2" )
|
230 |
left, right = st.columns(2)
|
231 |
nlines = int(left.number_input("Number of prescription levels", 0, 20, 1))
|
232 |
# cols = st.columns(ncol)
|
@@ -234,7 +227,7 @@ def main_page():
|
|
234 |
right.number_input(f"Prescription [Gy] # {i}", key=i)
|
235 |
st.text_area("Additional information", placeholder = "Bilateral cases only", help="E.g. Bilateral cases only", key=persist('additional_information'))
|
236 |
st.text_area("Motivation for development", key=persist('motivation'))
|
237 |
-
st.text_area("Class", placeholder="RULE 11, FROM MDCG 2021-24", key=persist('
|
238 |
st.date_input("Creation date", key=persist('creation_date'))
|
239 |
st.text_area("Type of architecture",value="UNet", key=persist('architecture'))
|
240 |
|
@@ -244,13 +237,12 @@ def main_page():
|
|
244 |
middle.text_input("Institution", placeholder = "University/clinic/company", key=persist('dev_institution'))
|
245 |
right.text_input("Email", key=persist('dev_email'))
|
246 |
|
247 |
-
st.text_area("Funded by", key=persist('
|
248 |
-
st.text_area("Shared by", key=persist('
|
249 |
st.selectbox("License", [""] + list(license_map.values()), help="The license associated with this model.", key=persist("license"))
|
250 |
-
st.text_area("Fine tuned from model", key=persist('
|
251 |
-
st.
|
252 |
-
st.text_input("Related GitHub Repository", help="Link to a GitHub repository used in the development of this model", key=persist("
|
253 |
-
st.text_area("Bibtex Citation", help="Bibtex citations for related work", key=persist("bibtex_citations"))
|
254 |
# st.selectbox("Library Name", [""] + libraries, help="The name of the library this model came from (Ex. pytorch, timm, spacy, keras, etc.). This is usually automatically detected in model repos, so it is not required.", key=persist('library_name'))
|
255 |
# st.text_input("Parent Model (URL)", help="If this model has another model as its base, please provide the URL link to the parent model", key=persist("Parent_Model_name"))
|
256 |
# st.text_input("Datasets (comma separated)", help="The dataset(s) used to train this model. Use dataset id from https://hf.co/datasets.", key=persist("datasets"))
|
@@ -269,7 +261,7 @@ def main_page():
|
|
269 |
# warnings setting
|
270 |
# languages=st.session_state.languages or None
|
271 |
license=st.session_state.license or None
|
272 |
-
task = st.session_state.task or None
|
273 |
markdown_upload = st.session_state.markdown_upload
|
274 |
#uploaded_model_card = st.session_state.uploaded_model
|
275 |
# Handle any warnings...
|
@@ -293,8 +285,6 @@ def main_page():
|
|
293 |
# Read a single file
|
294 |
uploaded_file = st.file_uploader("Choose a file", type = ['md'], help = 'Please choose a markdown (.md) file type to upload')
|
295 |
if uploaded_file is not None:
|
296 |
-
|
297 |
-
file_details = {"FileName":uploaded_file.name,"FileType":uploaded_file.type}
|
298 |
name_of_uploaded_file = save_uploadedfile(uploaded_file)
|
299 |
|
300 |
st.session_state.markdown_upload = name_of_uploaded_file ## uploaded model card
|
@@ -323,10 +313,8 @@ def main_page():
|
|
323 |
if submit:
|
324 |
if len(repo_id.split('/')) == 2:
|
325 |
repo_url = create_repo(repo_id, exist_ok=True, token=token)
|
326 |
-
|
327 |
-
|
328 |
-
print(card_info)
|
329 |
-
new_url = card_upload(card_info,repo_id, token=token)
|
330 |
st.success(f"Pushed the card to the repo [here]({new_url})!") # note: was repo_url
|
331 |
else:
|
332 |
st.error("Repo ID invalid. It should be username/repo-name. For example: nateraw/food")
|
|
|
9 |
import pandas as pd
|
10 |
from huggingface_hub import create_repo
|
11 |
import os
|
12 |
+
from datetime import date
|
13 |
from middleMan import parse_into_jinja_markdown as pj
|
14 |
|
15 |
import requests
|
|
|
96 |
)
|
97 |
return url
|
98 |
|
99 |
+
def images_upload(images_list,repo_id,token):
|
100 |
+
repo_type = "model"
|
101 |
+
commit_description=None,
|
102 |
+
revision=None
|
103 |
+
create_pr=None
|
104 |
+
for img in images_list:
|
105 |
+
if img is not None:
|
106 |
+
with tempfile.TemporaryDirectory() as tmpdir:
|
107 |
+
tmp_path = Path(tmpdir) / "README.md"
|
108 |
+
tmp_path.write_text(str(img))
|
109 |
+
url = upload_file(
|
110 |
+
path_or_fileobj=str(tmp_path),
|
111 |
+
path_in_repo="README.md",
|
112 |
+
repo_id=repo_id,
|
113 |
+
token=token,
|
114 |
+
repo_type=repo_type,
|
115 |
+
# identical_ok=True,
|
116 |
+
revision=revision
|
117 |
+
)
|
118 |
+
return url
|
119 |
+
|
120 |
def validate(self, repo_type="model"):
|
121 |
"""Validates card against Hugging Face Hub's model card validation logic.
|
122 |
Using this function requires access to the internet, so it is only called
|
|
|
156 |
|
157 |
## Save uploaded [markdown] file to directory to be used by jinja parser function
|
158 |
def save_uploadedfile(uploadedfile):
|
159 |
+
with open(uploadedfile.name,"wb") as f:
|
160 |
f.write(uploadedfile.getbuffer())
|
161 |
st.success("Saved File:{} to temp_uploaded_filed_Dir".format(uploadedfile.name))
|
162 |
return uploadedfile.name
|
163 |
|
164 |
|
165 |
def main_page():
|
166 |
+
today=date.today()
|
167 |
|
168 |
if "model_name" not in st.session_state:
|
169 |
# Initialize session state.
|
170 |
st.session_state.update({
|
171 |
+
# Model Basic Information
|
172 |
+
"model_version": 0,
|
173 |
+
"icd10": [],
|
174 |
+
"treatment_modality": [],
|
175 |
+
"prescription_levels": [],
|
176 |
+
"additional_information": "",
|
177 |
+
"motivation": "",
|
178 |
+
"model_class":"",
|
179 |
+
"creation_date": today,
|
180 |
+
"architecture": "",
|
181 |
+
"model_developers": "",
|
182 |
+
"funded_by":"",
|
183 |
+
"shared_by":"",
|
184 |
"license": "",
|
185 |
+
"finetuned_from": "",
|
186 |
+
"research_paper": "",
|
187 |
+
"git_repo": "",
|
188 |
+
# Technical Specifications
|
189 |
+
"nb_parameters": 5,
|
190 |
+
"input_channels": [],
|
191 |
+
"loss_function": "",
|
192 |
+
"batch_size": 1,
|
193 |
+
"patch_dimension": [],
|
194 |
+
"architecture_filename":None,
|
195 |
+
"libraries":[],
|
196 |
+
"hardware": "",
|
197 |
+
"inference_time": 10,
|
198 |
+
"get_started_code": "",
|
199 |
+
# Training Details
|
200 |
+
"training_set_size":10,
|
201 |
+
"validation_set_size":10,
|
202 |
+
"age_fig_filename":"",
|
203 |
+
"sex_fig_filename":"",
|
204 |
+
"dataset_source": "",
|
205 |
+
"acquisition_from": today,
|
206 |
+
"acquisition_to": today,
|
207 |
+
"markdown_upload": ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
})
|
209 |
## getting cache for each warnings
|
210 |
languages_map, license_map, available_metrics, libraries, tasks, icd_map, treatment_mod = get_cached_data()
|
|
|
215 |
warning_placeholder = st.empty()
|
216 |
|
217 |
st.text_input("Model Name", key=persist("model_name"))
|
218 |
+
st.number_input("Version",key=persist("model_version"),step=0.1)
|
219 |
st.text("Intended use:")
|
220 |
left, right = st.columns([4,2])
|
221 |
+
left.multiselect("Treatment site ICD10",list(icd_map), help="Reference ICD10 WHO: https://icd.who.int/icdapi",key=persist("icd10"))
|
222 |
+
right.multiselect("Treatment modality", list(treatment_mod), help="Reference LOINC Modality Radiation treatment: https://loinc.org/21964-2", key=persist("treatment_modality"))
|
223 |
left, right = st.columns(2)
|
224 |
nlines = int(left.number_input("Number of prescription levels", 0, 20, 1))
|
225 |
# cols = st.columns(ncol)
|
|
|
227 |
right.number_input(f"Prescription [Gy] # {i}", key=i)
|
228 |
st.text_area("Additional information", placeholder = "Bilateral cases only", help="E.g. Bilateral cases only", key=persist('additional_information'))
|
229 |
st.text_area("Motivation for development", key=persist('motivation'))
|
230 |
+
st.text_area("Class", placeholder="RULE 11, FROM MDCG 2021-24", key=persist('model_class'))
|
231 |
st.date_input("Creation date", key=persist('creation_date'))
|
232 |
st.text_area("Type of architecture",value="UNet", key=persist('architecture'))
|
233 |
|
|
|
237 |
middle.text_input("Institution", placeholder = "University/clinic/company", key=persist('dev_institution'))
|
238 |
right.text_input("Email", key=persist('dev_email'))
|
239 |
|
240 |
+
st.text_area("Funded by", key=persist('funded_by'))
|
241 |
+
st.text_area("Shared by", key=persist('shared_by'))
|
242 |
st.selectbox("License", [""] + list(license_map.values()), help="The license associated with this model.", key=persist("license"))
|
243 |
+
st.text_area("Fine tuned from model", key=persist('finetuned_from'))
|
244 |
+
st.text_area("Related Research Paper", help="Research paper related to this model.", key=persist("research_paper"))
|
245 |
+
st.text_input("Related GitHub Repository", help="Link to a GitHub repository used in the development of this model", key=persist("git_repo"))
|
|
|
246 |
# st.selectbox("Library Name", [""] + libraries, help="The name of the library this model came from (Ex. pytorch, timm, spacy, keras, etc.). This is usually automatically detected in model repos, so it is not required.", key=persist('library_name'))
|
247 |
# st.text_input("Parent Model (URL)", help="If this model has another model as its base, please provide the URL link to the parent model", key=persist("Parent_Model_name"))
|
248 |
# st.text_input("Datasets (comma separated)", help="The dataset(s) used to train this model. Use dataset id from https://hf.co/datasets.", key=persist("datasets"))
|
|
|
261 |
# warnings setting
|
262 |
# languages=st.session_state.languages or None
|
263 |
license=st.session_state.license or None
|
264 |
+
task = None #st.session_state.task or None
|
265 |
markdown_upload = st.session_state.markdown_upload
|
266 |
#uploaded_model_card = st.session_state.uploaded_model
|
267 |
# Handle any warnings...
|
|
|
285 |
# Read a single file
|
286 |
uploaded_file = st.file_uploader("Choose a file", type = ['md'], help = 'Please choose a markdown (.md) file type to upload')
|
287 |
if uploaded_file is not None:
|
|
|
|
|
288 |
name_of_uploaded_file = save_uploadedfile(uploaded_file)
|
289 |
|
290 |
st.session_state.markdown_upload = name_of_uploaded_file ## uploaded model card
|
|
|
313 |
if submit:
|
314 |
if len(repo_id.split('/')) == 2:
|
315 |
repo_url = create_repo(repo_id, exist_ok=True, token=token)
|
316 |
+
new_url = card_upload(pj(),repo_id, token=token)
|
317 |
+
# images_upload([st.session_state['architecture_filename'], st.session_state["age_fig_filename"], st.session_state["sex_fig_filename"]],repo_id, token=token)
|
|
|
|
|
318 |
st.success(f"Pushed the card to the repo [here]({new_url})!") # note: was repo_url
|
319 |
else:
|
320 |
st.error("Repo ID invalid. It should be username/repo-name. For example: nateraw/food")
|
current_card.md
CHANGED
@@ -1,224 +1,83 @@
|
|
1 |
---
|
2 |
language:
|
3 |
- en
|
4 |
-
license: openrail
|
5 |
---
|
6 |
|
7 |
-
# {{
|
8 |
|
9 |
<!--> Provide a quick summary of what the model is/does. <!-->
|
10 |
|
11 |
# Table of Contents
|
12 |
|
13 |
-
- [{{
|
14 |
- [Table of Contents](#table-of-contents)
|
15 |
-
- [Model
|
16 |
-
|
17 |
-
- [
|
18 |
-
|
19 |
-
|
20 |
-
- [Out-of-Scope Use](#out-of-scope-use)
|
21 |
-
- [Bias, Risks, and Limitations](#bias-risks-and-limitations)
|
22 |
-
- [Recommendations](#recommendations)
|
23 |
-
- [Training Details](#training-details)
|
24 |
-
- [Training Data](#training-data)
|
25 |
-
- [Training Procedure](#training-procedure)
|
26 |
-
- [Preprocessing](#preprocessing)
|
27 |
-
- [Speeds, Sizes, Times](#speeds-sizes-times)
|
28 |
-
- [Evaluation](#evaluation)
|
29 |
-
- [Testing Data, Factors & Metrics](#testing-data-factors--metrics)
|
30 |
-
- [Testing Data](#testing-data)
|
31 |
-
- [Factors](#factors)
|
32 |
-
- [Metrics](#metrics)
|
33 |
-
- [Results](#results)
|
34 |
-
- [Model Examination](#model-examination)
|
35 |
-
- [Environmental Impact](#environmental-impact)
|
36 |
-
- [Technical Specifications [optional]](#technical-specifications-optional)
|
37 |
-
- [Model Architecture and Objective](#model-architecture-and-objective)
|
38 |
-
- [Compute Infrastructure](#compute-infrastructure)
|
39 |
-
- [Hardware](#hardware)
|
40 |
-
- [Software](#software)
|
41 |
-
- [Citation](#citation)
|
42 |
-
- [Glossary [optional]](#glossary-optional)
|
43 |
-
- [More Information [optional]](#more-information-optional)
|
44 |
-
- [Model Card Authors [optional]](#model-card-authors-optional)
|
45 |
-
- [Model Card Contact](#model-card-contact)
|
46 |
-
- [How to Get Started with the Model](#how-to-get-started-with-the-model)
|
47 |
-
|
48 |
-
|
49 |
-
# Model Details
|
50 |
-
|
51 |
-
## Model Description
|
52 |
|
53 |
-
<!--> This section provides basic information about what the model is, its current status, and where it came from.. <!-->
|
54 |
-
{{ the_model_description | default("More information needed", true)}}
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
- **
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
- **License:** {{ license | default("More information needed", true)}}
|
61 |
-
- **
|
62 |
-
|
63 |
-
- **
|
64 |
-
|
65 |
-
# Uses
|
66 |
-
|
67 |
-
<!--> Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. <!-->
|
68 |
-
|
69 |
-
## Direct Use
|
70 |
-
|
71 |
-
<!--> This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. <!-->
|
72 |
-
|
73 |
-
{{ direct_use | default("More information needed", true)}}
|
74 |
-
|
75 |
-
## Downstream Use [Optional]
|
76 |
-
|
77 |
-
<!--> This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app <!-->
|
78 |
-
|
79 |
-
{{ downstream_use | default("More information needed", true)}}
|
80 |
-
|
81 |
-
## Out-of-Scope Use
|
82 |
-
|
83 |
-
<!--> This section addresses misuse, malicious use, and uses that the model will not work well for. <!-->
|
84 |
-
|
85 |
-
{{ out_of_scope_use | default("More information needed", true)}}
|
86 |
-
|
87 |
-
# Bias, Risks, and Limitations
|
88 |
-
|
89 |
-
<!--> This section is meant to convey both technical and sociotechnical limitations. <!-->
|
90 |
-
|
91 |
-
{{ bias_risks_limitations | default("More information needed", true)}}
|
92 |
-
|
93 |
-
## Recommendations
|
94 |
-
|
95 |
-
<!--> This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. <!-->
|
96 |
-
|
97 |
-
{{ bias_recommendations | default("Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recomendations.", true)}}
|
98 |
-
|
99 |
-
# Training Details
|
100 |
-
|
101 |
-
## Training Data
|
102 |
-
|
103 |
-
<!--> This should link to a Data Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. <!-->
|
104 |
-
|
105 |
-
{{ training_data | default("More information needed", true)}}
|
106 |
-
|
107 |
-
## Training Procedure
|
108 |
-
|
109 |
-
<!--> This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. <!-->
|
110 |
-
|
111 |
-
### Preprocessing
|
112 |
-
|
113 |
-
{{ preprocessing | default("More information needed", true)}}
|
114 |
-
|
115 |
-
### Speeds, Sizes, Times
|
116 |
-
|
117 |
-
<!--> This section provides information about throughput, start/end time, checkpoint size if relevant, etc. <!-->
|
118 |
-
|
119 |
-
{{ speeds_sizes_times | default("More information needed", true)}}
|
120 |
-
|
121 |
-
# Evaluation
|
122 |
-
|
123 |
-
<!--> This section describes the evaluation protocols and provides the results. <!-->
|
124 |
-
|
125 |
-
## Testing Data, Factors & Metrics
|
126 |
-
|
127 |
-
### Testing Data
|
128 |
-
|
129 |
-
<!--> This should link to a Data Card if possible. <!-->
|
130 |
-
|
131 |
-
{{ testing_data | default("More information needed", true)}}
|
132 |
-
|
133 |
-
### Factors
|
134 |
-
|
135 |
-
<!--> These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. <!-->
|
136 |
-
|
137 |
-
{{ testing_factors | default("More information needed", true)}}
|
138 |
|
139 |
-
|
140 |
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
## Results
|
146 |
-
|
147 |
-
{{ results | default("More information needed", true)}}
|
148 |
-
|
149 |
-
# Model Examination
|
150 |
-
|
151 |
-
{{ model_examination | default("More information needed", true)}}
|
152 |
-
|
153 |
-
# Environmental Impact
|
154 |
-
|
155 |
-
<!--> Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly <!-->
|
156 |
-
|
157 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
158 |
-
|
159 |
-
- **Hardware Type:** {{ hardware | default("More information needed", true)}}
|
160 |
-
- **Hours used:** {{ hours_used | default("More information needed", true)}}
|
161 |
-
- **Cloud Provider:** {{ cloud_provider | default("More information needed", true)}}
|
162 |
-
- **Compute Region:** {{ cloud_region | default("More information needed", true)}}
|
163 |
-
- **Carbon Emitted:** {{ co2_emitted | default("More information needed", true)}}
|
164 |
-
|
165 |
-
# Technical Specifications [optional]
|
166 |
-
|
167 |
-
## Model Architecture and Objective
|
168 |
-
|
169 |
-
{{ model_specs | default("More information needed", true)}}
|
170 |
-
|
171 |
-
## Compute Infrastructure
|
172 |
-
|
173 |
-
{{ compute_infrastructure | default("More information needed", true)}}
|
174 |
-
|
175 |
-
### Hardware
|
176 |
-
|
177 |
-
{{ hardware | default("More information needed", true)}}
|
178 |
-
|
179 |
-
### Software
|
180 |
-
|
181 |
-
{{ software | default("More information needed", true)}}
|
182 |
-
|
183 |
-
# Citation
|
184 |
-
|
185 |
-
<!--> If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. <!-->
|
186 |
-
|
187 |
-
**BibTeX:**
|
188 |
-
|
189 |
-
{{ citation_bibtex | default("More information needed", true)}}
|
190 |
-
|
191 |
-
**APA:**
|
192 |
-
|
193 |
-
{{ citation_apa | default("More information needed", true)}}
|
194 |
-
|
195 |
-
# Glossary [optional]
|
196 |
-
|
197 |
-
<!--> If relevant, include terms and calculations in this section that can help readers understand the model or model card. <!-->
|
198 |
-
|
199 |
-
{{ glossary | default("More information needed", true)}}
|
200 |
-
|
201 |
-
# More Information [optional]
|
202 |
|
203 |
-
{{
|
204 |
|
205 |
-
|
206 |
|
207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
|
209 |
-
|
|
|
|
|
210 |
|
211 |
-
|
|
|
|
|
212 |
|
213 |
-
|
|
|
|
|
214 |
|
215 |
-
Use the code below to get started with the model.
|
216 |
|
217 |
-
<details>
|
218 |
-
<summary> Click to expand </summary>
|
219 |
|
220 |
-
{{
|
|
|
|
|
221 |
|
222 |
-
|
|
|
223 |
|
224 |
|
|
|
1 |
---
|
2 |
language:
|
3 |
- en
|
|
|
4 |
---
|
5 |
|
6 |
+
# {{ model_name }}
|
7 |
|
8 |
<!--> Provide a quick summary of what the model is/does. <!-->
|
9 |
|
10 |
# Table of Contents
|
11 |
|
12 |
+
- [{{ model_name }}](#-model_name)
|
13 |
- [Table of Contents](#table-of-contents)
|
14 |
+
- [1. Model Basic Information](#model-basic-information)
|
15 |
+
- [2. Technical Specifications](#technical-specifications)
|
16 |
+
- [3. Training Details](#training-details)
|
17 |
+
- [4. Model Evaluation](#model-evaluation)
|
18 |
+
- [5. Model Examination](#model-examination)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
|
|
|
|
20 |
|
21 |
+
# 1. Model Basic Information
|
22 |
+
<!--> This section provides basic information about what the model is, its current status, and where it came from.. <!-->
|
23 |
+
- **Version:** {{ version | default("0")}}
|
24 |
+
## 1.1. Intended use
|
25 |
+
- **Treatment site ICD10:** {{ icd10 | default("More information needed", true) }}
|
26 |
+
- **Treatment modality:** {{ treatment_modality | default("More information needed", true) }}
|
27 |
+
- **Prescription levels [Gy]:** {{ prescription_levels | default("More information needed", true)}}
|
28 |
+
- **Additional information:** {{ additional_information | default("More information needed", true)}}
|
29 |
+
- **Motivation for development:** {{ motivation | default("More information needed", true)}}
|
30 |
+
- **Class:** {{ model_class | default("More information needed", true)}}
|
31 |
+
- **Creation date:** {{ creation_date | default("More information needed", true)}}
|
32 |
+
- **Type of architecture** {{ architecture | default("More information needed", true)}}
|
33 |
+
## 1.2. Development and deployment
|
34 |
+
- **Developed by:** Name: {{ dev_name | default("More information needed", true)}}, Instutution: {{dev_institution | default("More information needed", true)}}, Email: {{ dev_email | default("More information needed", true)}}
|
35 |
+
- **Funded by:** {{ funded_by | default("More information needed", true)}}
|
36 |
+
- **Shared by:** {{ shared_by | default("More information needed", true)}}
|
37 |
- **License:** {{ license | default("More information needed", true)}}
|
38 |
+
- **Finetuned from model:** {{ finetuned_by | default("More information needed", true)}}
|
39 |
+
- **Related Research Paper(s):** {{ research_paper | default("More information needed", true)}}
|
40 |
+
- **Related Git Repository:** {{ git_repo | default("More information needed", true)}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
## 1.3. How to Get Started with the Model
|
43 |
|
44 |
+
Use the code below to get started with the model.
|
45 |
+
<details>
|
46 |
+
<summary> Click to expand </summary>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
+
{{ get_started_code | default("More information needed", true)}}
|
49 |
|
50 |
+
</details>
|
51 |
|
52 |
+
# 2. Technical Specifications
|
53 |
+
## 2.1. Model architecture
|
54 |
+
- **Total number of parameters:** {{ nb_parameters | default("More information needed", true)}}
|
55 |
+
- **Input channels:** {{ input_channels | default("More information needed", true)}}
|
56 |
+
- **Loss function** {{ loss_function | default("More information needed", true)}}
|
57 |
+
- **Batch size** {{ batch_size | default("More information needed", true)}}
|
58 |
+
- **Patch dimension** {{ patch_dimension | default("More information needed", true)}}
|
59 |
+
<img width="100%" src="https://cdn-uploads.huggingface.co/production/uploads/65c9dbefd6cbf9dfed67367e/xGGUE5spRY6tar5R4VeKX.png" alt="error while loading image">
|
60 |
+
_Figure 1: Model architecture_
|
61 |
|
62 |
+
- **Libraries/Dependencies:** {{ libraries | default("More information needed", true)}}
|
63 |
+
- **Hardware recommended:** {{ hardware | default("More information needed", true)}}
|
64 |
+
- **Inference time for recommended [seconds]** {{ inference_time | default("More information needed", true)}}
|
65 |
|
66 |
+
# 3. Training Details
|
67 |
+
- **Training set size:** {{ training_set_size | default("More information needed", true)}}
|
68 |
+
- **Validation set size:** {{ validation_set_size | default("More information needed", true)}}
|
69 |
|
70 |
+
Age distribution | Sex distribution
|
71 |
+
--- | ---
|
72 |
+
![](age_distribution.png) | ![](sex_distribution.png)
|
73 |
|
|
|
74 |
|
|
|
|
|
75 |
|
76 |
+
- **Dataset source:** {{ dataset_source | default("More information needed", true)}}
|
77 |
+
- **Acquisition date** from {{ acquisition_from | default("More information needed", true)}} to {{ acquisition_to | default("More information needed", true)}}
|
78 |
+
# 4. Model Evaluation
|
79 |
|
80 |
+
# 5. Model Examination
|
81 |
+
<!--> This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. <!-->
|
82 |
|
83 |
|
middleMan.py
CHANGED
@@ -23,30 +23,42 @@ def parse_into_jinja_markdown():
|
|
23 |
# - parent model
|
24 |
# to fix:
|
25 |
# citation on form: check box for bibtex or apa: then parse
|
26 |
-
return (temp.render(
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
))
|
51 |
|
52 |
|
|
|
23 |
# - parent model
|
24 |
# to fix:
|
25 |
# citation on form: check box for bibtex or apa: then parse
|
26 |
+
return (temp.render(model_name = st.session_state["model_name"], model_version = st.session_state["model_version"],
|
27 |
+
icd10 = st.session_state["icd10"], treatment_modality = st.session_state["treatment_modality"], prescription_levels = st.session_state["prescription_levels"],
|
28 |
+
additional_information = st.session_state["additional_information"], motivation = st.session_state["motivation"], model_class = st.session_state["model_class"],
|
29 |
+
creation_date = st.session_state["creation_date"], architecture = st.session_state["architecture"],
|
30 |
+
model_developers=st.session_state["model_developers"],funded_by = st.session_state["funded_by"],shared_by = st.session_state["shared_by"],
|
31 |
+
license = st.session_state['license'],finetuned_from = st.session_state['finetuned_from'], research_paper = st.session_state["research_paper"], git_repo = st.session_state["git_repo"],
|
32 |
+
|
33 |
+
|
34 |
+
nb_parameters = st.session_state["nb_parameters"], input_channels = st.session_state["input_channels"],
|
35 |
+
loss_function = st.session_state["loss_function"], batch_size = st.session_state["batch_size"], patch_dimension = st.session_state["patch_dimension"],
|
36 |
+
architecture_filename = st.session_state["architecture_filename"], libraries = st.session_state["libraries"], hardware = st.session_state["hardware"],
|
37 |
+
inference_time = st.session_state["inference_time"], get_started_code = st.session_state["get_started_code"],
|
38 |
+
|
39 |
+
training_set_size = st.session_state["training_set_size"], validation_set_size = st.session_state["validation_set_size"],
|
40 |
+
age_fig_filename = st.session_state["age_fig_filename"], sex_fig_filename = st.session_state["sex_fig_filename"],
|
41 |
+
dataset_source = st.session_state["dataset_source"], acquisition_from = st.session_state["acquisition_from"], acquisition_to = st.session_state["acquisition_to"],
|
42 |
+
# direct_use = st.session_state["Direct_Use"], downstream_use = st.session_state["Downstream_Use"],out_of_scope_use = st.session_state["Out-of-Scope_Use"],
|
43 |
+
# bias_risks_limitations = st.session_state["Model_Limits_n_Risks"], bias_recommendations = st.session_state['Recommendations'],
|
44 |
+
# model_examination = st.session_state['Model_examin'],
|
45 |
+
# speeds_sizes_times = st.session_state['Speeds_Sizes_Times'],
|
46 |
+
# hardware= st.session_state['Model_hardware'], hours_used = st.session_state['hours_used'], cloud_provider = st.session_state['Model_cloud_provider'], cloud_region = st.session_state['Model_cloud_region'], co2_emitted = st.session_state['Model_c02_emitted'],
|
47 |
+
# citation_bibtex= st.session_state["APA_citation"], citation_apa = st.session_state['bibtex_citation'],
|
48 |
+
# training_data = st.session_state['training_Data'], preprocessing =st.session_state['model_preprocessing'],
|
49 |
+
# model_specs = st.session_state['Model_specs'], compute_infrastructure = st.session_state['compute_infrastructure'],software = st.session_state['technical_specs_software'],
|
50 |
+
# glossary = st.session_state['Glossary'],
|
51 |
+
# more_information = st.session_state['More_info'],
|
52 |
+
# model_card_authors = st.session_state['the_authors'],
|
53 |
+
# model_card_contact = st.session_state['Model_card_contact'],
|
54 |
+
# get_started_code =st.session_state["Model_how_to"],
|
55 |
+
# repo_link = st.session_state["github_url"],
|
56 |
+
# paper_link = st.session_state["paper_url"],
|
57 |
+
# blog_link = st.session_state["blog_url"],
|
58 |
+
# testing_data = st.session_state["Testing_Data"],
|
59 |
+
# testing_factors = st.session_state["Factors"],
|
60 |
+
# results = st.session_state['Model_Results'],
|
61 |
+
# testing_metrics = st.session_state["Metrics"]
|
62 |
))
|
63 |
|
64 |
|
pages/1_π_Technical_Specifications.py
CHANGED
@@ -8,10 +8,11 @@ import requests
|
|
8 |
# global variable_output
|
9 |
|
10 |
|
11 |
-
|
12 |
def get_cached_data():
|
13 |
# json.load(open('file_TG263.json'))
|
14 |
struct_dict = {"Target":["GTV","CTV","PTV"],"Anatomy":["SpinalCord","BrainStem"]}
|
|
|
|
|
15 |
r = requests.get('https://huggingface.co/api/models-tags-by-type')
|
16 |
tags_data = r.json()
|
17 |
libraries = [x['id'] for x in tags_data['library']]
|
@@ -28,14 +29,14 @@ def cs_body():
|
|
28 |
st.header('Technical Specifications')
|
29 |
st.write("Provide an overview of any additional technical specifications for this model")
|
30 |
st.markdown('##### Model architecture')
|
31 |
-
st.number_input("Total number of trainable parameters [million]",value=5)
|
32 |
left, middle, right = st.columns(3)
|
33 |
nlines = int(left.number_input("Input channels", 0, 20, 1))
|
34 |
for i in range(nlines):
|
35 |
type_input = middle.selectbox(f"Input type # {i}", list(struct_dict.keys()))
|
36 |
right.selectbox("Input",struct_dict[type_input], help="From https://aapm.onlinelibrary.wiley.com/doi/pdf/10.1002/acm2.12701")
|
37 |
-
st.text_input("Loss function",placeholder="MSE")
|
38 |
-
st.number_input("Batch size",value=1)
|
39 |
left, right = st.columns(2)
|
40 |
nlines = int(left.number_input("Patch dimension", 2, 3, 3))
|
41 |
# cols = st.columns(ncol)
|
@@ -45,10 +46,10 @@ def cs_body():
|
|
45 |
if arch_fig is not None:
|
46 |
st.image(arch_fig)
|
47 |
|
48 |
-
st.
|
49 |
-
st.text_input("Hardware recommended", placeholder="GPU 20Gb RAM", key=persist("
|
50 |
st.number_input("Inference time for recommended hardware [seconds]",value=10, key=persist("inference_time"))
|
51 |
-
st.text_area("Installation / Getting started", placeholder="Installation procedure / code to run inference", key=persist("
|
52 |
|
53 |
|
54 |
|
|
|
8 |
# global variable_output
|
9 |
|
10 |
|
|
|
11 |
def get_cached_data():
|
12 |
# json.load(open('file_TG263.json'))
|
13 |
struct_dict = {"Target":["GTV","CTV","PTV"],"Anatomy":["SpinalCord","BrainStem"]}
|
14 |
+
|
15 |
+
|
16 |
r = requests.get('https://huggingface.co/api/models-tags-by-type')
|
17 |
tags_data = r.json()
|
18 |
libraries = [x['id'] for x in tags_data['library']]
|
|
|
29 |
st.header('Technical Specifications')
|
30 |
st.write("Provide an overview of any additional technical specifications for this model")
|
31 |
st.markdown('##### Model architecture')
|
32 |
+
st.number_input("Total number of trainable parameters [million]",value=5,key=persist("nb_parameters"))
|
33 |
left, middle, right = st.columns(3)
|
34 |
nlines = int(left.number_input("Input channels", 0, 20, 1))
|
35 |
for i in range(nlines):
|
36 |
type_input = middle.selectbox(f"Input type # {i}", list(struct_dict.keys()))
|
37 |
right.selectbox("Input",struct_dict[type_input], help="From https://aapm.onlinelibrary.wiley.com/doi/pdf/10.1002/acm2.12701")
|
38 |
+
st.text_input("Loss function",placeholder="MSE", key=persist("loss_function"))
|
39 |
+
st.number_input("Batch size",value=1,key=persist("batch_size"))
|
40 |
left, right = st.columns(2)
|
41 |
nlines = int(left.number_input("Patch dimension", 2, 3, 3))
|
42 |
# cols = st.columns(ncol)
|
|
|
46 |
if arch_fig is not None:
|
47 |
st.image(arch_fig)
|
48 |
|
49 |
+
st.multiselect("Library/Dependencies", libraries, default=[libraries[0]], help="The name of the library this model came from (Ex. pytorch, timm, spacy, keras, etc.). This is usually automatically detected in model repos, so it is not required.", key=persist('libraries'))
|
50 |
+
st.text_input("Hardware recommended", placeholder="GPU 20Gb RAM", key=persist("hardware"))
|
51 |
st.number_input("Inference time for recommended hardware [seconds]",value=10, key=persist("inference_time"))
|
52 |
+
st.text_area("Installation / Getting started", placeholder="Installation procedure / code to run inference", key=persist("get_started_code"))
|
53 |
|
54 |
|
55 |
|
pages/2_ποΈββοΈ_Model_training.py
CHANGED
@@ -31,8 +31,10 @@ def cs_body():
|
|
31 |
|
32 |
fig, ax = plt.subplots()
|
33 |
ax.set_title("Age distribution")
|
34 |
-
ax.hist(np.random.normal(size=500))
|
35 |
-
left.pyplot(fig)
|
|
|
|
|
36 |
|
37 |
fig, ax = plt.subplots()
|
38 |
ax.pie([45,55],labels=["Men","Women"])
|
|
|
31 |
|
32 |
fig, ax = plt.subplots()
|
33 |
ax.set_title("Age distribution")
|
34 |
+
ax.hist(np.random.normal(loc=40,scale=4.0,size=500))
|
35 |
+
age = left.pyplot(fig)
|
36 |
+
|
37 |
+
|
38 |
|
39 |
fig, ax = plt.subplots()
|
40 |
ax.pie([45,55],labels=["Men","Women"])
|