소스 검색

fix(demo): add fallback to internal model when external model data is missingIf no valid model data is provided, the system now checks if an internal model
should be used. This enhances the robustness of the demo pipeline by providing
a default behavior when essential data is not available.

myhloli 1 년 전
부모
커밋
720db843c5
1개의 변경된 파일7개의 추가작업 그리고 0개의 파일을 삭제
  1. 7 0
      demo/demo.py

+ 7 - 0
demo/demo.py

@@ -23,6 +23,13 @@ try:
     image_writer = DiskReaderWriter(local_image_dir)
     pipe = UNIPipe(pdf_bytes, jso_useful_key, image_writer)
     pipe.pipe_classify()
+    """如果没有传入有效的模型数据,则使用内置model解析"""
+    if len(model_json) == 0:
+        if model_config.__use_inside_model__:
+            pipe.pipe_analyze()
+        else:
+            logger.error("need model list input")
+            exit(1)
     pipe.pipe_parse()
     md_content = pipe.pipe_mk_markdown(image_dir, drop_mode="none")
     with open(f"{demo_name}.md", "w", encoding="utf-8") as f: