Spaces:
Running
Running
Commit
·
5afe7ea
1
Parent(s):
97828eb
added cache button
Browse files
app.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
-
|
2 |
-
subprocess.check_call(["python", '-m', 'pip', 'install',"--upgrade", 'streamlit']) # upgrade pkg
|
3 |
|
4 |
import streamlit as st
|
5 |
import pandas as pd
|
@@ -35,7 +34,7 @@ model_classes ={
|
|
35 |
13: "WiFi",
|
36 |
}
|
37 |
|
38 |
-
@st.cache
|
39 |
def load_t5():
|
40 |
model = AutoModelForSeq2SeqLM.from_pretrained("t5-base")
|
41 |
|
@@ -43,23 +42,23 @@ def load_t5():
|
|
43 |
return model, tokenizer
|
44 |
|
45 |
|
46 |
-
@st.cache
|
47 |
def custom_model():
|
48 |
return pipeline("summarization", model="my_awesome_sum/")
|
49 |
|
50 |
|
51 |
-
@st.cache
|
52 |
def convert_df(df):
|
53 |
# IMPORTANT: Cache the conversion to prevent computation on every rerun
|
54 |
return df.to_csv(index=False).encode("utf-8")
|
55 |
|
56 |
|
57 |
-
@st.cache
|
58 |
def load_one_line_summarizer(model):
|
59 |
return model.load_model("t5", "snrspeaks/t5-one-line-summary")
|
60 |
|
61 |
|
62 |
-
@st.cache
|
63 |
def classify_category():
|
64 |
tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
|
65 |
new_model = load_model("model")
|
@@ -75,16 +74,15 @@ summarizer_option = st.selectbox(
|
|
75 |
("Custom trained on the dataset", "t5-base", "t5-one-line-summary"),
|
76 |
)
|
77 |
classification = st.checkbox("Classify Category", value=True)
|
78 |
-
|
79 |
-
<style>
|
80 |
-
#MainMenu {visibility: hidden;}
|
81 |
-
footer {visibility: hidden;}
|
82 |
-
</style>
|
83 |
-
"""
|
84 |
-
# st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
85 |
-
st.write(st.__version__)
|
86 |
-
st.write(pip.__version__)
|
87 |
ps = st.empty()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
if st.button("Process",type="primary"):
|
89 |
cancel_button=st.empty()
|
90 |
cancel_button2=st.empty()
|
|
|
1 |
+
|
|
|
2 |
|
3 |
import streamlit as st
|
4 |
import pandas as pd
|
|
|
34 |
13: "WiFi",
|
35 |
}
|
36 |
|
37 |
+
@st.cache(suppress_st_warning=True)
|
38 |
def load_t5():
|
39 |
model = AutoModelForSeq2SeqLM.from_pretrained("t5-base")
|
40 |
|
|
|
42 |
return model, tokenizer
|
43 |
|
44 |
|
45 |
+
@st.cache(suppress_st_warning=True)
|
46 |
def custom_model():
|
47 |
return pipeline("summarization", model="my_awesome_sum/")
|
48 |
|
49 |
|
50 |
+
@st.cache(suppress_st_warning=True)
|
51 |
def convert_df(df):
|
52 |
# IMPORTANT: Cache the conversion to prevent computation on every rerun
|
53 |
return df.to_csv(index=False).encode("utf-8")
|
54 |
|
55 |
|
56 |
+
@st.cache(suppress_st_warning=True)
|
57 |
def load_one_line_summarizer(model):
|
58 |
return model.load_model("t5", "snrspeaks/t5-one-line-summary")
|
59 |
|
60 |
|
61 |
+
@st.cache(suppress_st_warning=True)
|
62 |
def classify_category():
|
63 |
tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
|
64 |
new_model = load_model("model")
|
|
|
74 |
("Custom trained on the dataset", "t5-base", "t5-one-line-summary"),
|
75 |
)
|
76 |
classification = st.checkbox("Classify Category", value=True)
|
77 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
ps = st.empty()
|
79 |
+
cache_button=st.empty()
|
80 |
+
msg=st.empty()
|
81 |
+
if cache_button.button("Clear"):
|
82 |
+
caching.clear_cache()
|
83 |
+
st.balloons()
|
84 |
+
msg.error("Cache is cleared, please reload to scrape new values")
|
85 |
+
|
86 |
if st.button("Process",type="primary"):
|
87 |
cancel_button=st.empty()
|
88 |
cancel_button2=st.empty()
|