Skip to content

Commit

Permalink
Update Text Summarizer.py
Browse files Browse the repository at this point in the history
  • Loading branch information
yashasvini121 authored Oct 19, 2024
1 parent 5ff0d17 commit 7f86ba2
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions pages/Text Summarizer.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
import streamlit as st
from transformers import pipeline
from models.text_sumarization.predict import generate_summary

# 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)
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..."):
# 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'])
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)

0 comments on commit 7f86ba2

Please sign in to comment.