Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
|
| 3 |
+
# Load the model and tokenizer from Hugging Face
|
| 4 |
+
summarizer = pipeline("summarization", model="ibrahimgiki/facebook_bart_base")
|
| 5 |
+
|
| 6 |
+
# Define a function to summarize text
|
| 7 |
+
def summarize_text(text, max_length=130, min_length=30, do_sample=False):
|
| 8 |
+
summary = summarizer(text, max_length=max_length, min_length=min_length, do_sample=do_sample)
|
| 9 |
+
return summary[0]['summary_text']
|
| 10 |
+
|
| 11 |
+
# Example usage
|
| 12 |
+
text = """
|
| 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 |
+
summary = summarize_text(text)
|
| 18 |
+
print("Original Text:", text)
|
| 19 |
+
print("Summary:", summary)
|