Spaces:
Sleeping
Sleeping
ibrahimgiki
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,21 @@
|
|
|
|
1 |
from transformers import pipeline
|
2 |
|
|
|
|
|
|
|
3 |
# Load the model and tokenizer from Hugging Face
|
4 |
-
summarizer = pipeline("summarization", model=
|
5 |
|
6 |
-
#
|
7 |
-
|
8 |
-
summary = summarizer(text, max_length=max_length, min_length=min_length, do_sample=do_sample)
|
9 |
-
return summary[0]['summary_text']
|
10 |
|
11 |
-
#
|
12 |
-
|
13 |
-
Your text here. This text should be a long paragraph that you want to summarize.
|
14 |
-
The pipeline will take this text and generate a shorter version of it.
|
15 |
-
"""
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Replace with your actual model URL
|
5 |
+
model_url = "your_hf_username/your_model_name"
|
6 |
+
|
7 |
# Load the model and tokenizer from Hugging Face
|
8 |
+
summarizer = pipeline("summarization", model=model_url)
|
9 |
|
10 |
+
# Streamlit application
|
11 |
+
st.title("Text Summarization with BART")
|
|
|
|
|
12 |
|
13 |
+
# Text input from the user
|
14 |
+
user_input = st.text_area("Enter the text to summarize:")
|
|
|
|
|
|
|
15 |
|
16 |
+
# If user input is provided, summarize the text
|
17 |
+
if user_input:
|
18 |
+
with st.spinner("Summarizing..."):
|
19 |
+
summary = summarizer(user_input, max_length=130, min_length=30, do_sample=False)
|
20 |
+
summarized_text = summary[0]['summary_text']
|
21 |
+
st.text_area("Summary:", summarized_text, height=200)
|