Spaces:
Sleeping
Sleeping
Commit
·
9d6439d
1
Parent(s):
87dcf1f
2. update streamlit
Browse files- streamlitapp.py +12 -10
streamlitapp.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
from functools import partial
|
2 |
from pathlib import Path
|
|
|
3 |
|
4 |
import kangas as kg
|
5 |
import streamlit as st
|
6 |
import streamlit.components.v1 as components
|
7 |
from datasets import load_dataset
|
8 |
-
import socket
|
9 |
|
10 |
proj_dir = Path(__file__).parent
|
11 |
|
@@ -17,16 +17,18 @@ st.set_page_config(layout="wide")
|
|
17 |
st.markdown("1. Select dataset of your choice")
|
18 |
|
19 |
def kangas_fn(dataset_repo):
|
20 |
-
|
21 |
-
|
22 |
-
with st.spinner("Loading Dataset..."):
|
23 |
dataset = load_dataset(dataset_repo, split="train")
|
24 |
-
with st.spinner("Creating Kangas..."):
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
29 |
hf_dataset = st.text_input("HuggingFace Dataset", value='beans')
|
30 |
st.button("Download and Run", on_click=partial(kangas_fn, hf_dataset))
|
31 |
st.markdown("""Click the dropdown in Kangas to see pre-loaded datasets""")
|
32 |
-
|
|
|
1 |
from functools import partial
|
2 |
from pathlib import Path
|
3 |
+
import os
|
4 |
|
5 |
import kangas as kg
|
6 |
import streamlit as st
|
7 |
import streamlit.components.v1 as components
|
8 |
from datasets import load_dataset
|
|
|
9 |
|
10 |
proj_dir = Path(__file__).parent
|
11 |
|
|
|
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..."):
|
23 |
dataset = load_dataset(dataset_repo, split="train")
|
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)
|