Spaces:
Sleeping
Sleeping
File size: 909 Bytes
425a64e 3e4a8b7 562f97c 425a64e fd5f76d 40d1ff8 562f97c 425a64e 7e6cf49 425a64e 7e6cf49 425a64e |
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 |
# Import libraries
import gradio as gr
import torch as torch
from transformers import pipeline
# Create a summarization pipeline
# summarizer = pipeline("summarization")
#text_summery = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
text_summery = pipeline("summarization", model="sshleifer/distilbart-cnn-6-6")
#text_summery = pipeline("summarization", model="facebook/bart-large-cnn")
#text_summery = pipeline("summarization", model="google/pegasus-xsum")
# Define a function that takes a text and returns a summary
def summarize(text):
summary = text_summery(text, max_length=250, min_length=40, do_sample=False)[0]
return summary["summary_text"]
# Create a Gradio interface
interface = gr.Interface(
fn=summarize, # the function to wrap
inputs=gr.Textbox(lines=20, label="Text to Summarize"),
outputs=gr.Textbox(label="Summary")
)
# Launch the interface
interface.launch() |