Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -98,7 +98,6 @@ def scrape(instring):
|
|
98 |
return gr.HTML.update(f'''{html_src}''')
|
99 |
|
100 |
def scrape00(instring, page_num,pdf_lang,sent_wid,contrast_det,up_scale):
|
101 |
-
yield (None,None,gr.Markdown.update("""<h3> Trying Native Text Detection"""))
|
102 |
|
103 |
response = requests.get(instring, stream=True)
|
104 |
|
@@ -121,12 +120,10 @@ def scrape00(instring, page_num,pdf_lang,sent_wid,contrast_det,up_scale):
|
|
121 |
sum_out = summarizer(text)
|
122 |
except Exception:
|
123 |
try:
|
124 |
-
yield (None,None,gr.Markdown.update("""<h3> Trying OCR Text Detection"""))
|
125 |
text = ocrpdf("data.pdf",pdf_lang,page_num,sent_wid,contrast_det,up_scale)
|
126 |
sum_out = summarizer(text)
|
127 |
except Exception:
|
128 |
sum_out = "Error"
|
129 |
-
yield (None,None,gr.Markdown.update("""<h3> Error"""))
|
130 |
|
131 |
return text, sum_out,gr.Markdown.update("""<h3> Complete""")
|
132 |
|
@@ -143,9 +140,11 @@ with gr.Blocks() as app:
|
|
143 |
mes = gr.Markdown("""<h3> Summarize Text in PDF""")
|
144 |
with gr.Row():
|
145 |
with gr.Box():
|
146 |
-
|
147 |
-
|
148 |
-
|
|
|
|
|
149 |
with gr.Column():
|
150 |
target_lang = gr.Dropdown(label="PDF Language", choices=list(ocr_id.keys()),value="English")
|
151 |
sum_btn = gr.Button("Summarize")
|
|
|
98 |
return gr.HTML.update(f'''{html_src}''')
|
99 |
|
100 |
def scrape00(instring, page_num,pdf_lang,sent_wid,contrast_det,up_scale):
|
|
|
101 |
|
102 |
response = requests.get(instring, stream=True)
|
103 |
|
|
|
120 |
sum_out = summarizer(text)
|
121 |
except Exception:
|
122 |
try:
|
|
|
123 |
text = ocrpdf("data.pdf",pdf_lang,page_num,sent_wid,contrast_det,up_scale)
|
124 |
sum_out = summarizer(text)
|
125 |
except Exception:
|
126 |
sum_out = "Error"
|
|
|
127 |
|
128 |
return text, sum_out,gr.Markdown.update("""<h3> Complete""")
|
129 |
|
|
|
140 |
mes = gr.Markdown("""<h3> Summarize Text in PDF""")
|
141 |
with gr.Row():
|
142 |
with gr.Box():
|
143 |
+
with gr.Column():
|
144 |
+
sent_wid=gr.Slider(0.1, 3, step=0.1,value=1,label="Horizontal Word Space")
|
145 |
+
contrast_det=gr.Slider(0.1, 1, step=0.1,value=0.1,label="Contrast Threshold")
|
146 |
+
with gr.Column():
|
147 |
+
up_scale=gr.Slider(0.1, 5, step=0.1,value=1,label="PDF to Image Scale")
|
148 |
with gr.Column():
|
149 |
target_lang = gr.Dropdown(label="PDF Language", choices=list(ocr_id.keys()),value="English")
|
150 |
sum_btn = gr.Button("Summarize")
|