File size: 511 Bytes
e8e4ff3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from transformers import pipeline
import gradio as gr

# Initialize the summarization model using a PyTorch-based model
model = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")

def predict(prompt):
    summary = model(prompt)[0]['summary_text']
    return summary

# Build the Gradio interface
with gr.Blocks() as demo:
    textbox = gr.Textbox(placeholder="Enter text block to summarize", lines=4)
    gr.Interface(fn=predict, inputs=textbox, outputs="text")

# Launch the demo
demo.launch()