fix: image variable not defined
This commit is contained in:
@@ -683,6 +683,14 @@ class MineruOCRService(OCRServiceBase):
|
||||
Dict with 'markdown', 'latex', 'mathml' keys.
|
||||
"""
|
||||
try:
|
||||
# Decode image_bytes to numpy array for potential formula recognition
|
||||
image_bytes.seek(0)
|
||||
image_data = np.frombuffer(image_bytes.read(), dtype=np.uint8)
|
||||
original_image = cv2.imdecode(image_data, cv2.IMREAD_COLOR)
|
||||
|
||||
# Reset image_bytes for API request
|
||||
image_bytes.seek(0)
|
||||
|
||||
# Prepare multipart form data
|
||||
files = {"files": ("image.png", image_bytes, "image/png")}
|
||||
|
||||
@@ -715,7 +723,7 @@ class MineruOCRService(OCRServiceBase):
|
||||
markdown_content = result["results"]["image"].get("md_content", "")
|
||||
|
||||
if "
|
||||
markdown_content = self._extract_and_recognize_formulas(markdown_content, original_image)
|
||||
|
||||
# Apply postprocessing to fix OCR errors
|
||||
markdown_content = _postprocess_markdown(markdown_content)
|
||||
|
||||
Reference in New Issue
Block a user