RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
fix(deepdoc): prevent figure and equation crops from merging on scientific PDFs (#15873)
Dexterity18ea0fb7f9a6
diff --git a/deepdoc/vision/layout_recognizer.py b/deepdoc/vision/layout_recognizer.pyindex 21bc1f4bad..e71b6a654c 100644--- a/deepdoc/vision/layout_recognizer.py+++ b/deepdoc/vision/layout_recognizer.py@@ -136,16 +136,23 @@ class LayoutRecognizer(Recognizer):for lt in ["footer", "header", "reference", "figure caption", "table caption", "title", "table", "text", "figure", "equation"]:findLayout(lt)- # add box to figure layouts which has not text box- for i, lt in enumerate([lt for lt in lts if lt["type"] in ["figure", "equation"]]):- if lt.get("visited"):- continue- lt = deepcopy(lt)- del lt["type"]- lt["text"] = ""- lt["layout_type"] = "figure"- lt["layoutno"] = f"figure-{i}"- bxs.append(lt)+ # add box to figure/equation layouts which have no text box.+ # Index within each type's own list and keep the type as the layoutno+ # prefix so these match the namespace findLayout() assigns to+ # text-overlapping boxes (figure-N vs equation-N). Using a combined+ # figure+equation index with a fixed "figure" prefix would collide+ # with figure-N tags from findLayout and merge unrelated regions.+ for ty in ["figure", "equation"]:+ for i, lt in enumerate([lt for lt in lts if lt["type"] == ty]):+ if lt.get("visited"):+ continue+ lt = deepcopy(lt)+ lt.pop("type", None)+ lt["text"] = ""+ lt["layout_type"] = "figure"+ lt["layoutno"] = f"{ty}-{i}"+ logging.debug(f"Created placeholder box {lt['layoutno']} for textless {ty} region")+ bxs.append(lt)boxes.extend(bxs)@@ -437,16 +444,22 @@ class AscendLayoutRecognizer(Recognizer):for ty in ["footer", "header", "reference", "figure caption", "table caption", "title", "table", "text", "figure", "equation"]:_tag_layout(ty)- figs = [lt for lt in lts if lt["type"] in ["figure", "equation"]]- for i, lt in enumerate(figs):- if lt.get("visited"):- continue- lt = deepcopy(lt)- lt.pop("type", None)- lt["text"] = ""- lt["layout_type"] = "figure"- lt["layoutno"] = f"figure-{i}"- bxs.append(lt)+ # Index within each type's own list and keep the type as the layoutno+ # prefix so these match the namespace _tag_layout() assigns to+ # text-overlapping boxes (figure-N vs equation-N). Using a combined+ # figure+equation index with a fixed "figure" prefix would collide+ # with figure-N tags from _tag_layout and merge unrelated regions.+ for ty in ["figure", "equation"]:+ for i, lt in enumerate([lt for lt in lts if lt["type"] == ty]):+ if lt.get("visited"):+ continue+ lt = deepcopy(lt)+ lt.pop("type", None)+ lt["text"] = ""+ lt["layout_type"] = "figure"+ lt["layoutno"] = f"{ty}-{i}"+ logging.debug(f"Created placeholder box {lt['layoutno']} for textless {ty} region")+ bxs.append(lt)boxes_out.extend(bxs)