Browse Source

add fitz_preprocess as default preprocess for image parser to align with demo

zhangwei13 3 tháng trước cách đây
mục cha
commit
6a854390b4
1 tập tin đã thay đổi với 8 bổ sung5 xóa
  1. 8 5
      dots_ocr/parser.py

+ 8 - 5
dots_ocr/parser.py

@@ -379,10 +379,10 @@ def main():
         "--num_thread", type=int, default=16,
         help=""
     )
-    # parser.add_argument(
-    #     "--fitz_preprocess", type=bool, default=False,
-    #     help="False will use tikz dpi upsample pipeline, good for images which has been render with low dpi, but maybe result in higher computational costs"
-    # )
+    parser.add_argument(
+        "--no_fitz_preprocess", action='store_true',
+        help="False will use tikz dpi upsample pipeline, good for images which has been render with low dpi, but maybe result in higher computational costs"
+    )
     parser.add_argument(
         "--min_pixels", type=int, default=None,
         help=""
@@ -412,11 +412,14 @@ def main():
         use_hf=args.use_hf,
     )
 
+    fitz_preprocess = not args.no_fitz_preprocess
+    if fitz_preprocess:
+        print(f"Using fitz preprocess for image input, check the change of the image pixels")
     result = dots_ocr_parser.parse_file(
         args.input_path, 
         prompt_mode=args.prompt,
         bbox=args.bbox,
-        fitz_preprocess=True,
+        fitz_preprocess=fitz_preprocess,
         )