diff --git a/ocr-service/main.py b/ocr-service/main.py index 3a2c084e..cdaac88b 100644 --- a/ocr-service/main.py +++ b/ocr-service/main.py @@ -465,7 +465,15 @@ async def segtrain_model( "-N", "10", ] if os.path.exists(blla_model_path): - cmd += ["-i", blla_model_path] + cmd += ["-i", blla_model_path, "--resize", "both"] + else: + # No pretrained model — train from scratch with reduced height (800px) + # to keep peak RAM under ~200 MB on CPU (default 1800px uses ~500 MB+) + cmd += [ + "-s", + "[1,800,0,3 Cr7,7,64,2,2 Gn32 Cr3,3,128,2,2 Gn32 Cr3,3,128 Gn32 " + "Cr3,3,256 Gn32 Cr3,3,256 Gn32 Lbx32 Lby32 Cr1,1,32 Gn32 Lby32 Lbx32]", + ] cmd += xml_files log.info("Running: %s", " ".join(cmd[:5]) + " ...")