rehan953 commited on
Commit
28e752d
·
verified ·
1 Parent(s): a374680

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -37,7 +37,7 @@ DEFAULT_ZONE_FRAC = float(os.environ.get("GLMOCR_DEFAULT_ZONE_FRAC", "0.12"))
37
  MIN_CROP_HEIGHT = int(os.environ.get("GLMOCR_MIN_CROP_HEIGHT", "112"))
38
  MIN_CROP_PIXELS = int(os.environ.get("GLMOCR_MIN_CROP_PIXELS", "12544")) # 112*112
39
  # Wider PDF bands for position-based extraction (capture account numbers etc. in top/bottom)
40
- PDF_HEADER_BAND_FRAC = float(os.environ.get("GLMOCR_PDF_HEADER_BAND", "0.15")) # top 15%
41
  PDF_FOOTER_BAND_FRAC = float(os.environ.get("GLMOCR_PDF_FOOTER_BAND", "0.85")) # bottom 15%
42
 
43
  # Single shared parser to avoid "GLM-OCR initialized" per request and asyncio cleanup issues.
@@ -295,7 +295,8 @@ def run_ocr(uploaded_file):
295
  ftr = extract_pdf_text_in_band(path, page_num, PDF_FOOTER_BAND_FRAC, 1.0)
296
  if not (ftr and ftr.strip()):
297
  ftr = ocr_zone(img_path, fs, 1.0)
298
- if ftr and ftr.strip():
 
299
  parts.append(ftr.strip())
300
 
301
  if parts:
 
37
  MIN_CROP_HEIGHT = int(os.environ.get("GLMOCR_MIN_CROP_HEIGHT", "112"))
38
  MIN_CROP_PIXELS = int(os.environ.get("GLMOCR_MIN_CROP_PIXELS", "12544")) # 112*112
39
  # Wider PDF bands for position-based extraction (capture account numbers etc. in top/bottom)
40
+ PDF_HEADER_BAND_FRAC = float(os.environ.get("GLMOCR_PDF_HEADER_BAND", "0.08")) # top 8%
41
  PDF_FOOTER_BAND_FRAC = float(os.environ.get("GLMOCR_PDF_FOOTER_BAND", "0.85")) # bottom 15%
42
 
43
  # Single shared parser to avoid "GLM-OCR initialized" per request and asyncio cleanup issues.
 
295
  ftr = extract_pdf_text_in_band(path, page_num, PDF_FOOTER_BAND_FRAC, 1.0)
296
  if not (ftr and ftr.strip()):
297
  ftr = ocr_zone(img_path, fs, 1.0)
298
+ # Skip footer if its content already exists in page_md (avoids duplication)
299
+ if ftr and ftr.strip() and ftr.strip()[:80] not in page_md:
300
  parts.append(ftr.strip())
301
 
302
  if parts: