File size: 609 Bytes
4c54775
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0c1eda5
 
4c54775
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
from transformers import pipeline

summarizer = 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 = summarizer(text, min_length=180, truncation=True)
    return result[0]["summary_text"]

# To create interface.
iface = gr.Interface(
    fn=translate, # name of the function app. 
    inputs=gr.Textbox(lines=10, placeholder="Enter text to summarize..."),
    outputs=gr.Textbox() 
)
iface.launch()