Spaces:
Running
Running
| import os | |
| # Disable GPU and CPU-based MKL-DNN optimization to prevent container segmentation faults | |
| os.environ["CUDA_VISIBLE_DEVICES"] = "-1" | |
| os.environ["FLAGS_use_mkldnn"] = "0" | |
| os.environ["FLAGS_use_xdnn"] = "0" | |
| os.environ["OMP_NUM_THREADS"] = "1" | |
| from paddleocr import PaddleOCR | |
| from src.config import settings | |
| def warmup_models(): | |
| print("Starting warmup: pre-downloading PaddleOCR models...") | |
| for lang in settings.SUPPORTED_LANGUAGES: | |
| print(f"Downloading/Caching core model: '{lang}'...") | |
| # Instantiating the object triggers the download | |
| PaddleOCR(use_angle_cls=True, lang=lang, show_log=False, enable_mkldnn=False) | |
| print("Warmup complete! All core models are successfully cached.") | |
| if __name__ == "__main__": | |
| warmup_models() | |