Spaces:
Runtime error
Runtime error
Gbadamosi_oluwaseyi
commited on
Commit
•
092f4eb
1
Parent(s):
5d0397c
commit
Browse files- .streamlit/config.toml +6 -0
- __pycache__/function.cpython-38.pyc +0 -0
- app.py +32 -53
- favicon/favicon.ico +0 -0
- requirements.txt +1 -2
.streamlit/config.toml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[theme]
|
2 |
+
# primaryColor="#d33682"
|
3 |
+
# backgroundColor="#002b36"
|
4 |
+
# secondaryBackgroundColor="#586e75"
|
5 |
+
# textColor="#fafafa"
|
6 |
+
# font="sans serif"
|
__pycache__/function.cpython-38.pyc
ADDED
Binary file (3.17 kB). View file
|
|
app.py
CHANGED
@@ -9,29 +9,47 @@ from wordcloud import WordCloud
|
|
9 |
from datetime import datetime
|
10 |
warnings.filterwarnings("ignore")
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
st.set_option('deprecation.showPyplotGlobalUse', False)
|
13 |
|
14 |
def main():
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
st.
|
|
|
|
|
|
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
model_type = st.sidebar.selectbox("Model type", options=["Bart","T5"])
|
28 |
|
|
|
29 |
upload_doc = st.file_uploader("Upload a .txt, .pdf, .docx file for summarization")
|
30 |
|
31 |
-
st.markdown("<h3 style='text-align: center; color:
|
32 |
|
|
|
33 |
plain_text = st.text_area("Type your Message...",height=200)
|
34 |
|
|
|
35 |
if upload_doc:
|
36 |
clean_text = preprocess_plain_text(extract_text_from_file(upload_doc))
|
37 |
else:
|
@@ -47,12 +65,8 @@ def main():
|
|
47 |
with st.spinner(
|
48 |
text="Loading Bart Model and Extracting summary. This might take a few seconds depending on the length of your text..."):
|
49 |
summarizer_model = bart()
|
50 |
-
summarized_text = summarizer_model(text_to_summarize, max_length=
|
51 |
summarized_text = ' '.join([summ['summary_text'] for summ in summarized_text])
|
52 |
-
st.success("Data Submitted for model retraining")
|
53 |
-
postdate = datetime.now()
|
54 |
-
# Add Data To Database
|
55 |
-
add_data(text_to_summarize,summarized_text,postdate)
|
56 |
|
57 |
elif model_type == "T5":
|
58 |
text_to_summarize = clean_text
|
@@ -60,26 +74,9 @@ def main():
|
|
60 |
with st.spinner(
|
61 |
text="Loading T5 Model and Extracting summary. This might take a few seconds depending on the length of your text..."):
|
62 |
summarizer_model = t5()
|
63 |
-
summarized_text = summarizer_model(text_to_summarize, max_length=
|
64 |
summarized_text = ' '.join([summ['summary_text'] for summ in summarized_text])
|
65 |
-
st.success("Data Submitted for model retraining")
|
66 |
-
postdate = datetime.now()
|
67 |
-
# Add Data To Database
|
68 |
-
add_data(text_to_summarize,summarized_text,postdate)
|
69 |
-
|
70 |
-
# else:
|
71 |
-
# text_to_summarize = clean_text
|
72 |
|
73 |
-
# with st.spinner(
|
74 |
-
# text="Loading Pegasus Model and Extracting summary. This might take a few seconds depending on the length of your text..."):
|
75 |
-
# summarizer_model = pegasus()
|
76 |
-
# summarized_text = summarizer_model(text_to_summarize, max_length=100, min_length=30)
|
77 |
-
# # summarized_text = ' '.join([summ['summary_text'] for summ in summarized_text])
|
78 |
-
# st.success("Data Submitted for model retraining")
|
79 |
-
# postdate = datetime.now()
|
80 |
-
# # Add Data To Database
|
81 |
-
# # add_data(text_to_summarize,summarized_text,postdate)
|
82 |
-
|
83 |
res_col1 ,res_col2 = st.columns(2)
|
84 |
with res_col1:
|
85 |
st.subheader("Generated Text Visualization")
|
@@ -96,24 +93,6 @@ def main():
|
|
96 |
st.subheader("Summarized Text Output")
|
97 |
st.success("Summarized Text")
|
98 |
st.write(summarized_text)
|
99 |
-
|
100 |
-
elif choice == "Storage":
|
101 |
-
st.title("Manage & Monitor Results")
|
102 |
-
# stored_data = view_all_data()
|
103 |
-
# new_df = pd.DataFrame(stored_data,columns=["text_to_summarize","summarized_text","postdate"])
|
104 |
-
# st.dataframe(new_df)
|
105 |
-
# new_df['postdate'] = pd.to_datetime(new_df['postdate'])
|
106 |
-
|
107 |
-
|
108 |
-
else:
|
109 |
-
st.subheader("About")
|
110 |
-
# html_temp ="""<div>
|
111 |
-
# <p></p>
|
112 |
-
# <p></p>
|
113 |
-
# </div>"""
|
114 |
-
# st.markdown(html_temp, unsafe_allow_html=True)
|
115 |
-
|
116 |
-
|
117 |
|
118 |
if __name__ == '__main__':
|
119 |
main()
|
|
|
9 |
from datetime import datetime
|
10 |
warnings.filterwarnings("ignore")
|
11 |
|
12 |
+
# page info setup
|
13 |
+
menu_items = {
|
14 |
+
'Get help':'https://www.linkedin.com/in/oluwaseyi-gbadamosi-41015216b/' ,
|
15 |
+
'Report a bug': 'https://www.linkedin.com/in/oluwaseyi-gbadamosi-41015216b/',
|
16 |
+
'About': '''
|
17 |
+
## My Custom App
|
18 |
+
|
19 |
+
Some markdown to show in the About dialog.
|
20 |
+
'''
|
21 |
+
}
|
22 |
+
#page configuration
|
23 |
+
st.set_page_config(page_title="Article Summerizer", page_icon="./favicon/favicon.ico",menu_items=menu_items)
|
24 |
st.set_option('deprecation.showPyplotGlobalUse', False)
|
25 |
|
26 |
def main():
|
27 |
+
# This is used to hide the made with streamlit watermark
|
28 |
+
hide_streamlit_style = """
|
29 |
+
<style>
|
30 |
+
footer {visibility: hidden;}
|
31 |
+
</style>
|
32 |
+
"""
|
33 |
+
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
34 |
+
|
35 |
+
# Article Summerizer heading
|
36 |
+
st.markdown("<h1 style = 'color:gold; align:center; font-size: 40px;'> Article Summerizer</h1>", unsafe_allow_html=True)
|
37 |
|
38 |
+
# control for Model Settings
|
39 |
+
st.sidebar.markdown("<h4 style = 'color:gold; align:center; font-size: 20px;'> Model Settings</h1>", unsafe_allow_html=True)
|
40 |
+
max_length= st.sidebar.number_input("Maximum length of the generated text is 200 tokens",max_value=200)
|
41 |
+
min_length= st.sidebar.number_input("Maximum length of the generated text",min_value=30)
|
42 |
model_type = st.sidebar.selectbox("Model type", options=["Bart","T5"])
|
43 |
|
44 |
+
# This function is used to upload a .txt, .pdf, .docx file for summarization
|
45 |
upload_doc = st.file_uploader("Upload a .txt, .pdf, .docx file for summarization")
|
46 |
|
47 |
+
st.markdown("<h3 style='text-align: center; color: gold;'>OR</h3>",unsafe_allow_html=True)
|
48 |
|
49 |
+
#This function is used to Type your Message... (text area)
|
50 |
plain_text = st.text_area("Type your Message...",height=200)
|
51 |
|
52 |
+
# this is used to control the logic of the code
|
53 |
if upload_doc:
|
54 |
clean_text = preprocess_plain_text(extract_text_from_file(upload_doc))
|
55 |
else:
|
|
|
65 |
with st.spinner(
|
66 |
text="Loading Bart Model and Extracting summary. This might take a few seconds depending on the length of your text..."):
|
67 |
summarizer_model = bart()
|
68 |
+
summarized_text = summarizer_model(text_to_summarize, max_length=max_length ,min_length=min_length)
|
69 |
summarized_text = ' '.join([summ['summary_text'] for summ in summarized_text])
|
|
|
|
|
|
|
|
|
70 |
|
71 |
elif model_type == "T5":
|
72 |
text_to_summarize = clean_text
|
|
|
74 |
with st.spinner(
|
75 |
text="Loading T5 Model and Extracting summary. This might take a few seconds depending on the length of your text..."):
|
76 |
summarizer_model = t5()
|
77 |
+
summarized_text = summarizer_model(text_to_summarize, max_length=max_length, min_length=min_length)
|
78 |
summarized_text = ' '.join([summ['summary_text'] for summ in summarized_text])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
res_col1 ,res_col2 = st.columns(2)
|
81 |
with res_col1:
|
82 |
st.subheader("Generated Text Visualization")
|
|
|
93 |
st.subheader("Summarized Text Output")
|
94 |
st.success("Summarized Text")
|
95 |
st.write(summarized_text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
if __name__ == '__main__':
|
98 |
main()
|
favicon/favicon.ico
ADDED
requirements.txt
CHANGED
@@ -3,7 +3,6 @@ pandas==1.3.5
|
|
3 |
PyPDF2==1.26.0
|
4 |
regex==2021.8.28
|
5 |
transformers==4.17.0
|
6 |
-
wordcloud==
|
7 |
torch==1.10.1
|
8 |
streamlit==1.8.1
|
9 |
-
# tensorflow==2.1.0
|
|
|
3 |
PyPDF2==1.26.0
|
4 |
regex==2021.8.28
|
5 |
transformers==4.17.0
|
6 |
+
wordcloud==1.8.1
|
7 |
torch==1.10.1
|
8 |
streamlit==1.8.1
|
|