File size: 595 Bytes
4b5f72d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# import libraries
import gradio as gr
import torch
import transformers
from transformers import pipeline

# define summarizer function
def summarizer(text):
    summarizer = pipeline("summarization")
    summary = summarizer(text, max_length=100, min_length=30, do_sample=False)
    return summary

# define input and output
inputs = gr.inputs.Textbox(lines=5, label="Enter text to summarize")
outputs = gr.outputs.Textbox(label="Summary")

# define interface
interface = gr.Interface(summarizer, inputs, outputs, live=True, capture_session=True)

# run interface
interface.launch(inline=False)