File size: 779 Bytes
ae4db4c
 
 
1caf530
3142597
ae4db4c
1caf530
ae4db4c
 
 
 
 
 
 
1caf530
ae4db4c
 
1caf530
0023667
ae4db4c
1caf530
 
b0601d0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from transformers import pipeline
import gradio as gr

# Define the summarizer using the transformers pipeline
summarizer = pipeline("summarization", model="google-t5/t5-small", tokenizer="google-t5/t5-small", truncation=True, framework="tf")

# Define the function to process the text and return the summary
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']

# Create the Gradio interface with updated syntax
iface = gr.Interface(
    fn=translate,
    inputs=gr.Textbox(lines=10, placeholder="Enter text to summarize..."),
    outputs=gr.Textbox()
)

# Launch the Gradio app
iface.launch()