Omnibus commited on
Commit
73570f9
1 Parent(s): 373d23c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
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
- sent_wid=gr.Slider(0.1, 3, step=0.1,value=1,label="Horizontal Word Space")
147
- contrast_det=gr.Slider(0.1, 1, step=0.1,value=0.1,label="Contrast Threshold")
148
- up_scale=gr.Slider(0.1, 5, step=0.1,value=1,label="PDF to Image Scale")
 
 
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")