my_first_space / app.py
citizenbu's picture
Update app.py
852626d
# 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()