File size: 550 Bytes
ca51f45
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from transformers import pipeline 
import gradio as gr
summarizer = pipeline("summarization",model="t5-base",tokenizer="t5-smaller",truncation=True,framework="tf")

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

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

iface.launch()