Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ nltk.download('punkt')
|
|
6 |
from transformers import pipeline
|
7 |
import gradio as gr
|
8 |
from gradio.mix import Parallel, Series
|
|
|
9 |
USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0'
|
10 |
|
11 |
config = Config()
|
@@ -38,6 +39,7 @@ keywords = article.keywords
|
|
38 |
keywords.sort()
|
39 |
print(keywords)
|
40 |
print(f"Summary: \n{article.summary}")
|
|
|
41 |
io1 = gr.Interface.load('huggingface/sshleifer/distilbart-cnn-12-6')
|
42 |
io2 = gr.Interface.load("huggingface/facebook/bart-large-cnn")
|
43 |
io3 = gr.Interface.load("huggingface/google/pegasus-xsum")
|
@@ -45,21 +47,23 @@ io4 = gr.Interface.load("huggingface/sshleifer/distilbart-cnn-6-6")
|
|
45 |
|
46 |
iface = Parallel(io1, io2, io3, io4,
|
47 |
theme='huggingface',
|
48 |
-
inputs = gr.inputs.Textbox(lines
|
49 |
|
50 |
iface.launch()
|
|
|
51 |
def extract_article_text(url):
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
-
|
58 |
-
article.download()
|
59 |
-
article.parse()
|
60 |
-
text = article.text
|
61 |
-
return text
|
62 |
-
extractor = gr.Interface(extract_article_text, 'text', 'text')
|
63 |
summarizer = gr.Interface.load("huggingface/facebook/bart-large-cnn")
|
64 |
|
65 |
sample_url = [['https://www.technologyreview.com/2021/07/22/1029973/deepmind-alphafold-protein-folding-biology-disease-drugs-proteome/'],
|
@@ -73,14 +77,14 @@ desc = '''
|
|
73 |
'''
|
74 |
|
75 |
iface = Series(extractor, summarizer,
|
76 |
-
inputs
|
77 |
-
lines
|
78 |
-
label
|
79 |
),
|
80 |
-
outputs
|
81 |
-
title
|
82 |
-
theme
|
83 |
-
description
|
84 |
examples=sample_url)
|
85 |
|
86 |
iface.launch()
|
|
|
6 |
from transformers import pipeline
|
7 |
import gradio as gr
|
8 |
from gradio.mix import Parallel, Series
|
9 |
+
|
10 |
USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0'
|
11 |
|
12 |
config = Config()
|
|
|
39 |
keywords.sort()
|
40 |
print(keywords)
|
41 |
print(f"Summary: \n{article.summary}")
|
42 |
+
|
43 |
io1 = gr.Interface.load('huggingface/sshleifer/distilbart-cnn-12-6')
|
44 |
io2 = gr.Interface.load("huggingface/facebook/bart-large-cnn")
|
45 |
io3 = gr.Interface.load("huggingface/google/pegasus-xsum")
|
|
|
47 |
|
48 |
iface = Parallel(io1, io2, io3, io4,
|
49 |
theme='huggingface',
|
50 |
+
inputs = gr.inputs.Textbox(lines=10, label="Text"))
|
51 |
|
52 |
iface.launch()
|
53 |
+
|
54 |
def extract_article_text(url):
|
55 |
+
USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0'
|
56 |
+
config = Config()
|
57 |
+
config.browser_user_agent = USER_AGENT
|
58 |
+
config.request_timeout = 10
|
59 |
+
|
60 |
+
article = Article(url, config=config)
|
61 |
+
article.download()
|
62 |
+
article.parse()
|
63 |
+
text = article.text
|
64 |
+
return text
|
65 |
|
66 |
+
extractor = gr.Interface(extract_article_text, 'text', 'text')
|
|
|
|
|
|
|
|
|
|
|
67 |
summarizer = gr.Interface.load("huggingface/facebook/bart-large-cnn")
|
68 |
|
69 |
sample_url = [['https://www.technologyreview.com/2021/07/22/1029973/deepmind-alphafold-protein-folding-biology-disease-drugs-proteome/'],
|
|
|
77 |
'''
|
78 |
|
79 |
iface = Series(extractor, summarizer,
|
80 |
+
inputs=gr.inputs.Textbox(
|
81 |
+
lines=2,
|
82 |
+
label='URL'
|
83 |
),
|
84 |
+
outputs='text',
|
85 |
+
title='News Summarizer',
|
86 |
+
theme='huggingface',
|
87 |
+
description=desc,
|
88 |
examples=sample_url)
|
89 |
|
90 |
iface.launch()
|