File size: 1,301 Bytes
e7ed007 515cb5a e7ed007 de887f0 e7ed007 fa161ca e7ed007 9c494b8 e7ed007 90f52b2 | 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | from newspaper import Article
from newspaper import Config
import nltk
nltk.download('punkt')
from transformers import pipeline
import gradio as gr
from gradio.mix import Parallel, Series
def auto_link(url):
USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0'
configuration = Config()
configuration.browser_user_agent = USER_AGENT
configuration.request_timeout = 10
abstract = Article(url, config =configuration)
abstract.download()
abstract.parse()
text = abstract.text
return text
extract = gr.Interface(auto_link, 'text', 'text')
abstractive_summarization = gr.Interface.load("huggingface/facebook/bart-large-cnn")
example_urls = [['https://www.ibm.com/cloud/learn/machine-learning/'],
['https://www.cnn.com/2021/11/24/us/arctic-ocean-early-warming-climate/index.html/'],
['https://www.britannica.com/topic/Pyramids-of-Giza']]
title = '''
summarizeer
'''
UI_summarizer = Series(extract, abstractive_summarization, inputs = gr.inputs.Textbox (lines = 2, label = 'URL'),
outputs = 'text', title = 'Summarization', theme = 'huggingface', description = title,
examples= example_urls)
UI_summarizer.launch(inline = False)
|