|
from transformers import pipeline |
|
import gradio as gr |
|
import torch |
|
|
|
def textSummarizer(ARTICLE,MaxTokens,MinTokens): |
|
summarizer = pipeline("summarization", model="facebook/bart-large-cnn") |
|
result = summarizer(ARTICLE, max_length=MaxTokens, min_length=MinTokens, do_sample=False) |
|
return result[0]["summary_text"] |
|
|
|
|
|
app = gr.Interface(textSummarizer, |
|
inputs = [gr.Textbox(), |
|
gr.Slider(minimum=0,maximum=500,step=2), |
|
gr.Slider(minimum=0,maximum=100,step=1)], |
|
outputs = gr.Textbox(), |
|
title = "Article Summarizer", |
|
theme=gr.themes.Soft()) |
|
|
|
app.launch() |