comet-team commited on
Commit
b86a896
·
1 Parent(s): 9d6439d

Update streamlitapp.py

Browse files
Files changed (1) hide show
  1. streamlitapp.py +7 -5
streamlitapp.py CHANGED
@@ -8,15 +8,15 @@ import streamlit.components.v1 as components
8
  from datasets import load_dataset
9
 
10
  proj_dir = Path(__file__).parent
11
-
12
  servername = 'comet-team-kangas-demo.hf.space'
13
  src = f"https://{servername}/kangas/?datagrid=.%2Fdatagrids%2Fcoco-500.datagrid"
14
-
15
  st.set_page_config(layout="wide")
16
 
17
- st.markdown("1. Select dataset of your choice")
 
18
 
19
  def kangas_fn(dataset_repo):
 
20
  dg_file_name = dataset_repo.replace('/', '__') + '.datagrid'
21
  dg_full_path = str(proj_dir / 'datagrids' / dg_file_name)
22
  with st.spinner("2. Loading Dataset..."):
@@ -24,11 +24,13 @@ def kangas_fn(dataset_repo):
24
  with st.spinner("3. Creating Kangas..."):
25
  if not os.path.exists(dg_full_path):
26
  dg = kg.DataGrid(dataset)
 
 
27
  dg.save(dg_full_path)
28
  with st.spinner("4. Loading Kangas..."):
29
  src = f"https://{servername}/kangas/?datagrid=.%2Fdatagrids%2F" + dg_file_name
30
 
31
  hf_dataset = st.text_input("HuggingFace Dataset", value='beans')
32
- st.button("Download and Run", on_click=partial(kangas_fn, hf_dataset))
33
- st.markdown("""Click the dropdown in Kangas to see pre-loaded datasets""")
34
  components.iframe(src, None, 1000, scrolling=True)
 
8
  from datasets import load_dataset
9
 
10
  proj_dir = Path(__file__).parent
 
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
20
  dg_file_name = dataset_repo.replace('/', '__') + '.datagrid'
21
  dg_full_path = str(proj_dir / 'datagrids' / dg_file_name)
22
  with st.spinner("2. Loading Dataset..."):
 
24
  with st.spinner("3. Creating Kangas..."):
25
  if not os.path.exists(dg_full_path):
26
  dg = kg.DataGrid(dataset)
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("4. Loading Kangas..."):
31
  src = f"https://{servername}/kangas/?datagrid=.%2Fdatagrids%2F" + dg_file_name
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(src, None, 1000, scrolling=True)