|
|
@@ -162,6 +162,14 @@ class SmartLayoutRouter(BaseLayoutDetector):
|
|
|
if model_name == 'fallback':
|
|
|
continue # 跳过回退模型(除非所有模型都失败)
|
|
|
try:
|
|
|
+ # 传递 debug 模式配置给子模型(如果启用)
|
|
|
+ if self.debug_mode:
|
|
|
+ model.debug_mode = self.debug_mode # type: ignore
|
|
|
+ if self.output_dir:
|
|
|
+ model.output_dir = self.output_dir # type: ignore
|
|
|
+ if self.page_name:
|
|
|
+ model.page_name = self.page_name # type: ignore
|
|
|
+
|
|
|
# 调用 detect() 方法,基类会自动执行后处理
|
|
|
results = model.detect(image)
|
|
|
all_postprocessed_results[model_name] = results
|
|
|
@@ -174,6 +182,13 @@ class SmartLayoutRouter(BaseLayoutDetector):
|
|
|
# 如果所有模型都失败,尝试回退模型
|
|
|
if 'fallback' in self.models:
|
|
|
logger.info("🔄 All models failed, using fallback model")
|
|
|
+ # 传递 debug 模式配置给回退模型(如果启用)
|
|
|
+ if self.debug_mode:
|
|
|
+ self.models['fallback'].debug_mode = self.debug_mode # type: ignore
|
|
|
+ if self.output_dir:
|
|
|
+ self.models['fallback'].output_dir = self.output_dir # type: ignore
|
|
|
+ if self.page_name:
|
|
|
+ self.models['fallback'].page_name = self.page_name # type: ignore
|
|
|
# 回退模型使用 detect() 方法(会自动执行后处理)
|
|
|
fallback_result = self.models['fallback'].detect(image)
|
|
|
return fallback_result
|