|
import streamlit as st |
|
from transformers import pipeline |
|
|
|
|
|
summarizer = pipeline("summarization", model="google/pegasus-xsum") |
|
|
|
|
|
def main(): |
|
st.title("Text Summarization App") |
|
|
|
|
|
user_input = st.text_area("Enter your text for summarization:") |
|
|
|
if st.button("Generate Summary"): |
|
if user_input: |
|
|
|
summary = summarizer(user_input, max_length=150, min_length=50, length_penalty=2.0, num_beams=4)[0]['summary_text'] |
|
|
|
|
|
st.write("Summary:") |
|
st.write(summary) |
|
else: |
|
st.warning("Please enter some text for summarization.") |
|
|
|
if __name__ == "__main__": |
|
main() |
|
|