Spaces:
Running
Running
Update working_yolo_pipeline.py
Browse files- working_yolo_pipeline.py +17 -1
working_yolo_pipeline.py
CHANGED
|
@@ -2131,10 +2131,26 @@ def run_document_pipeline(input_path: str, layoutlmv3_model_path: str):
|
|
| 2131 |
print("❌ No data extracted.")
|
| 2132 |
return None
|
| 2133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2134 |
# 3. CONSOLIDATE BLOCKS FOR INFERENCE
|
| 2135 |
sequential_blocks = []
|
| 2136 |
for p_data in all_pages_data:
|
| 2137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2138 |
|
| 2139 |
# --- 4. STARTING LAYOUTLMV3 INFERENCE ---
|
| 2140 |
print("\n" + "=" * 80)
|
|
|
|
| 2131 |
print("❌ No data extracted.")
|
| 2132 |
return None
|
| 2133 |
|
| 2134 |
+
# # 3. CONSOLIDATE BLOCKS FOR INFERENCE
|
| 2135 |
+
# sequential_blocks = []
|
| 2136 |
+
# for p_data in all_pages_data:
|
| 2137 |
+
# sequential_blocks.extend(p_data.get('blocks', []))
|
| 2138 |
+
|
| 2139 |
# 3. CONSOLIDATE BLOCKS FOR INFERENCE
|
| 2140 |
sequential_blocks = []
|
| 2141 |
for p_data in all_pages_data:
|
| 2142 |
+
if isinstance(p_data, dict):
|
| 2143 |
+
# If it's a dictionary, extract the 'blocks' key
|
| 2144 |
+
blocks = p_data.get('blocks', [])
|
| 2145 |
+
sequential_blocks.extend(blocks)
|
| 2146 |
+
elif isinstance(p_data, list):
|
| 2147 |
+
# If it's already a list, add it directly
|
| 2148 |
+
sequential_blocks.extend(p_data)
|
| 2149 |
+
else:
|
| 2150 |
+
print(f"⚠️ Warning: Unexpected data type in all_pages_data: {type(p_data)}")
|
| 2151 |
+
|
| 2152 |
+
|
| 2153 |
+
|
| 2154 |
|
| 2155 |
# --- 4. STARTING LAYOUTLMV3 INFERENCE ---
|
| 2156 |
print("\n" + "=" * 80)
|