Commit
•
38b73e2
1
Parent(s):
ce1527e
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,13 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
-
|
|
|
|
|
3 |
|
4 |
-
|
5 |
-
model = AutoModelForSeq2SeqLM.from_pretrained("achimoraites/flan-t5-base-samsum")
|
6 |
|
7 |
-
def summarize(text
|
8 |
-
|
9 |
-
summary_ids = model.generate(inputs["input_ids"], num_beams=num_beams, min_length=0, max_length=max_length)
|
10 |
-
return tokenizer.batch_decode(summary_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
11 |
|
12 |
-
gr.Interface(fn=summarize, inputs="text", outputs="text", live=False)
|
|
|
|
1 |
+
|
2 |
import gradio as gr
|
3 |
+
import torch
|
4 |
+
import transformers
|
5 |
+
from transformers import pipeline
|
6 |
|
7 |
+
summarizer = pipeline("summarization", model="achimoraites/flan-t5-base-samsum")
|
|
|
8 |
|
9 |
+
def summarize(text):
|
10 |
+
return summarizer(text, max_length=100, min_length=30)[0]['summary_text']
|
|
|
|
|
11 |
|
12 |
+
iface = gr.Interface(fn=summarize, inputs="text", outputs="text", live=False, capture_session=True)
|
13 |
+
iface.launch(inline = False)
|