Browse Source

fix(zhch): 修复结果保存逻辑和异常处理

- 修改 input_path 的访问方式,从直接获取属性改为通过键值对获取
- 添加异常堆栈信息打印,便于调试
- 统一处理 batch_results 中 image_path 的生成逻辑
- 注释掉结果处理中的打印语句
zhch158_admin 3 months ago
parent
commit
9a0b44e7ed
1 changed files with 4 additions and 3 deletions
  1. 4 3
      zhch/ppstructurev3_multi_gpu_multiprocess_official.py

+ 4 - 3
zhch/ppstructurev3_multi_gpu_multiprocess_official.py

@@ -98,7 +98,7 @@ def worker(pipeline_name_or_config_path: str,
                     
                     for result in results:
                         try:
-                            input_path = Path(result.input_path)
+                            input_path = Path(result["input_path"])
                             
                             # 保存结果
                             if result.get("page_index") is not None:
@@ -127,8 +127,9 @@ def worker(pipeline_name_or_config_path: str,
                             processed_count += 1
                             
                         except Exception as e:
+                            traceback.print_exc()
                             batch_results.append({
-                                "image_path": Path(result.input_path).name if hasattr(result, 'input_path') else "unknown",
+                                "image_path": Path(result["input_path"]).name,
                                 "processing_time": 0,
                                 "success": False,
                                 "device": device,
@@ -139,7 +140,7 @@ def worker(pipeline_name_or_config_path: str,
                     # 将结果放入结果队列
                     result_queue.put(batch_results)
                     
-                    print(f"Worker {worker_id} ({device}) processed batch of {len(batch)} files. Total: {processed_count}")
+                    # print(f"Worker {worker_id} ({device}) processed batch of {len(batch)} files. Total: {processed_count}")
                     
                 except Exception as e:
                     # 批处理失败