Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
summarizer = pipeline(
|
5 |
+
"summarization",
|
6 |
+
'pszemraj/led-large-book-summary'
|
7 |
+
)
|
8 |
+
|
9 |
+
def summarizer(text):
|
10 |
+
result = summarizer(
|
11 |
+
text,
|
12 |
+
min_length=16,
|
13 |
+
max_length=256,
|
14 |
+
no_repeat_ngram_size=3,
|
15 |
+
encoder_no_repeat_ngram_size=3,
|
16 |
+
repetition_penalty=3.5,
|
17 |
+
num_beams=4,
|
18 |
+
early_stopping=True,
|
19 |
+
)
|
20 |
+
|
21 |
+
with gr.Blocks() as demo:
|
22 |
+
gr.Markdown("#Text-to-Image Generator")
|
23 |
+
text = gr.Textbox(label="Text Input", placeholder="Enter your text......")
|
24 |
+
submit_btn = gr.Button("Summarize")
|
25 |
+
summary = gr.Textbox(label="Summary")
|
26 |
+
submit_btn.click(fn=summarizer, inputs=text, outputs=summary)
|
27 |
+
demo.launch()
|