Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/BIT-DataLab/Edit-Banana
/ functions
Functions
308 in github.com/BIT-DataLab/Edit-Banana
⨍
Functions
308
◇
Types & classes
50
↳
Endpoints
7
↓ 1 callers
Method
_get_elements_to_process
筛选需要处理的基本图形
modules/basic_shape_processor.py:1428
↓ 1 callers
Method
_get_elements_to_process
Filter elements to process (icons, arrows, etc.; arrows treated as icon crop).
modules/icon_picture_processor.py:317
↓ 1 callers
Method
_get_image_state
获取或创建图像状态(LRU缓存)
modules/sam3_info_extractor.py:320
↓ 1 callers
Method
_get_image_state
(self, image_path: str)
sam3_service/server.py:125
↓ 1 callers
Method
_get_next_id
获取下一个可用 ID
modules/text/xml_generator.py:92
↓ 1 callers
Method
_image_to_base64
Encode PIL image to base64.
modules/icon_picture_processor.py:406
↓ 1 callers
Method
_image_to_base64
将PIL图像转换为base64
modules/refinement_processor.py:373
↓ 1 callers
Method
_is_academic_text
检测是否为学术文本
modules/text/processors/font_family.py:227
↓ 1 callers
Method
_is_code_text
检测是否为代码风格文本
modules/text/processors/font_family.py:213
↓ 1 callers
Method
_is_mostly_white
检查区域是否大部分为白色 用于过滤那些实际上没什么内容的"空白"区域
modules/refinement_processor.py:245
↓ 1 callers
Method
_is_refinement_meaningful
Whether refinement changed result meaningfully.
modules/text/restorer.py:407
↓ 1 callers
Method
_is_spatially_close
Whether two polygons are spatially close.
modules/text/restorer.py:422
↓ 1 callers
Method
_merge_nearby_regions
合并相邻的小问题区域 只对面积 < 3% 的小区域进行合并,大区域保持独立
modules/metric_evaluator.py:854
↓ 1 callers
Method
_merge_polygons
Merge two polygons.
modules/text/restorer.py:454
↓ 1 callers
Method
_nms_smallest_first
小框优先NMS:保留小框,抑制被小框高度覆盖的大框 逻辑: 1. 按面积从小到大排序 2. 依次处理每个框,保留最小的 3. 用保留的小框去抑制与之高度重叠的大框 这
modules/metric_evaluator.py:1057
↓ 1 callers
Method
_ocr_result_to_dict_list
Convert OCR result to list of dicts.
modules/text/restorer.py:461
↓ 1 callers
Method
_parse_and_update_cell
解析XML片段并更新ID Args: xml_content: mxCell的XML字符串 new_id: 新分配的ID Returns:
modules/xml_merger.py:375
↓ 1 callers
Method
_parse_result
Parse PaddleOCR 2.x or 3.x result into list of TextBlock.
modules/text/ocr/paddle_ocr.py:50
↓ 1 callers
Method
_postprocess
Extract alpha and resize to original. Returns alpha uint8.
modules/icon_picture_processor.py:147
↓ 1 callers
Method
_postprocess
(self, pred: np.ndarray, original_size)
sam3_service/rmbg_server.py:54
↓ 1 callers
Method
_preprocess
Preprocess: scale, normalize, HWC->CHW. img: RGB numpy. Returns: (preprocessed_image, original_size)
modules/icon_picture_processor.py:123
↓ 1 callers
Method
_preprocess
(self, img: np.ndarray)
sam3_service/rmbg_server.py:46
↓ 1 callers
Method
_prettify_xml
格式化XML输出(移除版本声明,过滤空行)
modules/xml_merger.py:446
↓ 1 callers
Method
_print_stats
Print stats.
modules/text/restorer.py:561
↓ 1 callers
Method
_process_element
处理单个元素:提取颜色并生成XML 优先使用SAM3提供的Mask进行精确取色 Args: elem: 元素信息 cv2_image: OpenCV格式的图像
modules/basic_shape_processor.py:1435
↓ 1 callers
Method
_process_element
Process one element. Returns True if RMBG was used.
modules/icon_picture_processor.py:325
↓ 1 callers
Method
_process_region
处理单个问题区域 当前策略(保守):直接裁剪原图区域,转成picture元素 Args: region: 问题区域信息(来自MetricEvaluator) orig
modules/refinement_processor.py:276
↓ 1 callers
Method
_run_cv_detection
运行CV补充检测
modules/basic_shape_processor.py:1517
↓ 1 callers
Method
_run_ocr
Run OCR (Tesseract or PaddleOCR + optional Pix2Text for formulas).
modules/text/restorer.py:263
↓ 1 callers
Method
_save_evaluation_json
保存评估结果到 JSON 文件 Args: metrics: 详细指标 bad_regions: 问题区域列表 needs_refinement: 是否需要二次处理
modules/metric_evaluator.py:1243
↓ 1 callers
Method
_save_metadata
Save metadata.
modules/text/restorer.py:503
↓ 1 callers
Method
_save_uncovered_visualization
保存问题区域可视化图 - 重点突出需要 fallback 补救的区域 显示: - 原图作为背景 - 红色半透明填充 + 粗红框标记问题区域(需要 fallback) - 问题区域的详细标注
modules/metric_evaluator.py:1160
↓ 1 callers
Method
_scale_fragment_coordinates
缩放 XMLFragment 的坐标
modules/xml_merger.py:262
↓ 1 callers
Method
_should_group
判断两个文字块是否应该分到同一组
modules/text/processors/font_size.py:121
↓ 1 callers
Method
_should_merge
判断两个文字块是否应该合并
modules/text/processors/font_family.py:333
↓ 1 callers
Method
_should_merge_for_color
判断两个文字块是否应该合并(用于颜色统一) 使用更严格的条件:必须在同一行(垂直重叠)
modules/text/processors/style.py:230
↓ 1 callers
Method
_sort_fragments
排序XML片段 排序规则: 1. 首先按 layer_level 升序(小的在底层,先写入XML) 2. 同层级内按面积降序(大的在下,先写入) DrawIO的Z轴规
modules/xml_merger.py:338
↓ 1 callers
Method
_spans_overlap
( self, offset1: int, length1: int, offset2: int, length2: int
modules/text/processors/style.py:139
↓ 1 callers
Function
_validate_cv_rectangle
验证CV检测到的矩形是否有效 检查内容: 1. 内部颜色是否有足够变化(排除纯色背景误检) 2. 边框与内部是否有明显区别 :param cv2_image: BGR图像 :param bbox: [x1, y1, x2, y2]
modules/basic_shape_processor.py:757
↓ 1 callers
Method
add_prompt
添加提示词
modules/sam3_info_extractor.py:50
↓ 1 callers
Function
build_style_string
Convert style dict to DrawIO style string.
modules/utils/drawio_library.py:18
↓ 1 callers
Method
calculate_font_sizes
Set font_size from block height (text: height - offset; formula: height * ratio).
modules/text/processors/font_size.py:49
↓ 1 callers
Function
calculate_image_complexity
Compute image complexity (for picture vs icon). Returns (laplacian_variance, std_deviation).
modules/icon_picture_processor.py:415
↓ 1 callers
Function
calculate_stroke_width
计算边框粗细 (Stroke Width) 逻辑:沿四边向内扫描,寻找颜色突变点,多个采样点综合取中位数。 优化: - 提高突变阈值(35),减少误检 - 限制最大宽度(8像素),避免过粗 - 大多数边框在 1-5 像素
modules/basic_shape_processor.py:185
↓ 1 callers
Function
create_app
(runtime: Sam3Runtime)
sam3_service/server.py:249
↓ 1 callers
Function
create_app
(model_path: str)
sam3_service/rmbg_server.py:70
↓ 1 callers
Function
extract_color_with_mask
使用SAM3提供的Mask进行精确取色 Args: image: BGR格式的OpenCV图像 bbox: [x1, y1, x2, y2] 边界框 mask: SAM3提供的二值掩码 (full size or cropp
modules/basic_shape_processor.py:456
↓ 1 callers
Method
extract_styles
从文字块和 OCR styles 中提取样式。 优先级:1. 文字块自身属性 2. OCR styles 的 spans 匹配
modules/text/processors/style.py:55
↓ 1 callers
Method
extract_with_custom_prompts
使用自定义提示词提取(不使用分组) Args: context: 处理上下文 prompts: 自定义提示词列表 score_threshold: 置信度阈值
modules/sam3_info_extractor.py:541
↓ 1 callers
Function
main
()
flowchart_text/main.py:23
↓ 1 callers
Function
main
()
sam3_service/run_all_service.py:17
↓ 1 callers
Function
main
()
sam3_service/rmbg_server.py:108
↓ 1 callers
Function
main
()
scripts/setup_rmbg.py:16
↓ 1 callers
Method
merge_ocr_results
合并 layout OCR 和 Pix2Text 结果(主入口) Args: ocr_result: 主 OCR 结果对象 pix2text_result: Pix2Text 结果对象 Return
modules/text/processors/formula.py:97
↓ 1 callers
Method
merge_with_text_xml
合并图形XML和文字XML 这是最常用的合并场景:SAM3提取的图形 + OCR提取的文字 Args: shape_xml_path: 图形XML路径 text_xm
modules/xml_merger.py:527
↓ 1 callers
Function
parse_args
()
sam3_service/server.py:268
↓ 1 callers
Function
parse_args
()
sam3_service/rmbg_server.py:96
↓ 1 callers
Method
predict
Background removal; fallback to CPU if GPU fails. Returns RGBA PIL.
modules/icon_picture_processor.py:160
↓ 1 callers
Method
predict
(self, payload: PredictRequest)
sam3_service/server.py:177
↓ 1 callers
Method
print_prompt_groups
打印当前词库配置
modules/sam3_info_extractor.py:1070
↓ 1 callers
Method
process
处理入口 - 分组提取图片中的所有元素 Args: context: 处理上下文,需要包含 image_path Returns: ProcessingRes
modules/sam3_info_extractor.py:409
↓ 1 callers
Method
process
处理入口 Args: context: 处理上下文 Returns: ProcessingResult
modules/basic_shape_processor.py:1369
↓ 1 callers
Method
process
Process icon/picture elements in context.
modules/icon_picture_processor.py:266
↓ 1 callers
Method
process
处理样式(主入口) Args: text_blocks: 文字块列表 ocr_styles: OCR 返回的全局 styles 列表(若有) unify: 是否执行聚类统一
modules/text/processors/style.py:31
↓ 1 callers
Method
process
处理字号(主入口) Args: text_blocks: 文字块列表 unify: 是否执行聚类统一 vertical_threshold_ratio: 垂直距离阈值比例
modules/text/processors/font_size.py:17
↓ 1 callers
Method
recognize_region
识别特定区域的公式 Args: image_path: 图片路径 polygon: [x1, y1, x2, y2...] or [(x,y), ...] R
modules/text/ocr/pix2text.py:162
↓ 1 callers
Method
remove_background
Alias for predict.
modules/icon_picture_processor.py:219
↓ 1 callers
Method
remove_background
(self, pil_img: Image.Image)
sam3_service/rmbg_server.py:59
↓ 1 callers
Method
remove_prompt
移除提示词
modules/sam3_info_extractor.py:55
↓ 1 callers
Method
restore
Full pipeline: process image and write draw.io file.
modules/text/restorer.py:192
↓ 1 callers
Method
save_metadata
保存元数据JSON
modules/sam3_info_extractor.py:1001
↓ 1 callers
Method
save_to_file
保存到文件 Args: cells: 文本单元格列表 output_path: 输出文件路径(自动添加 .drawio 后缀)
modules/text/xml_generator.py:280
↓ 1 callers
Method
to_dict
转换为字典(用于JSON序列化,不包含xml_fragment)
modules/data_types.py:135
↓ 1 callers
Method
to_dict_list
将 MergedBlock 列表转换为字典列表 供后续处理器使用
modules/text/processors/formula.py:342
↓ 1 callers
Method
unify_by_clustering
通过空间聚类统一样式 注意: - 加粗/斜体 **不做** 聚类统一,保留 OCR 原始值 - 只对颜色做聚类统一(同一区域的文字颜色通常一致) 原因: - 加粗/斜
modules/text/processors/style.py:150
↓ 1 callers
Method
unify_by_clustering
Unify font sizes for spatially close blocks (union-find + median).
modules/text/processors/font_size.py:67
↓ 1 callers
Method
unify_by_clustering
通过空间聚类统一字体 算法: 1. 并查集聚类:将空间相邻的文字块分组 2. 组内统一:使用多数投票选择字体
modules/text/processors/font_family.py:242
↓ 1 callers
Function
unify_element_styles
统一相似大小和类型的基本图形的边框厚度。 注意:参考 sam3_extractor.py 的简化逻辑,默认边框宽度为1, 这里主要用于确保同类元素风格一致。
modules/basic_shape_processor.py:660
Method
__init__
(self, config: dict = None)
main.py:83
Method
__init__
初始化处理器 Args: config: 处理配置,如果为None则使用默认配置
modules/base.py:91
Method
__init__
(self)
modules/base.py:195
Method
__init__
(self, config=None, checkpoint_path: str = None, bpe_path: str = None)
modules/sam3_info_extractor.py:372
Method
__init__
(self, config=None)
modules/xml_merger.py:73
Method
__init__
Args: config: 处理配置 enable_cv_detection: 是否启用CV补充检测(检测SAM3遗漏的矩形)
modules/basic_shape_processor.py:1360
Method
__init__
( self, config=None, rmbg_model_path: str = None, )
modules/icon_picture_processor.py:246
Method
__init__
(self, config=None)
modules/refinement_processor.py:130
Method
__init__
(self, config=None)
modules/metric_evaluator.py:211
Method
__init__
(self, source_width: int, source_height: int, canvas_width: int = None, canvas_height: int =
modules/text/coord_processor.py:23
Method
__init__
Args: formula_engine: Formula engine ('pix2text', 'none'). ocr_engine: Layout/text OCR engine ('tesseract', 'paddleoc
modules/text/restorer.py:34
Method
__init__
初始化生成器 Args: diagram_name: 图表名称 page_width: 页面宽度 page_height: 页面高度
modules/text/xml_generator.py:77
Method
__init__
(self, use_angle_cls: bool = True, lang: str = "ch")
modules/text/ocr/paddle_ocr.py:31
Method
__init__
初始化 Pix2Text Args: device: 计算设备(cuda 使用 GPU3) languages: 文字语言(影响非公式部分的识别)
modules/text/ocr/pix2text.py:72
Method
__init__
(self, lang: str = "eng+chi_sim")
modules/text/ocr/local_ocr.py:26
Method
__init__
(self)
modules/text/processors/style.py:28
Method
__init__
(self, formula_ratio: float = 0.6, text_offset: float = 1.0)
modules/text/processors/font_size.py:13
Method
__init__
初始化公式处理器 Args: overlap_threshold: 覆盖率阈值 text_similarity_threshold: 文本相似度阈值
modules/text/processors/formula.py:86
Method
__init__
初始化字体处理器 Args: default_font: 默认字体
modules/text/processors/font_family.py:82
Method
__init__
(self, base_url: str, timeout: int = 120)
sam3_service/client.py:9
Method
__init__
(self, endpoints: List[str], timeout: int = 120)
sam3_service/client.py:46
Method
__init__
(self, base_url: str, timeout: int = 60)
sam3_service/rmbg_client.py:11
← previous
next →
101–200 of 308, ranked by callers