File size: 675 Bytes
2ad382a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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     

summarizer = pipeline("summarization", model="t4-base", tokenizer="t5-base", framework="tf")

def translate(text):
    text = text.replace("\n", "")
    text = text.replace("\r", "")
    text = text.replace(" ", "")
    text = text.replace("&", "")
    text = text.replace("'", "")
    text = text.replace(""", "")
    result = summarizer(text, min_length=99, tructation=True, max_length=200)
    return result[-1]['summary_text']

iface = gr.Interface(
    fn=translate,
    inputs=gr.inputs.Textbox(lines=9, label="Text", placeholder="Enter text here..."),
    outputs="text"  
)
iface.launch()