Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.
Python ai4sciencedocument-analysisdocxextract-datalayout-analysisocrparserpdfpdf-converterpdf-extractor-llmpdf-extractor-pretrainpdf-extractor-ragpdf-parserpptxpythonxlsx
refactor(data/utils.py): remove unnecessary decorator and improve image loading
myhloli4f7ef05d1253
diff --git a/magic_pdf/data/utils.py b/magic_pdf/data/utils.pyindex 0cb22848..137bf6d2 100644--- a/magic_pdf/data/utils.py+++ b/magic_pdf/data/utils.py@@ -29,7 +29,6 @@ def fitz_doc_to_image(doc, dpi=200) -> dict:return img_dict-@ImportPILdef load_images_from_pdf(pdf_bytes: bytes, dpi=200, start_page_id=0, end_page_id=None) -> list:images = []with fitz.open('pdf', pdf_bytes) as doc:diff --git a/magic_pdf/model/sub_modules/language_detection/yolov11/YOLOv11.py b/magic_pdf/model/sub_modules/language_detection/yolov11/YOLOv11.pyindex f93d77c8..11764d3f 100644--- a/magic_pdf/model/sub_modules/language_detection/yolov11/YOLOv11.py+++ b/magic_pdf/model/sub_modules/language_detection/yolov11/YOLOv11.py@@ -2,7 +2,7 @@import timefrom collections import Counterfrom uuid import uuid4-+import cv2import numpy as npimport torchfrom loguru import logger@@ -29,7 +29,7 @@ def split_images(image, result_images=None):if result_images is None:result_images = []- width, height = image.shape[:2]+ height, width = image.shape[:2]long_side = max(width, height) # 获取较长边长度if long_side <= 400:@@ -68,14 +68,8 @@ def resize_images_to_224(image):Works directly with NumPy arrays."""try:- # Handle numpy array directly- if len(image.shape) == 3: # Color image- height, width, channels = image.shape- else: # Grayscale image- height, width = image.shape- image = np.stack([image] * 3, axis=2) # Convert to RGB-- import cv2+ height, width = image.shape[:2]+if width < 224 or height < 224:# Create black backgroundnew_image = np.zeros((224, 224, 3), dtype=np.uint8)