Varshithdharmajv commited on
Commit
7ffaec2
·
verified ·
1 Parent(s): 18a597f

Upload ocr_module.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. ocr_module.py +6 -1
ocr_module.py CHANGED
@@ -150,7 +150,12 @@ class MVM2OCREngine:
150
  try:
151
  formula_out = self.p2t.recognize_formula(image_path)
152
  raw_latex = clean_latex_output(str(formula_out)).strip()
153
- print(f"[OCR] Pass 1 (formula mode): {raw_latex[:80]}")
 
 
 
 
 
154
  except Exception as e1:
155
  print(f"[OCR] Pass 1 formula mode failed: {e1}")
156
  raw_latex = ""
 
150
  try:
151
  formula_out = self.p2t.recognize_formula(image_path)
152
  raw_latex = clean_latex_output(str(formula_out)).strip()
153
+
154
+ if "\\newcommand" in raw_latex or "\\def" in raw_latex:
155
+ print(f"[OCR] Pass 1 hallucinated preamble macros. Rejecting output.")
156
+ raw_latex = ""
157
+ else:
158
+ print(f"[OCR] Pass 1 (formula mode): {raw_latex[:80]}")
159
  except Exception as e1:
160
  print(f"[OCR] Pass 1 formula mode failed: {e1}")
161
  raw_latex = ""