Spaces:
Runtime error
Runtime error
Benjamin Bossan
commited on
Commit
·
1b701be
1
Parent(s):
6e9ab9b
Move editing stuff to sidebar
Browse files
app.py
CHANGED
@@ -36,8 +36,6 @@ tmp_repo = Path(mkdtemp(prefix="skops-"))
|
|
36 |
# the hf_repo is the actual repo used for init()
|
37 |
hf_repo = Path(mkdtemp(prefix="skops-"))
|
38 |
|
39 |
-
left_col, right_col = st.columns([1, 2])
|
40 |
-
|
41 |
# a hacky way to "persist" custom sections
|
42 |
CUSTOM_SECTIONS_CACHE_FILE = ".custom-sections.json"
|
43 |
|
@@ -223,11 +221,10 @@ def display_model_card(model_card):
|
|
223 |
# metadata = rendered[3:idx]
|
224 |
# rendered = rendered[idx + 4 :] # noqa: E203
|
225 |
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
st.markdown(rendered, unsafe_allow_html=True)
|
231 |
|
232 |
|
233 |
def download_model_card(model_card):
|
@@ -266,13 +263,15 @@ def add_custom_plot():
|
|
266 |
st.session_state.custom_sections[str(PLOT_PREFIX + plot_name)] = file_path
|
267 |
|
268 |
|
269 |
-
with
|
270 |
# This contains every element required to edit the model card
|
271 |
model = None
|
272 |
data = None
|
273 |
section_name = None
|
274 |
section_content = None
|
275 |
|
|
|
|
|
276 |
model_file = st.file_uploader("Upload a model*", on_change=load_model)
|
277 |
data_file = st.file_uploader(
|
278 |
"Upload X data (csv)*", type=["csv"], on_change=load_data
|
@@ -373,18 +372,17 @@ with left_col:
|
|
373 |
)
|
374 |
|
375 |
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
model_card = _create_model_card()
|
384 |
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
|
390 |
-
|
|
|
36 |
# the hf_repo is the actual repo used for init()
|
37 |
hf_repo = Path(mkdtemp(prefix="skops-"))
|
38 |
|
|
|
|
|
39 |
# a hacky way to "persist" custom sections
|
40 |
CUSTOM_SECTIONS_CACHE_FILE = ".custom-sections.json"
|
41 |
|
|
|
221 |
# metadata = rendered[3:idx]
|
222 |
# rendered = rendered[idx + 4 :] # noqa: E203
|
223 |
|
224 |
+
# strip metadata
|
225 |
+
with st.expander("show metadata"):
|
226 |
+
st.text(metadata)
|
227 |
+
st.markdown(rendered, unsafe_allow_html=True)
|
|
|
228 |
|
229 |
|
230 |
def download_model_card(model_card):
|
|
|
263 |
st.session_state.custom_sections[str(PLOT_PREFIX + plot_name)] = file_path
|
264 |
|
265 |
|
266 |
+
with st.sidebar:
|
267 |
# This contains every element required to edit the model card
|
268 |
model = None
|
269 |
data = None
|
270 |
section_name = None
|
271 |
section_content = None
|
272 |
|
273 |
+
st.title("Model Card Editor")
|
274 |
+
|
275 |
model_file = st.file_uploader("Upload a model*", on_change=load_model)
|
276 |
data_file = st.file_uploader(
|
277 |
"Upload X data (csv)*", type=["csv"], on_change=load_data
|
|
|
372 |
)
|
373 |
|
374 |
|
375 |
+
model_card = None
|
376 |
+
if model is None:
|
377 |
+
st.text("*add a model to render the model card*")
|
378 |
+
if data is None:
|
379 |
+
st.text("*add data to render the model card")
|
380 |
+
if (model is not None) and (data is not None):
|
381 |
+
model_card = _create_model_card()
|
|
|
382 |
|
383 |
+
# this contains the rendered model card
|
384 |
+
rendered = download_model_card(model_card)
|
385 |
+
if rendered:
|
386 |
+
st.download_button(label="Download model card (markdown format)", data=rendered)
|
387 |
|
388 |
+
display_model_card(model_card)
|