Spaces:
Runtime error
Runtime error
Modified app.py
Browse files- app.py +38 -9
- requirements.txt +2 -1
app.py
CHANGED
@@ -1,15 +1,44 @@
|
|
1 |
-
|
2 |
-
from
|
3 |
import gradio as gr
|
4 |
from gradio.mix import Parallel, Series
|
5 |
|
6 |
-
io1 = gr.Interface.load('huggingface/sshleifer/distilbart-cnn-12-6')
|
7 |
-
io2 = gr.Interface.load("huggingface/facebook/bart-large-cnn")
|
8 |
-
io3 = gr.Interface.load("huggingface/google/pegasus-xsum")
|
9 |
-
io4 = gr.Interface.load("huggingface/sshleifer/distilbart-cnn-6-6")
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
iface.launch()
|
|
|
1 |
+
from newspaper import Article
|
2 |
+
from newspaper import Config
|
3 |
import gradio as gr
|
4 |
from gradio.mix import Parallel, Series
|
5 |
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
|
8 |
+
def extract_article_text(url):
|
9 |
+
USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0'
|
10 |
+
config = Config()
|
11 |
+
config.browser_user_agent = USER_AGENT
|
12 |
+
config.request_timeout = 10
|
13 |
+
|
14 |
+
article = Article(url, config=config)
|
15 |
+
article.download()
|
16 |
+
article.parse()
|
17 |
+
text = article.text
|
18 |
+
return text
|
19 |
+
|
20 |
+
extractor = gr.Interface(extract_article_text, 'text', 'text')
|
21 |
+
summarizer = gr.Interface.load("huggingface/facebook/bart-large-cnn")
|
22 |
+
|
23 |
+
sample_url = [['https://www.technologyreview.com/2021/07/22/1029973/deepmind-alphafold-protein-folding-biology-disease-drugs-proteome/'],
|
24 |
+
['https://www.technologyreview.com/2021/07/21/1029860/disability-rights-employment-discrimination-ai-hiring/'],
|
25 |
+
['https://www.technologyreview.com/2021/07/09/1028140/ai-voice-actors-sound-human/']]
|
26 |
+
|
27 |
+
desc = '''
|
28 |
+
Let Hugging Face models summarize articles for you.
|
29 |
+
Note: Shorter articles generate faster summaries.
|
30 |
+
This summarizer uses bart-large-cnn model by Facebook
|
31 |
+
'''
|
32 |
+
|
33 |
+
iface = Series(extractor, summarizer,
|
34 |
+
inputs = gr.inputs.Textbox(
|
35 |
+
lines = 2,
|
36 |
+
label = 'URL'
|
37 |
+
),
|
38 |
+
outputs = 'text',
|
39 |
+
title = 'News Summarizer',
|
40 |
+
theme = 'huggingface',
|
41 |
+
description = desc,
|
42 |
+
examples=sample_url)
|
43 |
|
44 |
iface.launch()
|
requirements.txt
CHANGED
@@ -1 +1,2 @@
|
|
1 |
-
transformers
|
|
|
|
1 |
+
transformers
|
2 |
+
newspaper3k
|