Spaces:
Sleeping
Sleeping
Commit
·
0a6da1c
1
Parent(s):
7b46147
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,23 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
| 5 |
-
summarizer = pipeline("summarization", model="Falconsai/text_summarization")
|
| 6 |
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
def summarize(input):
|
| 10 |
-
|
| 11 |
-
output = summarizer(
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
return output
|
| 14 |
|
| 15 |
demo = gr.Interface(fn=summarize, inputs="text", outputs="text")
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
+
summarizer = pipeline("summarization", "jordiclive/flan-t5-3b-summarizer", torch_dtype=torch.bfloat16)
|
|
|
|
| 6 |
|
| 7 |
+
raw_document = 'You must be 18 years old to live or work in New York State...'
|
| 8 |
+
prompt = "Produce an article summary of the following news article:"
|
| 9 |
|
| 10 |
def summarize(input):
|
| 11 |
+
|
| 12 |
+
output = summarizer(
|
| 13 |
+
f"{prompt} {input}",
|
| 14 |
+
num_beams=5,
|
| 15 |
+
min_length=5,
|
| 16 |
+
no_repeat_ngram_size=3,
|
| 17 |
+
truncation=True,
|
| 18 |
+
max_length=512,
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
return output
|
| 22 |
|
| 23 |
demo = gr.Interface(fn=summarize, inputs="text", outputs="text")
|