Spaces:
Sleeping
Sleeping
Iniitial commit
Browse files- README.md +4 -0
- app.py +15 -0
- requirements.txt +3 -0
README.md
CHANGED
|
@@ -12,3 +12,7 @@ short_description: Summarize the section of the block
|
|
| 12 |
---
|
| 13 |
|
| 14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
| 15 |
+
|
| 16 |
+
# Text Summarizer
|
| 17 |
+
|
| 18 |
+
Summarizes long text using the BART model from Hugging Face.
|
app.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
summarizer = pipeline("Summarization", model="facebook/bart-large-cnn")
|
| 5 |
+
|
| 6 |
+
def summarize_text(text):
|
| 7 |
+
summary = summarizer(text, max_length=130, min_length=30, do_sample=False)
|
| 8 |
+
return summary[0]['summary_text']
|
| 9 |
+
|
| 10 |
+
iface = gr.Interface(fn=summarize_text,
|
| 11 |
+
inputs=gr.Textbox(lines=10, placeholder="Enter text to summarize..."),
|
| 12 |
+
outputs="text",
|
| 13 |
+
title="Text Summarizer",
|
| 14 |
+
description="Summarize long text using BART model.")
|
| 15 |
+
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
gradio
|
| 3 |
+
torch
|