Regino commited on
Commit
1c11257
·
1 Parent(s): 75f3ebe

updated code'

Browse files
Files changed (1) hide show
  1. app.py +23 -12
app.py CHANGED
@@ -1,18 +1,29 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- # Force PyTorch backend
5
- summarizer = pipeline("summarization", model="facebook/bart-large-cnn", framework="pt")
 
 
 
 
6
 
7
- st.title("Text Summarization App")
 
8
 
9
- # Input text
10
- text = st.text_area("Enter your text:", "")
11
 
12
- if st.button("Summarize"):
13
- if text:
14
- summary = summarizer(text, max_length=50, min_length=10, do_sample=False)
15
- st.subheader("Summary:")
16
- st.write(summary[0]["summary_text"])
17
- else:
18
- st.warning("Please enter some text.")
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ # Set page title and description
5
+ st.title("📄 Text Summarization App")
6
+ st.write("""
7
+ This app allows users to upload a text file and get a summarized version using a Natural Language Processing (NLP) model.
8
+ It uses the `transformers` library from Hugging Face, which provides state-of-the-art machine learning models.
9
+ """)
10
 
11
+ # Load summarization pipeline
12
+ summarizer = pipeline("summarization")
13
 
14
+ # File uploader
15
+ uploaded_file = st.file_uploader("Upload a text file", type=["txt"])
16
 
17
+ if uploaded_file is not None:
18
+ # Read the file content
19
+ text = uploaded_file.read().decode("utf-8")
20
+
21
+ # Display original text (optional)
22
+ st.subheader("Original Text")
23
+ st.text_area("Content:", text, height=200)
24
+
25
+ # Summarize the text
26
+ if st.button("Summarize"):
27
+ summary = summarizer(text, max_length=150, min_length=50, do_sample=False)
28
+ st.subheader("Summarized Text")
29
+ st.write(summary[0]['summary_text'])