File size: 710 Bytes
20333e8
 
 
0716b4b
20333e8
 
0716b4b
 
b501b84
20333e8
 
0716b4b
20333e8
 
 
0716b4b
20333e8
0716b4b
b501b84
20333e8
 
 
0716b4b
4fac8f8
0716b4b
b501b84
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from transformers import pipeline
import gradio as gr

# Initialize the summarizer pipeline
summarizer = pipeline("summarization", model="t5-base", tokenizer="t5-small", truncation=True, framework="tf")

def summarize(text):
    # Replace HTML entities
    text = text.replace('"', '"')
    text = text.replace(''', "'")
    text = text.replace('&', "&")
    # Summarize the text
    result = summarizer(text, min_length=100, truncation=True)
    return result[0]["summary_text"]

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

# Launch the Gradio interface
iface.launch()