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
↓ 59 callers
Method
_log
简单的日志输出
modules/base.py:144
↓ 11 callers
Method
to_list
(self)
modules/data_types.py:89
↓ 9 callers
Method
has_xml
检查是否已生成XML
modules/data_types.py:131
↓ 8 callers
Method
find
(x)
modules/metric_evaluator.py:899
↓ 7 callers
Method
process
处理入口 - 子类必须实现 Args: context: 处理上下文,包含输入数据和共享状态 Returns: ProcessingResult: 处理结果
modules/base.py:108
↓ 6 callers
Method
load_config
加载配置文件
modules/sam3_info_extractor.py:85
↓ 4 callers
Function
calculate_iou
计算两个bbox的IoU
modules/metric_evaluator.py:142
↓ 4 callers
Method
is_valid_formula
验证是否为有效公式 过滤条件: 1. 长度 >= 2 2. 包含数学符号 3. 不包含无效模式 4. 不是纯粗体短文本 5. 不是重复模式(如 \b=\b=\b=...
modules/text/processors/formula.py:210
↓ 4 callers
Function
load_config
Load config/config.yaml.
main.py:62
↓ 4 callers
Method
process
Process image and return draw.io XML string. Args: image_path: Input image path. Returns: draw.io XM
modules/text/restorer.py:92
↓ 4 callers
Function
scan_line
(pixels, limit)
modules/basic_shape_processor.py:214
↓ 3 callers
Method
_convert_to_elements
将原始结果转换为ElementInfo列表
modules/sam3_info_extractor.py:611
↓ 3 callers
Function
calculate_iou
计算两个矩形框的 IoU
modules/basic_shape_processor.py:163
↓ 3 callers
Function
extract_style_specific
针对不同基础形状的特定取色和边框算法。 - 对于矩形类形状,使用动态边框宽度检测 - 对于非矩形形状(椭圆、菱形等),使用Mask提取更准确的填充色
modules/basic_shape_processor.py:393
↓ 3 callers
Method
from_list
(cls, coords: List[int])
modules/data_types.py:93
↓ 3 callers
Method
load_model
Load SAM3 model.
modules/sam3_info_extractor.py:396
↓ 3 callers
Function
main
()
main.py:325
↓ 3 callers
Method
predict
SAM3推理 Args: image_path: 图片路径 prompts: 提示词列表 score_threshold: 置信度阈值 min_area
modules/sam3_info_extractor.py:250
↓ 3 callers
Method
process
处理入口 - 合并所有XML片段 Args: context: 处理上下文,需要包含: - canvas_width, canvas_height: 画布尺寸
modules/xml_merger.py:76
↓ 3 callers
Method
process_image
Run pipeline on one image. Returns output XML path or None.
main.py:142
↓ 2 callers
Method
_calculate_containment
计算 box_inner 被 box_outer 包含的比例 返回值范围 [0, 1]: - 1.0 表示完全包含 - 0.0 表示无重叠
modules/sam3_info_extractor.py:944
↓ 2 callers
Method
_calculate_iou
Compute IoU of two boxes.
modules/sam3_info_extractor.py:872
↓ 2 callers
Method
_create_element_from_cv
从CV检测结果创建ElementInfo
modules/basic_shape_processor.py:1554
↓ 2 callers
Method
_deduplicate_within_group
组内去重
modules/sam3_info_extractor.py:640
↓ 2 callers
Method
_extract_text_bboxes_from_xml
从文字 XML 中提取所有文字元素的 bbox Args: text_xml: 文字处理生成的 XML 内容 img_width, img_height: 图片尺寸
modules/metric_evaluator.py:510
↓ 2 callers
Method
_filter_text_elements
Filter out text-type elements by blacklist/keywords.
modules/sam3_info_extractor.py:590
↓ 2 callers
Method
_generate_xml
生成mxCell XML
modules/basic_shape_processor.py:1487
↓ 2 callers
Function
_merge_nearby_lines
合并相近的平行线段,减少冗余 Args: lines: 线段列表,格式为 [(y, x1, x2), ...] 或 [(x, y1, y2), ...] threshold: 合并阈值,位置差小于此值的线段会被合并
modules/basic_shape_processor.py:708
↓ 2 callers
Method
_polygon_to_bbox
多边形转边界框 (x_min, y_min, x_max, y_max)
modules/text/processors/formula.py:308
↓ 2 callers
Method
_scale_xml_coordinates
缩放 XML 字符串中的坐标 支持两种格式: 1. 普通图形(vertex):mxGeometry 的 x, y, width, height 2. 箭头/边(edge):mxPoint 的 x, y(sourceP
modules/xml_merger.py:224
↓ 2 callers
Method
_should_refine_block
Whether to try refinement.
modules/text/restorer.py:389
↓ 2 callers
Function
add_cell
(item_list)
modules/basic_shape_processor.py:1700
↓ 2 callers
Method
analyze_image
(self, image_path: str)
modules/text/ocr/local_ocr.py:31
↓ 2 callers
Function
calculate_element_area
(bbox)
modules/basic_shape_processor.py:1653
↓ 2 callers
Method
clean_latex
清洗 LaTeX,替换不兼容的命令
modules/text/processors/formula.py:267
↓ 2 callers
Function
compare_with_rendered
对比原图和渲染后的图像,找出差异区域(遗漏的内容) Args: original_path: 原始图片路径 rendered_path: DrawIO渲染后的图片路径 config: 配置参数 - d
modules/metric_evaluator.py:1519
↓ 2 callers
Method
create_text_cell
创建文本单元格 Args: text: 文字内容 x, y: 左上角坐标 width, height: 尺寸 font_size: 字号(pt)
modules/text/xml_generator.py:235
↓ 2 callers
Function
detect_rectangles_robust
精准矩形检测(补充SAM3遗漏的矩形) 采用保守策略: - 默认只启用可靠的检测方法(contour, nested_contour) - 提高检测门槛减少误检 - 对检测结果进行内容验证 :param cv2_image: BG
modules/basic_shape_processor.py:818
↓ 2 callers
Method
extract_by_group
Extract only the given prompt group.
modules/sam3_info_extractor.py:493
↓ 2 callers
Function
extract_geometric_params
针对特定形状提取几何参数(如平行四边形的倾斜度、圆柱体的顶部高度等)。 返回参数字典,例如 {"size": 0.2, "direction": "south"}
modules/basic_shape_processor.py:82
↓ 2 callers
Function
extract_style_colors
精细化取色逻辑:区分 边框区域(Stroke) 和 内部区域(Fill) 优化策略: 1. Fill: 采样边框内侧的"回"字形区域(避开中心可能的文字),使用K-Means聚类找主色 2. Stroke: 提取边界框外围10%区域,取最暗的25%像素的均
modules/basic_shape_processor.py:267
↓ 2 callers
Method
generate_xml
生成完整的 draw.io XML Args: cells: 文本单元格列表 Returns: XML 字符串
modules/text/xml_generator.py:151
↓ 2 callers
Method
get_config_path
获取配置文件路径
modules/sam3_info_extractor.py:75
↓ 2 callers
Method
get_deduplication_config
获取去重配置
modules/sam3_info_extractor.py:192
↓ 2 callers
Method
get_prompt_groups
从配置文件加载词组配置
modules/sam3_info_extractor.py:146
↓ 2 callers
Method
get_sam3_config
获取SAM3配置
modules/sam3_info_extractor.py:207
↓ 2 callers
Function
get_style_for_item
获取元素样式,CV检测的强制使用黑色细边框
modules/basic_shape_processor.py:1662
↓ 2 callers
Method
get_text_filter
获取文字过滤配置
modules/sam3_info_extractor.py:186
↓ 2 callers
Method
infer_from_text
根据文本内容推测字体 推测规则(按优先级): 1. LaTeX 公式 → Times New Roman 2. 中文字符 → SimSun 3. 代码特征 → Courier New
modules/text/processors/font_family.py:172
↓ 2 callers
Method
load
加载SAM3模型
modules/sam3_info_extractor.py:229
↓ 2 callers
Method
load
Load RMBG-2.0 ONNX model; fallback to CPU if CUDA fails.
modules/icon_picture_processor.py:63
↓ 2 callers
Method
load_rmbg_model
Load RMBG model.
modules/icon_picture_processor.py:255
↓ 2 callers
Method
normalize_polygon
Normalize quadrilateral to canvas geometry.
modules/text/coord_processor.py:33
↓ 2 callers
Method
polygon_to_geometry
将多边形转换为 draw.io geometry 格式 Args: polygon: 四边形顶点坐标 Returns: dict: {"x", "y", "w
modules/text/coord_processor.py:100
↓ 2 callers
Method
process
处理入口 - 对问题区域进行Fallback补救 Args: context: 处理上下文 Returns: ProcessingResult,新增的元素会被
modules/refinement_processor.py:135
↓ 2 callers
Method
process
处理入口 - 评估质量 Args: context: 处理上下文 Returns: ProcessingResult,metadata中包含评估结果
modules/metric_evaluator.py:216
↓ 2 callers
Method
process_image
Process image and return list of text blocks.
modules/text/restorer.py:135
↓ 2 callers
Method
remove
(self, image_base64: str)
sam3_service/rmbg_client.py:48
↓ 2 callers
Function
rgb2hex
(rgb)
modules/basic_shape_processor.py:384
↓ 2 callers
Method
save_visualization
保存评估结果可视化图 Args: context: 处理上下文 bad_regions: 问题区域列表 output_path: 输出路径
modules/metric_evaluator.py:1295
↓ 2 callers
Method
standardize
标准化字体名称 策略: 1. 精确匹配映射表 2. 模糊匹配(如 ArialMT → Arial) 3. 归类未知字体
modules/text/processors/font_family.py:135
↓ 2 callers
Method
text_similarity
计算两个文本的相似度 改进:使用更严格的匹配,避免长文本与短公式误匹配
modules/text/processors/formula.py:276
↓ 1 callers
Method
__init__
(self, checkpoint_path: str, bpe_path: str, device: str = None)
modules/sam3_info_extractor.py:217
↓ 1 callers
Method
__init__
(self, model_path: str = None)
modules/icon_picture_processor.py:49
↓ 1 callers
Method
_add_text_cell
添加文本单元格到 XML
modules/text/xml_generator.py:218
↓ 1 callers
Method
_build_detection
( self, prompt: str, score: float, bbox: List[int], polygon: List[List
sam3_service/server.py:152
↓ 1 callers
Method
_build_style_string
构建 mxCell 样式字符串 draw.io 使用分号分隔的键值对表示样式: style="text;fontSize=12;fontStyle=1;fontColor=#000000;"
modules/text/xml_generator.py:98
↓ 1 callers
Method
_build_xml_structure
构建完整的DrawIO XML结构
modules/xml_merger.py:353
↓ 1 callers
Function
_calculate_area
(bbox: List[int])
sam3_service/server.py:76
↓ 1 callers
Method
_calculate_overlap_ratio
计算 box1 对 box2 的覆盖率 返回 (交集面积) / (box2 面积)
modules/text/processors/formula.py:319
↓ 1 callers
Method
_calculate_rotation
计算旋转角度 通过上边(P0 到 P1)的方向向量计算旋转角度。 水平向右为 0°,顺时针旋转为正角度。 Args: p0: 左上角坐标 p1: 右上
modules/text/coord_processor.py:71
↓ 1 callers
Method
_collect_fragments
收集所有XML片段 收集顺序: 1. 从 context.xml_fragments 获取 2. 从 context.elements 中提取有 xml_fragment 的元素(坐标需要缩放回原始尺寸)
modules/xml_merger.py:152
↓ 1 callers
Method
_convert_ocr_only
仅转换 OCR 结果(保留字体信息)
modules/text/processors/formula.py:189
↓ 1 callers
Method
_convert_position
转换坐标格式(numpy 数组 → Python 列表)
modules/text/ocr/pix2text.py:221
↓ 1 callers
Method
_create_base_xml
创建DrawIO基础XML结构
modules/xml_merger.py:416
↓ 1 callers
Method
_create_content_mask
创建内容掩码 - 识别图片中真正需要被检测的前景内容 关键改进:区分"前景内容"和"背景" - 背景:大面积连续的单色区域(白色、浅灰色、浅蓝色等) - 前景内容:图形、图标、文字、箭头等需要被检测的元素
modules/metric_evaluator.py:345
↓ 1 callers
Method
_create_covered_mask
创建覆盖掩码 - 严格判断有效输出 有效输出的定义: 1. 对于图片类内容(热力图、chart等):必须有 base64 才算覆盖 2. 对于基本矢量图形:有 xml_fragment 就算覆盖 3.
modules/metric_evaluator.py:432
↓ 1 callers
Method
_deduplicate_cross_groups
跨组去重(智能版) 规则: 1. 优先保留 priority 高的组 2. 同优先级时,保留 score 高的 3. 箭头与其他元素重叠时特殊处理 4. 【新增】基础图形和图片类重叠时
modules/sam3_info_extractor.py:748
↓ 1 callers
Method
_detect_bad_regions
识别问题区域 - 三重策略检测漏检区域 策略: 1. 双通道检测:基于内容掩码的细粒度/粗粒度连通域检测 2. 复杂图像区域检测:检测高方差区域(热力图、照片等)是否有 base64 覆盖 3. 小框
modules/metric_evaluator.py:548
↓ 1 callers
Method
_detect_coarse_channel
粗粒度通道:使用闭操作合并相邻内容 用于检测版块、大图、分散的图形组
modules/metric_evaluator.py:1014
↓ 1 callers
Method
_detect_complex_image_regions
检测复杂图像区域(热力图、照片、图表等) 三重策略: 1. 检查"图片类但没有 base64"的元素 2. 检测"完全没有被任何元素覆盖"的高复杂度区域(SAM3 漏检) 3. 基于图像分析的补充检测
modules/metric_evaluator.py:613
↓ 1 callers
Method
_detect_fine_channel
细粒度通道:不做形态学操作,直接连通域分析 用于检测小图、图标、人脸等小目标
modules/metric_evaluator.py:976
↓ 1 callers
Method
_detect_global_font
Detect global dominant font.
modules/text/restorer.py:481
↓ 1 callers
Function
_encode_mask_png
(mask: np.ndarray)
sam3_service/server.py:56
↓ 1 callers
Function
_encode_mask_rle
(mask: np.ndarray)
sam3_service/server.py:39
↓ 1 callers
Method
_escape_text
转义文本内容 - HTML 特殊字符转义 - LaTeX 公式转换为 MathJax 格式 \\(公式\\)
modules/text/xml_generator.py:135
↓ 1 callers
Method
_estimate_font_size
估算字号(取短边长度)
modules/text/ocr/pix2text.py:242
↓ 1 callers
Method
_extract_block_styles
提取单个文字块的样式
modules/text/processors/style.py:86
↓ 1 callers
Method
_extract_boxes
提取文字块的边界框
modules/text/processors/style.py:262
↓ 1 callers
Function
_extract_polygon
(binary_mask: np.ndarray, epsilon_factor: float)
sam3_service/server.py:64
↓ 1 callers
Method
_extract_polygon
从mask提取多边形轮廓
modules/sam3_info_extractor.py:345
↓ 1 callers
Method
_extract_text_fragments_from_xml
从 flowchart_text 生成的完整 XML 中提取 mxCell 片段 flowchart_text 生成的是完整的 drawio XML 文件, 我们需要从中提取 mxCell 元素(跳过 id=0 和 id=1 的基础
modules/xml_merger.py:285
↓ 1 callers
Method
_filter_candidates
最终过滤:与已有元素去重 + 覆盖比例过滤 对于 complex 通道(复杂图像检测),使用更宽松的过滤条件
modules/metric_evaluator.py:1099
↓ 1 callers
Method
_filter_contained_elements
过滤被大图完全包含的小元素 规则: 1. 如果小元素被图片类大元素包含 > 85%,只保留大元素 2. 图片类:icon, picture, logo, chart, function_graph 3
modules/sam3_info_extractor.py:889
↓ 1 callers
Method
_generate_debug_image
Generate debug image.
modules/text/restorer.py:551
↓ 1 callers
Method
_generate_xml
Generate XML fragment for image element.
modules/icon_picture_processor.py:380
↓ 1 callers
Method
_generate_xml_fragment
为 fallback 元素生成 XML 片段 Args: element: 元素信息
modules/refinement_processor.py:347
↓ 1 callers
Method
_generate_xml_fragments
Generate XML for elements that do not have one yet. Arrows are treated as icon (image crop).
main.py:277
↓ 1 callers
Method
_get_default_config
获取默认配置(当config.yaml不存在时使用)
modules/sam3_info_extractor.py:98
↓ 1 callers
Method
_get_default_path
Default model path under models/rmbg/.
modules/icon_picture_processor.py:56
next →
1–100 of 308, ranked by callers