Spaces:
Build error
Build error
Regino
commited on
Commit
·
1c11257
1
Parent(s):
75f3ebe
updated code'
Browse files
app.py
CHANGED
|
@@ -1,18 +1,29 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
|
| 12 |
-
if
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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'])
|