Spaces:
Sleeping
Sleeping
Commit
·
d4943e2
1
Parent(s):
b86a896
Update streamlitapp.py
Browse files- streamlitapp.py +11 -8
streamlitapp.py
CHANGED
@@ -7,13 +7,16 @@ import streamlit as st
|
|
7 |
import streamlit.components.v1 as components
|
8 |
from datasets import load_dataset
|
9 |
|
10 |
-
|
11 |
servername = 'comet-team-kangas-demo.hf.space'
|
12 |
-
src = f"https://{servername}/kangas/?datagrid=.%2Fdatagrids%2Fcoco-500.datagrid"
|
13 |
st.set_page_config(layout="wide")
|
|
|
|
|
|
|
|
|
14 |
|
15 |
-
st.markdown("# HuggingFace + Streamlit + Kangas")
|
16 |
-
st.markdown("1. Select a HuggingFace dataset, or select one below")
|
17 |
|
18 |
def kangas_fn(dataset_repo):
|
19 |
global src
|
@@ -27,10 +30,10 @@ def kangas_fn(dataset_repo):
|
|
27 |
with st.spinner("4. Saving Kangas..."):
|
28 |
if not os.path.exists(dg_full_path):
|
29 |
dg.save(dg_full_path)
|
30 |
-
with st.spinner("
|
31 |
-
|
32 |
|
33 |
hf_dataset = st.text_input("HuggingFace Dataset", value='beans')
|
34 |
st.button("Download", on_click=partial(kangas_fn, hf_dataset))
|
35 |
-
st.markdown("""Click the dropdown in Kangas select a dataset""")
|
36 |
-
components.iframe(
|
|
|
7 |
import streamlit.components.v1 as components
|
8 |
from datasets import load_dataset
|
9 |
|
10 |
+
# If you duplicate this space, change this to match your space:
|
11 |
servername = 'comet-team-kangas-demo.hf.space'
|
|
|
12 |
st.set_page_config(layout="wide")
|
13 |
+
proj_dir = Path(__file__).parent
|
14 |
+
|
15 |
+
if 'iframe_source' not in st.session_state:
|
16 |
+
st.session_state['iframe_source'] = f"https://{servername}/kangas/?datagrid=.%2Fdatagrids%2Fcoco-500.datagrid"
|
17 |
|
18 |
+
st.markdown("# HuggingFace Spaces + Streamlit + Kangas")
|
19 |
+
st.markdown("1. Select a HuggingFace dataset and Download, or select one below in Kangas")
|
20 |
|
21 |
def kangas_fn(dataset_repo):
|
22 |
global src
|
|
|
30 |
with st.spinner("4. Saving Kangas..."):
|
31 |
if not os.path.exists(dg_full_path):
|
32 |
dg.save(dg_full_path)
|
33 |
+
with st.spinner("5. Loading Kangas..."):
|
34 |
+
st.session_state['iframe_source'] = f"https://{servername}/kangas/?datagrid=.%2Fdatagrids%2F" + dg_file_name
|
35 |
|
36 |
hf_dataset = st.text_input("HuggingFace Dataset", value='beans')
|
37 |
st.button("Download", on_click=partial(kangas_fn, hf_dataset))
|
38 |
+
st.markdown("""Click the dropdown in Kangas to select a previously-downloaded dataset""")
|
39 |
+
components.iframe(st.session_state['iframe_source'], None, 1000, scrolling=True)
|