Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ def scrape(instring):
|
|
10 |
</div>''')
|
11 |
return gr.HTML.update(f'''{html_src}''')
|
12 |
|
13 |
-
def scrape00(instring):
|
14 |
response = requests.get(instring, stream=True)
|
15 |
|
16 |
if response.status_code == 200:
|
@@ -24,7 +24,7 @@ def scrape00(instring):
|
|
24 |
#print (out)
|
25 |
reader = PdfReader("data.pdf")
|
26 |
number_of_pages = len(reader.pages)
|
27 |
-
page = reader.pages[
|
28 |
text = page.extract_text()
|
29 |
try:
|
30 |
summarizer = gr.Interface.load("huggingface/facebook/bart-large-cnn")
|
@@ -35,7 +35,9 @@ def scrape00(instring):
|
|
35 |
|
36 |
with gr.Blocks() as app:
|
37 |
gr.Markdown('''<h1>PDF Viewer''')
|
38 |
-
|
|
|
|
|
39 |
with gr.Row():
|
40 |
go_btn = gr.Button("Load PDF")
|
41 |
sum_btn = gr.Button("Summarize")
|
@@ -44,5 +46,5 @@ with gr.Blocks() as app:
|
|
44 |
text_out = gr.Textbox()
|
45 |
sum_out = gr.Textbox()
|
46 |
go_btn.click(scrape,inp,outp)
|
47 |
-
sum_btn.click(scrape00,inp,[text_out,sum_out])
|
48 |
app.queue(concurrency_count=10).launch()
|
|
|
10 |
</div>''')
|
11 |
return gr.HTML.update(f'''{html_src}''')
|
12 |
|
13 |
+
def scrape00(instring, page_num):
|
14 |
response = requests.get(instring, stream=True)
|
15 |
|
16 |
if response.status_code == 200:
|
|
|
24 |
#print (out)
|
25 |
reader = PdfReader("data.pdf")
|
26 |
number_of_pages = len(reader.pages)
|
27 |
+
page = reader.pages[int(page_num-1)]
|
28 |
text = page.extract_text()
|
29 |
try:
|
30 |
summarizer = gr.Interface.load("huggingface/facebook/bart-large-cnn")
|
|
|
35 |
|
36 |
with gr.Blocks() as app:
|
37 |
gr.Markdown('''<h1>PDF Viewer''')
|
38 |
+
with gr.Row():
|
39 |
+
inp=gr.Textbox(label="PDF URL",scale=3)
|
40 |
+
pg_num=gr.Number(label="Page Number",value=1,precision=0,scale=1)
|
41 |
with gr.Row():
|
42 |
go_btn = gr.Button("Load PDF")
|
43 |
sum_btn = gr.Button("Summarize")
|
|
|
46 |
text_out = gr.Textbox()
|
47 |
sum_out = gr.Textbox()
|
48 |
go_btn.click(scrape,inp,outp)
|
49 |
+
sum_btn.click(scrape00,[inp,pg_num],[text_out,sum_out])
|
50 |
app.queue(concurrency_count=10).launch()
|