File size: 831 Bytes
6dcf513
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import streamlit as st
from transformers import pipeline

# Load summarization pipeline
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")

def main():
    st.title("Text Summarizer")

    # Input text area
    article = st.text_area("Enter the article:")

    # Button to generate summary
    if st.button("Generate Summary"):
        # Check if the article is not empty
        if article:
            # Generate summary using the BART model
            summary = summarizer(article, max_length=130, min_length=30, do_sample=False)[0]['summary_text']
            

            # Display the generated summary
            st.subheader("Summary:")
            st.write(summary)
        else:
            st.warning("Please enter an article before generating a summary.")

if __name__ == "__main__":
    main()