File size: 578 Bytes
12199af
 
 
7f8b8e9
12199af
 
 
 
 
7f8b8e9
12199af
 
 
 
248316d
12199af
 
 
2d9ae00
 
12199af
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from transformers import pipeline
import gradio as gr

summarize = pipeline("summarization", model='t5-base', tokenizer='t5-small', truncation=True, framework='tf')

def translate(text):
    text = text.replace('"', '"')
    text = text.replace(''', "'")
    text = text.replace('&', '&')
    result = summarize(text, min_length=180, truncation=True)
    return result[0]["summary_text"]

iface = gr.Interface(
    fn=translate,
    inputs=gr.inputs.Textbox(lines=10, placeholder="Enter text to summarize and hit enter"),
    outputs="text"
)


iface.launch()