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

TextSummarization In continuation to PR #156 #183

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ websockets==13.0.1
torch==2.3.0
ultralytics==8.3.3
diffusers==0.30.3
transformers==4.42.4
transformers==4.45.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import streamlit as st
from transformers import pipeline

def textSummarizationModel():
# Title of the web app
st.title("Text Summarization Tool")

# Load the summarization model
@st.cache_resource(show_spinner=True) # Cache the model loading for faster performance
def load_summarizer():
return pipeline("summarization", model="t5-small")

summarizer = load_summarizer()

# Instructions for users
st.write("Enter the text you'd like to summarize (minimum 50 words).")

# Create a text area for the user to input text
user_input = st.text_area("Input Text", height=200)

# 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..."):
# Generate the summary
summary = summarizer(user_input, max_length=150, min_length=30, do_sample=False)
# Display the summarized text
st.subheader("Summary:")
st.write(summary[0]['summary_text'])