Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding caching to streamlit demos #14232

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b5ea36d
Delete examples/demos/streamlit/CLIPForZeroShotClassification/inputs …
AbdullahMubeenAnwar Apr 7, 2024
806331e
Add files via upload
AbdullahMubeenAnwar Apr 7, 2024
bb166ad
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
5e4da28
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
e99c91d
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
9404550
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
c52fa94
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
0fc3097
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
43fc87b
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
61e947d
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
784e031
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
1321047
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
7409c6d
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
9f6da69
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
6b10fc4
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
b46ab4a
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
cc70e29
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
410addd
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
a1d6723
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
02ad1d1
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
42078fc
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
db53093
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
11ac274
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
ff71363
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
24a6f94
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
48eadf4
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
9f9812f
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
dcf223b
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
4b51194
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
3542f2b
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
f7dd451
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
d06fb05
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
b5eaa22
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
b74d6e7
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
41006b2
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
692f321
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
724ccfa
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
fbe28bf
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
9d07b25
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
50933f3
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
84c3172
Update streamlit_app.py
AbdullahMubeenAnwar Apr 7, 2024
62507ef
Delete examples/demos/streamlit/run_demos.ipynb
AbdullahMubeenAnwar Apr 7, 2024
c46681e
Add files via upload
AbdullahMubeenAnwar Apr 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model, labels):

image_assembler = ImageAssembler() \
Expand Down Expand Up @@ -121,4 +122,4 @@ def save_uploadedfile(uploadedfile):
Pipeline = create_pipeline(model, lables)
output = fit_data(Pipeline, selected_image)

st.markdown(f'This document has been classified as : **{output}**')
st.markdown(f'This document has been classified as : **{output}**')
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
document_assembler = DocumentAssembler()\
.setInputCol("text")\
Expand Down Expand Up @@ -100,4 +101,4 @@ def fit_data(pipeline, data):
output = fit_data(Pipeline, selected_text)

st.subheader('Prediction')
st.write(output)
st.write(output)
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
document_assembler = DocumentAssembler()\
.setInputCol("text")\
Expand Down Expand Up @@ -101,4 +102,4 @@ def fit_data(pipeline, data):
output = fit_data(Pipeline, selected_text)

st.subheader('Prediction')
st.write(output)
st.write(output)
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
documenter = DocumentAssembler()\
.setInputCol("text")\
Expand Down
1 change: 1 addition & 0 deletions examples/demos/streamlit/Sentence Grammer/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
documentAssembler = DocumentAssembler() \
.setInputCol("text") \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
document_assembler = DocumentAssembler()
document_assembler.setInputCol('text')
Expand Down Expand Up @@ -150,4 +151,4 @@ def get_similarity(light_pipeline, input_list):
else:
similarity_str = "not similar"
st.markdown(f'Detected similarity: **{similarity}%**')
st.markdown(f'These sentences are **{similarity_str}**.')
st.markdown(f'These sentences are **{similarity_str}**.')
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
documentAssembler = DocumentAssembler()\
.setInputCol("text")\
Expand Down Expand Up @@ -104,4 +105,4 @@ def fit_data(pipeline, data):
if output.lower() in ['neutral', 'normal']:
st.markdown("""<h3>This seems like a <span style="color: green">{}</span> tweet. <span style="font-size:35px;">&#128515;</span></h3>""".format(output), unsafe_allow_html=True)
elif output.lower() in ['racism', 'sexism']:
st.markdown("""<h3>This seems like a <span style="color: #B64434">{}</span> tweet. <span style="font-size:35px;">&#129324;</span></h3>""".format(output), unsafe_allow_html=True)
st.markdown("""<h3>This seems like a <span style="color: #B64434">{}</span> tweet. <span style="font-size:35px;">&#129324;</span></h3>""".format(output), unsafe_allow_html=True)
1 change: 1 addition & 0 deletions examples/demos/streamlit/Sentiment DA/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
document = DocumentAssembler()\
.setInputCol("text")\
Expand Down
1 change: 1 addition & 0 deletions examples/demos/streamlit/Sentiment DE/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
document = DocumentAssembler()\
.setInputCol("text")\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
documentAssembler = DocumentAssembler()\
.setInputCol("text")\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
document = DocumentAssembler()\
.setInputCol("text")\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
documentAssembler = DocumentAssembler()\
.setInputCol("text")\
Expand Down Expand Up @@ -101,4 +102,4 @@ def fit_data(pipeline, data):
if output in ['neutral', 'normal']:
st.markdown("""<h3>This seems like <span style="color: #209DDC">{}</span> news. <span style="font-size:35px;">&#128578;</span></h3>""".format(output), unsafe_allow_html=True)
elif output == 'sarcasm':
st.markdown("""<h3>This seems like a <span style="color: #B64434">{}</span> tweet. <span style="font-size:35px;">&#128579;</span></h3>""".format('sarcastic'), unsafe_allow_html=True)
st.markdown("""<h3>This seems like a <span style="color: #B64434">{}</span> tweet. <span style="font-size:35px;">&#128579;</span></h3>""".format('sarcastic'), unsafe_allow_html=True)
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
documentAssembler = DocumentAssembler() \
.setInputCol("text") \
Expand Down
1 change: 1 addition & 0 deletions examples/demos/streamlit/Sentiment EN/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
documentAssembler = DocumentAssembler()\
.setInputCol("text")\
Expand Down
1 change: 1 addition & 0 deletions examples/demos/streamlit/Sentiment FR/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
document = DocumentAssembler()\
.setInputCol("text")\
Expand Down
1 change: 1 addition & 0 deletions examples/demos/streamlit/Sentiment SW/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
document_assembler = DocumentAssembler() \
.setInputCol("text") \
Expand Down
1 change: 1 addition & 0 deletions examples/demos/streamlit/Sentiment TR/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
document = DocumentAssembler()\
.setInputCol("text")\
Expand Down
1 change: 1 addition & 0 deletions examples/demos/streamlit/Sentiment UR/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
document_assembler = DocumentAssembler()\
.setInputCol("text")\
Expand Down
1 change: 1 addition & 0 deletions examples/demos/streamlit/Sentiment VI/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
document = DocumentAssembler()\
.setInputCol("text")\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):

