File size: 751 Bytes
09b983a
d6c533e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
!pip install torch
import torch
import gradio as gr
# Use a pipeline as a high-level helper
from transformers import pipeline

# Initialize the summarization pipeline
pipe = pipeline("summarization", model="Falconsai/text_summarization", torch_dtype=torch.float16)

# Define the summarize function
def summarize(input):
    output = pipe(input)
    return output[0]['summary_text']

# Define the Gradio interface
iface = gr.Interface(
    fn=summarize,
    inputs=gr.Textbox(lines=10, placeholder="Enter text to summarize here..."),
    outputs="text",
    title="Text Summarizer",
    description="Enter a long piece of text, and the summarizer will provide a concise summary."
)

# Launch the interface
if __name__ == "__main__":
    iface.launch()