Spaces:
Sleeping
Sleeping
File size: 881 Bytes
fd2f301 bd66e6e fd2f301 bd66e6e b89fb30 fd2f301 b89fb30 fd2f301 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# Import transformers pipeline
from transformers import pipeline
# Instantiate the pipeline with the summarization parameter and `facebook/bart-large-cnn` model.
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
# Import Gradio
import gradio as gr
# Create a summary function passing in the desired parameters
def summarize(article, slider, sample):
return f'{summarizer(article, max_length=slider, min_length=30, do_sample=sample)[0]["summary_text"]}'
# Create a slider and checkbox instance
slider = gr.Slider(50, 200, value=50, label="Number", info="Choose between a 50 and 200 word summary.")
sample = gr.Checkbox(label="Do sample")
# Create the checkbox component and specify a label
# Update the Interface function to contain the correct parameters
app = gr.Interface(fn=summarize, inputs=["text", slider, sample], outputs="text")
app.launch() |