Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

feat: remove unused functions and clean up codebase by deleting obsolete files

myhloli34765d172ab1
diff --git a/mineru/backend/utils/boxbase.py b/mineru/backend/utils/boxbase.py
index b743fff0..bc295761 100644
--- a/mineru/backend/utils/boxbase.py
+++ b/mineru/backend/utils/boxbase.py
@@ -6,19 +6,6 @@ import math
from ...types import BBox
-def is_in(box1: BBox, box2: BBox) -> bool:
- """box1是否完全在box2里面."""
- x0_1, y0_1, x1_1, y1_1 = box1
- x0_2, y0_2, x1_2, y1_2 = box2
-
- return (
- x0_1 >= x0_2 # box1的左边界不在box2的左边外
- and y0_1 >= y0_2 # box1的上边界不在box2的上边外
- and x1_1 <= x1_2 # box1的右边界不在box2的右边外
- and y1_1 <= y1_2
- ) # box1的下边界不在box2的下边外
-
-
def bbox_relative_pos(bbox1: BBox, bbox2: BBox) -> tuple[bool, bool, bool, bool]:
"""判断两个矩形框的相对位置关系.
@@ -102,23 +89,6 @@ def bbox_center_distance(bbox1: BBox, bbox2: BBox) -> float:
return math.sqrt((center1_x - center2_x) ** 2 + (center1_y - center2_y) ** 2)
-def get_minbox_if_overlap_by_ratio(bbox1: BBox, bbox2: BBox, ratio: float) -> BBox | None:
- """通过calculate_overlap_area_2_minbox_area_ratio计算两个bbox重叠的面积占最小面积的box的比例
- 如果比例大于ratio,则返回小的那个bbox, 否则返回None."""
- x1_min, y1_min, x1_max, y1_max = bbox1
- x2_min, y2_min, x2_max, y2_max = bbox2
- area1 = (x1_max - x1_min) * (y1_max - y1_min)
- area2 = (x2_max - x2_min) * (y2_max - y2_min)
- overlap_ratio = calculate_overlap_area_2_minbox_area_ratio(bbox1, bbox2)
- if overlap_ratio > ratio:
- if area1 <= area2:
- return bbox1
- else:
- return bbox2
- else:
- return None
-
-
def calculate_overlap_area_2_minbox_area_ratio(bbox1: BBox, bbox2: BBox) -> float:
"""计算box1和box2的重叠面积占最小面积的box的比例."""
# Determine the coordinates of the intersection rectangle
@@ -139,42 +109,6 @@ def calculate_overlap_area_2_minbox_area_ratio(bbox1: BBox, bbox2: BBox) -> floa
return intersection_area / min_box_area
-def calculate_iou(bbox1: BBox, bbox2: BBox) -> float:
- """计算两个边界框的交并比(IOU)。
-
- Args:
- bbox1: 第一个边界框的坐标,格式为 (x1, y1, x2, y2),其中 (x1, y1) 为左上角坐标,(x2, y2) 为右下角坐标。
- bbox2: 第二个边界框的坐标,格式与 `bbox1` 相同。
-
- Returns:
- float: 两个边界框的交并比(IOU),取值范围为 [0, 1]。
- """
- # Determine the coordinates of the intersection rectangle
- x_left = max(bbox1[0], bbox2[0])
- y_top = max(bbox1[1], bbox2[1])
- x_right = min(bbox1[2], bbox2[2])
- y_bottom = min(bbox1[3], bbox2[3])
-
- if x_right < x_left or y_bottom < y_top:
- return 0.0
-
- # The area of overlap area
- intersection_area = (x_right - x_left) * (y_bottom - y_top)
-
- # The area of both rectangles
- bbox1_area = (bbox1[2] - bbox1[0]) * (bbox1[3] - bbox1[1])
- bbox2_area = (bbox2[2] - bbox2[0]) * (bbox2[3] - bbox2[1])
-
- if any([bbox1_area == 0, bbox2_area == 0]):
- return 0
-
- # Compute the intersection over union by taking the intersection area
- # and dividing it by the sum of both areas minus the intersection area
- iou = intersection_area / float(bbox1_area + bbox2_area - intersection_area)
-
- return iou
-
-
def calculate_overlap_area_in_bbox1_area_ratio(bbox1: BBox, bbox2: BBox) -> float:
"""计算box1和box2的重叠面积占bbox1的比例."""
# Determine the coordinates of the intersection rectangle
@@ -193,38 +127,3 @@ def calculate_overlap_area_in_bbox1_area_ratio(bbox1: BBox, bbox2: BBox) -> floa
return 0
else:
return intersection_area / bbox1_area
-
-
-def calculate_vertical_projection_overlap_ratio(block1: BBox, block2: BBox) -> float:
- """
- Calculate the proportion of the x-axis covered by the vertical projection of two blocks.
-
- Args:
- block1 (tuple): Coordinates of the first block (x0, y0, x1, y1).
- block2 (tuple): Coordinates of the second block (x0, y0, x1, y1).
-
- Returns:
- float: The proportion of the x-axis covered by the vertical projection of the two blocks.
- """
- x0_1, _, x1_1, _ = block1
- x0_2, _, x1_2, _ = block2
-
- # Calculate the intersection of the x-coordinates
- x_left = max(x0_1, x0_2)
- x_right = min(x1_1, x1_2)
-
- if x_right < x_left:
- return 0.0
-
- # Length of the intersection
- intersection_length = x_right - x_left
-
- # Length of the x-axis projection of the first block
- block1_length = x1_1 - x0_1
-
- if block1_length == 0:
- return 0.0
-
- # Proportion of the x-axis covered by the intersection
- # logger.info(f"intersection_length: {intersection_length}, block1_length: {block1_length}")
- return intersection_length / block1_length
diff --git a/mineru/backend/utils/content_block_draft.py b/mineru/backend/utils/content_block_draft.py
deleted file mode 100644
index 0d3d5de7..00000000
--- a/mineru/backend/utils/content_block_draft.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright (c) Opendatalab. All rights reserved.
-from __future__ import annotations
-
-from dataclasses import dataclass, field
-from typing import Any, Mapping
-
-from ...types import BBox
-
-
-@dataclass(slots=True)
-class VlmContentBlockDraft:
- """VLM raw content block 的内部适配层,不作为 middle_json block 输出。"""
-
- raw_type: str
- bbox: BBox
- angle: int | None = None
- content: str | None = None
- sub_type: str | None = None
- cell_merge: list[int] = field(default_factory=list)
- ocr_det_lines: list[dict] = field(default_factory=list)
- line_avg_height: int = 0
-
- @classmethod
- def from_content_block(cls, content_block: Mapping[str, Any], width: int, height: int) -> VlmContentBlockDraft:
- """将 mineru_vl_utils 的相对坐标 content block 转为页面绝对坐标 draft。"""
- x1, y1, x2, y2 = content_block["bbox"]
- x_1, y_1, x_2, y_2 = (
- int(x1 * width),
- int(y1 * height),
- int(x2 * width),
- int(y2 * height),
- )
- if x_2 < x_1:
- x_1, x_2 = x_2, x_1
- if y_2 < y_1:
- y_1, y_2 = y_2, y_1
-
- return cls(
- raw_type=str(content_block["type"]),
- bbox=(x_1, y_1, x_2, y_2),
- angle=content_block.get("angle", 0),
- content=content_block.get("content", ""),
- sub_type=content_block.get("sub_type"),
- cell_merge=list(content_block.get("cell_merge") or []),
- ocr_det_lines=list(content_block.get("_lines") or []),
- )
diff --git a/mineru/backend/utils/magic_model_utils.py b/mineru/backend/utils/magic_model_utils.py
deleted file mode 100644
index 8ce4b0a4..00000000
--- a/mineru/backend/utils/magic_model_utils.py
+++ /dev/null
@@ -1,185 +0,0 @@
-# Copyright (c) Opendatalab. All rights reserved.
-"""
-包含两个MagicModel类中重复使用的方法和逻辑
-"""
-
-from typing import Any, Callable, Dict, List, TypeVar
-
-from loguru import logger
-
-from ...types import Block
-from .boxbase import bbox_center_distance, bbox_distance, is_in
-
-T = TypeVar("T")
-
-
-def _identical(x: T) -> T:
- return x
-
-
-def reduct_overlap(bboxes: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
- """
- 去除重叠的bbox,保留不被其他bbox包含的bbox
-
- Args:
- bboxes: 包含bbox信息的字典列表
-
- Returns:
- 去重后的bbox列表
- """
- N = len(bboxes)
- keep = [True] * N
- for i in range(N):
- for j in range(N):
- if i == j:
- continue
- if is_in(bboxes[i]["bbox"], bboxes[j]["bbox"]):
- keep[i] = False
- return [bboxes[i] for i in range(N) if keep[i]]
-
-
-def tie_up_category_by_index(
- get_subjects_func: Callable[[], list[Block]],
- get_objects_func: Callable[[], list[Block]],
- extract_subject_func: Callable[[Block], Any] | None = None,
- extract_object_func: Callable[[Block], Any] | None = None,
- object_block_type: str = "object",
- include_bbox: bool = True,
-) -> list[dict[str, Any]]:
- """
- 基于index的类别关联方法,用于将主体对象与客体对象进行关联
- 客体优先匹配给index最接近的主体,匹配优先级为:
- 1. index差值(最高优先级)
- 2. bbox边缘距离(相邻边距离)
- 3. bbox中心点距离(最低优先级,作为最终tiebreaker)
-
- 参数:
- get_subjects_func: 函数,提取主体对象
- get_objects_func: 函数,提取客体对象
- extract_subject_func: 函数,自定义提取主体属性(默认使用bbox和其他属性)
- extract_object_func: 函数,自定义提取客体属性(默认使用bbox和其他属性)
-
- 返回:
- 关联后的对象列表,按主体index升序排列
- """
- subjects = get_subjects_func()
- objects = get_objects_func()
-
- # 如果没有提供自定义提取函数,使用默认函数
- if extract_subject_func is None:
- extract_subject_func = _identical
- if extract_object_func is None:
- extract_object_func = _identical
-
- # 初始化结果字典,key为主体索引,value为关联信息
- result_dict = {}
-
- # 初始化所有主体
- for i, subject in enumerate(subjects):
- result_dict[i] = {
- "sub_bbox": extract_subject_func(subject),
- "obj_bboxes": [],
- "sub_idx": i,
- }
-
- # 提取所有客体的index集合,用于计算有效index差值
- object_indices = {obj.index for obj in objects}
-
- def calc_effective_index_diff(obj_index: int, sub_index: int) -> int: # noqa: ANN202
- """
- 计算有效的index差值
- 有效差值 = 绝对差值 - 区间内其他客体的数量
- 即:如果obj_index和sub_index之间的差值是由其他客体造成的,则应该扣除这部分差值
- """
- if obj_index == sub_index:
- return 0
-
- start, end = min(obj_index, sub_index), max(obj_index, sub_index)
- abs_diff = end - start
-
- # 计算区间(start, end)内有多少个其他客体的index
- other_objects_count = 0
- for idx in range(start + 1, end):
- if idx in object_indices:
- other_objects_count += 1
-
- return abs_diff - other_objects_count
-
- # 为每个客体找到最匹配的主体
- for obj in objects:
- if len(subjects) == 0:
- # 如果没有主体,跳过客体
- continue
-
- obj_index = obj.index
- min_index_diff = float("inf")
- best_subject_indices = []
-
- # 找出有效index差值最小的所有主体
- for i, subject in enumerate(subjects):
- sub_index = subject.index
- index_diff = calc_effective_index_diff(obj_index, sub_index)
-
- if index_diff < min_index_diff:
- min_index_diff = index_diff
- best_subject_indices = [i]
- elif index_diff == min_index_diff:
- best_subject_indices.append(i)
-
- if len(best_subject_indices) == 1:
- best_subject_idx = best_subject_indices[0]
- # 如果有多个主体的index差值相同(最多两个),根据边缘距离进行筛选
- elif len(best_subject_indices) == 2:
- # 只有在包含bbox信息时才进行边缘距离的计算和比较,否则直接匹配第一个主体
- if include_bbox:
- # 计算所有候选主体的边缘距离
- edge_distances = [(idx, bbox_distance(obj.bbox, subjects[idx].bbox)) for idx in best_subject_indices]
- edge_dist_diff = abs(edge_distances[0][1] - edge_distances[1][1])
-
- for idx, edge_dist in edge_distances:
- logger.debug(f"Obj index: {obj_index}, Sub index: {subjects[idx].index}, Edge distance: {edge_dist}")
-
- if edge_dist_diff > 2:
- # 边缘距离差值大于2,匹配边缘距离更小的主体
- best_subject_idx = min(edge_distances, key=lambda x: x[1])[0]
- logger.debug(
- f"Obj index: {obj_index}, edge_dist_diff > 2, matching to subject with min edge distance,"
- f" index: {subjects[best_subject_idx].index}"
- )
- elif object_block_type == "table_caption":
- # 边缘距离差值<=2且为table_caption,匹配index更大的主体
- best_subject_idx = max(best_subject_indices, key=lambda idx: subjects[idx].index)
- logger.debug(
- f"Obj index: {obj_index}, edge_dist_diff <= 2 and table_caption,"
- f" matching to later subject with index: {subjects[best_subject_idx].index}"
- )
- elif object_block_type.endswith("footnote"):
- # 边缘距离差值<=2且为footnote,匹配index更小的主体
- best_subject_idx = min(best_subject_indices, key=lambda idx: subjects[idx].index)
- logger.debug(
- f"Obj index: {obj_index}, edge_dist_diff <= 2 and footnote,"
- f" matching to earlier subject with index: {subjects[best_subject_idx].index}"
- )
- else:
- # 边缘距离差值<=2 且不适用特殊匹配规则,使用中心点距离匹配
- center_distances = [
- (idx, bbox_center_distance(obj.bbox, subjects[idx].bbox)) for idx in best_subject_indices
- ]
- for idx, center_dist in center_distances:
- logger.debug(
- f"Obj index: {obj_index}, Sub index: {subjects[idx].index}, Center distance: {center_dist}"
- )
- best_subject_idx = min(center_distances, key=lambda x: x[1])[0]
- else:
- best_subject_idx = best_subject_indices[0]
- else:
- raise ValueError("More than two subjects have the same minimal index difference, which is unexpected.")
-
- # 将客体添加到最佳主体的obj_bboxes中
- result_dict[best_subject_idx]["obj_bboxes"].append(extract_object_func(obj))
-
- # 转换为列表并按主体index排序
- ret = list(result_dict.values())
- ret.sort(key=lambda x: x["sub_idx"])
-
- return ret
diff --git a/mineru/backend/utils/middle_json_utils.py b/mineru/backend/utils/middle_json_utils.py
deleted file mode 100644
index 43bfddf4..00000000
--- a/mineru/backend/utils/middle_json_utils.py
+++ /dev/null
@@ -1,64 +0,0 @@
-"""Shared middle_json build template for current PDF backends.
-
-Each backend still owns its ``init``, ``append``, and ``finalize`` helpers;
-this module also provides shared post-processing helpers that were duplicated
-across backends.
-"""
-
-from __future__ import annotations
-
-import copy
-from typing import Any, Iterator, TypeVar
-
-from ..pdf.model_output_to_middle_json import blocks_to_page_info
-from ...types import Block, PageInfo, Span
-from ...utils.image_payload import ImagePayloadCache
-from ...utils.page_index import resolve_output_page_idx
-from ...utils.pdf_document import PDFDocument
-
-T = TypeVar("T")
-
-
-def append_pages(
- middle_json: list[PageInfo],
- model_list: list[T],
- images_list: list[dict[str, Any]],
- pdf_doc: PDFDocument,
- page_start_index: int = 0,
- page_index_map: list[int] | None = None,
- progress_bar: Any = None,
- image_cache: ImagePayloadCache | None = None,
-) -> None:
- """Append per-page results to `middle_json` list.
- """
- for offset, (page_data, image_dict) in enumerate(zip(model_list, images_list)):
- physical_page_idx = page_start_index + offset
- output_page_idx = resolve_output_page_idx(physical_page_idx, page_index_map)
-
- pdf_page = pdf_doc[physical_page_idx]
- page_info = blocks_to_page_info(
- copy.deepcopy(page_data),
- image_dict,
- pdf_page,
- output_page_idx,
- image_cache,
- )
-
- if page_info is None:
- page_info = PageInfo(
- blocks=[],
- page_idx=output_page_idx,
- _backend=None,
- )
-
- middle_json.append(page_info)
- if progress_bar is not None:
- progress_bar.update(1)
-
-
-def _iter_block_spans(block: Block) -> Iterator[Span]:
- """Depth-first generator yielding every span in a block tree."""
- for line in block.lines:
- yield from line.spans
- for child in block.blocks:
- yield from _iter_block_spans(child)
diff --git a/mineru/backend/utils/ocr_det_utils.py b/mineru/backend/utils/ocr_det_utils.py
deleted file mode 100644
index 96d5403a..00000000
--- a/mineru/backend/utils/ocr_det_utils.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# Copyright (c) Opendatalab. All rights reserved.
-
-from typing import Any
-
-import cv2
-import numpy as np
-from loguru import logger
-
-from ...types import BBox
-from ...utils.pdf_image_tools import get_crop_img
-
-OCR_DET_PADDING = 50
-
-
-def _get_ch_ocr_det_model() -> Any:
- """获取默认中文 OCR 检测模型,当前 ch 已对应轻量 PP-OCRv6 配置。"""
- try:
- from ..local_model_runtime import AtomModelSingleton
- except Exception as e:
- logger.error(
- "Failed to import AtomModelSingleton, OCR detection will not work. If you want to use OCR features, "
- "please execute `pip install mineru[core]` to install the required packages."
- )
- raise e
-
- atom_model_manager = AtomModelSingleton()
-
- return atom_model_manager.get_atom_model(
- atom_model_name="ocr",
- ocr_show_log=False,
- det_db_box_thresh=0.3,
- lang="ch",
- )
-
-
-def _detect_ocr_boxes_from_padded_crop(
- bbox: BBox,
- page_pil_img: Any,
- scale: float,
- ocr_model: Any = None,
- padding: int = OCR_DET_PADDING,
-) -> tuple[list[dict[str, Any]], int]:
- if not bbox:
- return [], padding
-
- crop_pil_img = get_crop_img(bbox, page_pil_img, scale)
- crop_np_img = np.array(crop_pil_img)
- if crop_np_img.size == 0:
- return [], padding
-
- if padding > 0:
- crop_np_img = cv2.copyMakeBorder(
- crop_np_img, padding, padding, padding, padding, cv2.BORDER_CONSTANT, value=[255, 255, 255]
- )
-
- crop_img = cv2.cvtColor(crop_np_img, cv2.COLOR_RGB2BGR)
- if ocr_model is None:
- ocr_model = _get_ch_ocr_det_model()
-
- ocr_det_res = ocr_model.ocr(crop_img, rec=False)[0]
- return ocr_det_res or [], padding
diff --git a/mineru/backend/utils/para_block_utils.py b/mineru/backend/utils/para_block_utils.py
index fe43d5b1..2bb3065a 100644
--- a/mineru/backend/utils/para_block_utils.py
+++ b/mineru/backend/utils/para_block_utils.py
@@ -1,9 +1,8 @@
# Copyright (c) Opendatalab. All rights reserved.
-import copy
import math
from typing import Any, TypeAlias
-from ...types import Block, BlockType, PageInfo
+from ...types import BlockType
LINE_STOP_FLAG = (".", "!", "?", "。", "!", "?", ")", ")", '"', "”", ":", ":", ";", ";")
SECTION_MERGE_BARRIER_TYPES = {
@@ -30,11 +29,6 @@ CalculationBBox: TypeAlias = tuple[int, int, int, int]
OrderedBlock: TypeAlias = tuple[int, int, BlockDict]
-def build_para_blocks_from_preproc(pages: list[PageInfo]) -> None:
- for page_info in pages:
- page_info.para_blocks = copy.deepcopy(page_info.preproc_blocks)
-
-
def merge_para_text_blocks(pages: list[dict[str, Any]]) -> None:
"""按页面阅读顺序给可延续的文本或参考文献列表写入 continues_prev 标记。"""
ordered_blocks: list[OrderedBlock] = []
@@ -133,16 +127,6 @@ def can_auto_merge_text_blocks(current_block: BlockDict, previous_block: BlockDi
)
-def cleanup_internal_para_block_metadata(pages: list[PageInfo]) -> None:
- for page_info in pages:
- for block in page_info.preproc_blocks:
- _cleanup_block_internal_metadata(block)
- for block in page_info.para_blocks:
- _cleanup_block_internal_metadata(block)
- for block in page_info.discarded_blocks:
- _cleanup_block_internal_metadata(block)
-
-
def _find_previous_text_block(
ordered_blocks: list[OrderedBlock],
current_index: int,
@@ -351,11 +335,3 @@ def _remove_line_metadata(block: BlockDict) -> None:
for child_block in content:
if isinstance(child_block, dict):
_remove_line_metadata(child_block)
-
-
-def _cleanup_block_internal_metadata(block: Block) -> None:
- """递归清理只供 finalize 内部流程使用的临时字段。"""
- block._ocr_det_lines = []
- block._line_avg_height = 0
- for sub_block in block.blocks:
- _cleanup_block_internal_metadata(sub_block)
diff --git a/mineru/backend/utils/runtime_utils.py b/mineru/backend/utils/runtime_utils.py
deleted file mode 100644
index f93cfdf4..00000000
--- a/mineru/backend/utils/runtime_utils.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (c) Opendatalab. All rights reserved.
-from __future__ import annotations
-
-import time
-from typing import Any
-
-
-def exclude_progress_bar_idle_time(progress_bar: Any, idle_since: float | None, now: float | None = None) -> float | None:
- """Exclude non-processing idle time from a reused tqdm progress bar."""
- if progress_bar is None or idle_since is None:
- return
-
- if now is None:
- now = time.time()
-
- idle_duration = now - idle_since
- if idle_duration <= 0:
- return
-
- if hasattr(progress_bar, "start_t"):
- progress_bar.start_t += idle_duration
- if hasattr(progress_bar, "last_print_t"):
- progress_bar.last_print_t = now
- if hasattr(progress_bar, "last_print_n") and hasattr(progress_bar, "n"):
- progress_bar.last_print_n = progress_bar.n
diff --git a/mineru/backend/utils/span_pre_proc.py b/mineru/backend/utils/span_pre_proc.py
index e1b43aa4..42ba4aff 100644
--- a/mineru/backend/utils/span_pre_proc.py
+++ b/mineru/backend/utils/span_pre_proc.py
@@ -303,10 +303,6 @@ class SpanBlockMatcher:
self.used_span_indices.add(span_idx)
return block_spans
- def remaining_spans(self) -> list[_AnalyzeSpan]:
- """返回尚未归属到任何 block 的 span,方便保持后续兼容。"""
- return [span for index, span in enumerate(self.spans) if index not in self.used_span_indices]
-
@staticmethod
def _default_overlap_ratio(span: _AnalyzeSpan, block_bbox: BBox) -> float:
"""默认沿用旧逻辑:计算 span 面积中落入 block 的比例。"""
diff --git a/mineru/backend/utils/visual_span_utils.py b/mineru/backend/utils/visual_span_utils.py
deleted file mode 100644
index d7517f1e..00000000
--- a/mineru/backend/utils/visual_span_utils.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (c) Opendatalab. All rights reserved.
-from __future__ import annotations
-
-from typing import Any
-
-from ...types import Block, ContentType
-from ...utils.image_payload import ImagePayloadCache
-from ...utils.cut_image import cut_image_and_table
-from .para_block_utils import iter_block_spans
-
-VISUAL_SPAN_TYPES = {
- ContentType.IMAGE,
- # ContentType.TABLE,
- ContentType.CHART,
- # ContentType.INTERLINE_EQUATION,
-}
-
-
-def cut_visual_spans_in_blocks(
- blocks: list[Block],
- page_pil_img: Any,
- page_index: int,
- scale: float|int = 2,
- image_cache: ImagePayloadCache | None = None,
-) -> None:
- """在最终 block tree 中裁剪视觉 span,避免 regroup/deepcopy 后 image_path 写回旧对象。"""
- for block in blocks:
- for span in iter_block_spans(block):
- if span.type in VISUAL_SPAN_TYPES:
- cut_image_and_table(
- span,
- page_pil_img,
- page_index,
- scale=scale,
- image_cache=image_cache,
- )
diff --git a/mineru/utils/cut_image.py b/mineru/utils/cut_image.py
deleted file mode 100644
index 0b9ba26b..00000000
--- a/mineru/utils/cut_image.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# Copyright (c) Opendatalab. All rights reserved.
-from __future__ import annotations
-
-from typing import Any
-
-from loguru import logger
-
-from ..types import BBox, Span
-from .image_payload import ImagePayloadCache, image_path_from_key
-from .pdf_image_tools import get_crop_img
-from .pdf_reader import image_to_bytes
-
-
-def cut_image_and_table(
- span: Span,
- page_pil_img: Any,
- page_id: int,
- scale: float|int = 2,
- image_cache: ImagePayloadCache | None = None,
-) -> Span:
-
- span_type = span.type
-
- if not check_img_bbox(span.bbox):
- span.image_path = ""
- else:
- filename = f"{page_id}_{int(span.bbox[0])}_{int(span.bbox[1])}_{int(span.bbox[2])}_{int(span.bbox[3])}"
- path_key = f"{span_type}_{filename}"
- crop_img = get_crop_img(span.bbox, page_pil_img, scale=scale)
- img_bytes = image_to_bytes(crop_img, image_format="JPEG")
- span.image_path = image_path_from_key(path_key, "jpg")
- if image_cache is not None:
- image_cache.register_bytes(img_bytes, "jpeg", image_path=span.image_path)
-
- return span
-
-
-def check_img_bbox(bbox: BBox) -> bool:
- if any([bbox[0] >= bbox[2], bbox[1] >= bbox[3]]):
- logger.warning(f"image_bboxes: 错误的box, {bbox}")
- return False
- return True