diff --git a/App.py b/App.py index dd8f9180..cc5ab1aa 100644 --- a/App.py +++ b/App.py @@ -107,3 +107,16 @@ - **GLD**: The price of SPDR Gold Shares (GLD), which is the target variable representing gold prices. """ ) + +#Text Summarization Section + +st.write( + "- *Text Summarizer*: Save time with concise, professional summaries of lengthy texts—tailored to meet your needs and streamline your reading experience." +) +with st.expander("Text Summarizer - More Information"): + st.subheader("Introduction") + st.write( + """ + Many struggle with summarizing large texts or learning from lengthy materials. This model simplifies the process, offering concise summaries that enhance understanding and speed up learning—perfect for students and professionals alike. + """ + ) \ No newline at end of file diff --git a/models/text_sumarization/predict.py b/models/text_sumarization/predict.py new file mode 100644 index 00000000..826801ce --- /dev/null +++ b/models/text_sumarization/predict.py @@ -0,0 +1,13 @@ +from transformers import pipeline +import streamlit as st + +@st.cache_resource(show_spinner=True) # Cache the model loading for faster performance +def load_summarizer(): + """Load and cache the text summarization pipeline model.""" + return pipeline("summarization", model="t5-small") + +def generate_summary(text: str) -> str: + """Generate a summary for the given input text.""" + summarizer = load_summarizer() + summary = summarizer(text, max_length=150, min_length=30, do_sample=False) + return summary[0]["summary_text"] diff --git a/pages/Text Summarizer.py b/pages/Text Summarizer.py new file mode 100644 index 00000000..58a1a502 --- /dev/null +++ b/pages/Text Summarizer.py @@ -0,0 +1,19 @@ +import streamlit as st +from models.text_sumarization.predict import generate_summary + +st.title("Text Summarization Tool") + +st.write("Enter the text you'd like to summarize (minimum 50 words).") + +user_input = st.text_area("Input Text", height=250) + +# A button to initiate the summarization process +if st.button("Summarize"): + if len(user_input.split()) < 50: + st.warning("Please enter at least 50 words for summarization.") + else: + # Show a spinner while the summarization is being processed + with st.spinner("Summarizing..."): + summary = generate_summary(user_input) # Call the function from predict.py + st.subheader("Summary:") + st.code(summary, language="text", wrap_lines=True) diff --git a/requirements.txt b/requirements.txt index d43fe9e5..ac7563bf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -63,7 +63,7 @@ matplotlib-inline==0.1.7 mdurl==0.1.2 mistune==3.0.2 narwhals==1.8.1 -numpy==2.1.1 +numpy openpyxl==3.1.5 overrides==7.7.0 packaging==24.1 @@ -78,7 +78,7 @@ pluggy==1.5.0 prometheus_client==0.20.0 prompt_toolkit==3.0.47 prophet==1.1.6 -protobuf==5.28.2 +protobuf==4.25.5 psutil==6.0.0 pure_eval==0.2.3 pyarrow==17.0.0 @@ -138,3 +138,5 @@ webcolors==24.8.0 webencodings==0.5.1 websocket-client==1.8.0 xgboost==2.1.1 +transformers==4.45.2 +tf_keras==2.17.0