allow environment variable for BASE_DIR models (#14678)

* allow environment variable for BASE_DIR models

* add doc for environment variable PADDLE_OCR_BASE_DIR

* fix code style error
pull/14686/head
mauryaland 2025-02-14 14:58:00 +01:00 committed by GitHub
parent 500e1a78cb
commit 44e17bae0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -24,6 +24,10 @@ hide:
python -m pip install paddlepaddle-gpu==3.0.0rc1 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
```
You can customize the storage location for OCR models by setting the environment variable `PADDLE_OCR_BASE_DIR`. If this variable is not set, the models will be downloaded to the following default locations:
- On Linux/macOS: `${HOME}/.paddleocr`
- On Windows: `C:\Users\{username}\.paddleocr`
### Use by code
=== "Detection + Classification + Recognition"

View File

@ -85,7 +85,7 @@ __all__ = [
SUPPORT_DET_MODEL = ["DB"]
SUPPORT_REC_MODEL = ["CRNN", "SVTR_LCNet"]
BASE_DIR = os.path.expanduser("~/.paddleocr/")
BASE_DIR = os.environ.get("PADDLE_OCR_BASE_DIR", os.path.expanduser("~/.paddleocr/"))
DEFAULT_OCR_MODEL_VERSION = "PP-OCRv4"
SUPPORT_OCR_MODEL_VERSION = ["PP-OCR", "PP-OCRv2", "PP-OCRv3", "PP-OCRv4"]