audio_assembler = AudioAssembler() \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):

audio_assembler = AudioAssembler() \
Expand Down
1 change: 1 addition & 0 deletions examples/demos/streamlit/Spell Checker EN/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline():

document_assembler = DocumentAssembler()\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model, language):

documentAssembler = DocumentAssembler() \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model, language):

documentAssembler = DocumentAssembler() \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model, language):

documentAssembler = DocumentAssembler() \
Expand Down
1 change: 1 addition & 0 deletions examples/demos/streamlit/StopWords Indian/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
documenter = DocumentAssembler()\
.setInputCol("text")\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model, language):

documentAssembler = DocumentAssembler() \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model, task):
documentAssembler = DocumentAssembler() \
.setInputCol("text") \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model, task):
documentAssembler = DocumentAssembler() \
.setInputCol("text") \
Expand Down
1 change: 1 addition & 0 deletions examples/demos/streamlit/T5 Grammer/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
documentAssembler = DocumentAssembler() \
.setInputCol("text") \
Expand Down
1 change: 1 addition & 0 deletions examples/demos/streamlit/T5 Linguistic/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
documentAssembler = DocumentAssembler() \
.setInputCol("text") \
Expand Down
1 change: 1 addition & 0 deletions examples/demos/streamlit/T5 SQL/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
documentAssembler = DocumentAssembler() \
.setInputCol("text") \
Expand Down
1 change: 1 addition & 0 deletions examples/demos/streamlit/Text Finder EN/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model, matches):
documentAssembler = DocumentAssembler()\
.setInputCol("text")\
Expand Down
3 changes: 2 additions & 1 deletion examples/demos/streamlit/Text Preprocessing/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model, language):

documentAssembler = DocumentAssembler()\
Expand Down Expand Up @@ -171,4 +172,4 @@ def fit_data(pipeline, data):
if selected_models[5] is True:
tcol_arr = np.asarray(df['removed_stopwords'].values[0])[:,3]
st.subheader("Tokens after removing Stop Words:")
st.dataframe(pd.DataFrame({'removed_stopwords':tcol_arr}))
st.dataframe(pd.DataFrame({'removed_stopwords':tcol_arr}))
3 changes: 2 additions & 1 deletion examples/demos/streamlit/Text Summarization/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
document_assembler = DocumentAssembler()\
.setInputCol("text")\
Expand Down Expand Up @@ -98,4 +99,4 @@ def fit_data(pipeline, data):

Pipeline = create_pipeline(model)
output = fit_data(Pipeline, selected_text)
st.write(output)
st.write(output)
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model, max_out_length):
document_assembler = DocumentAssembler()\
.setInputCol("text")\
Expand Down Expand Up @@ -103,4 +104,4 @@ def fit_data(pipeline, data):

Pipeline = create_pipeline(model, max_out_length)
output = fit_data(Pipeline, selected_text)
st.write(output)
st.write(output)
3 changes: 2 additions & 1 deletion examples/demos/streamlit/Translation Marian/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):
documentAssembler = DocumentAssembler()\
.setInputCol("text")\
Expand Down Expand Up @@ -122,4 +123,4 @@ def fit_data(pipeline, data):

Pipeline = create_pipeline(selected_model)
output = fit_data(Pipeline, selected_text)
st.write(output)
st.write(output)
1 change: 1 addition & 0 deletions examples/demos/streamlit/Typo Detector/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline():

documentAssembler = DocumentAssembler()\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

spark = sparknlp.start()

@st.cache_resource
def create_pipeline(model):

image_assembler = ImageAssembler() \
Expand Down Expand Up @@ -113,4 +114,4 @@ def save_uploadedfile(uploadedfile):
Pipeline = create_pipeline(model)
output = fit_data(Pipeline, selected_image)

st.markdown(f'This document has been classified as : **{output}**')
st.markdown(f'This document has been classified as : **{output}**')