Skip to content

Error: "No available model hosting platforms detected. Please check your network connection" when running OCR pipeline offline - paddleocr v3.2.0, paddlepaddle v3.2.0 #16620

Description

@zeeeffchow

🔎 Search before asking

  • I have searched the PaddleOCR Docs and found no similar bug report.
  • I have searched the PaddleOCR Issues and found no similar bug report.
  • I have searched the PaddleOCR Discussions and found no similar bug report.

🐛 Bug (问题描述)

Are we able to run PaddleOCR 3.2.0 offline?

I have downloaded and installed the models locally (they are in .paddlex/) and tried running the OCR pipeline without Internet connection. It seems it will connect to a model registry to download models from, and if there is no connection, the pipeline ends with the error:
"Failed to load OCR models: No available model hosting platforms detected. Please check your network connection".

It does not go on to look for the model locally, even though it says in an earlier warning that if I don't have a network connection, only local models will be used:
"No model hoster is available! Please check your network connection to one of the following model hosts:
HuggingFace (https://huggingface.co),
ModelScope (https://modelscope.cn),
AIStudio (https://aistudio.baidu.com), or
BOS (https://paddle-model-ecology.bj.bcebos.com).
Otherwise, only local models can be used."

When I try to run the pipeline with Internet connection, only then it realizes that the model files already exist and it goes on to use them:
Creating model: ('PP-LCNet_x1_0_doc_ori', None)
Model files already exist. Using cached files. To redownload, please delete the directory manually: C:\Users\User\.paddlex\official_models\PP-LCNet_x1_0_doc_ori.
Creating model: ('UVDoc', None)
Model files already exist. Using cached files. To redownload, please delete the directory manually: C:\Users\User\.paddlex\official_models\UVDoc.
...

I have confirmed that the model files are already stored in .paddlex/. Am I doing something wrong here?

🏃‍♂️ Environment (运行环境)

python 3.9.18
paddleocr 3.2.0
paddlepaddle 3.2.0

🌰 Minimal Reproducible Example (最小可复现问题的Demo)

"""
Issue: PaddleOCR 3.2.0 fails to initialize offline even when models are cached locally.
It attempts to connect to HuggingFace, ModelScope, AIStudio, and BOS before checking local cache.

Expected: Should work offline once models are downloaded.
Actual: Raises "No available model hosting platforms detected" error.

Environment:

  • PaddleOCR: 3.2.0
  • paddlepaddle: 3.2.0
  • Python: 3.9.18
  • OS: Windows (also reproducible on Linux through WSL)
    """

Step 1: First run WITH internet to download models

print("Step 1: Downloading models (run with internet connection)...")
try:
from paddleocr import PaddleOCR

# Download English model
ocr_en = PaddleOCR(
    use_textline_orientation=True,
    lang='en',
    enable_mkldnn=True,
)
print("✓ English model downloaded successfully")

# Download Arabic model  
ocr_ar = PaddleOCR(
    use_textline_orientation=True,
    lang='ar',
    enable_mkldnn=True,
)
print("✓ Arabic model downloaded successfully")

print("\nModels are now cached locally.")
print("Please disconnect internet and run this script again.\n")

except Exception as e:
print(f"✗ Error during download: {e}")

Step 2: Run OFFLINE (disconnect internet before running this part)

print("\n" + "="*60)
print("Step 2: Testing offline initialization...")
print("Please ensure internet is DISCONNECTED before proceeding.")
print("="*60 + "\n")

input("Press Enter when offline to test...")

try:
from paddleocr import PaddleOCR

print("Attempting to load English model offline...")
ocr_en_offline = PaddleOCR(
    use_textline_orientation=True,
    lang='en',
    enable_mkldnn=True,
)
print("✓ English model loaded offline successfully!")

except Exception as e:
print(f"✗ FAILED to load offline: {e}")
print("\nExpected behavior: Should load from local cache")
print("Actual behavior: Tries to connect to online sources and fails")

"""
Expected Error Output:

DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): huggingface.co:443
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): aistudio.baidu.com:443
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): modelscope.cn:443
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): paddle-model-ecology.bj.bcebos.com:443
No model hoster is available! Please check your network connection...
Creating model: ('PP-LCNet_x1_0_doc_ori', None)
No available model hosting platforms detected. Please check your network connection.
ERROR: Failed to load OCR models: No available model hosting platforms detected.

Workaround Attempts:

None of these work in PaddleOCR 3.2.0:

  1. os.environ['PADDLE_PDX_USE_LOCAL_MODEL'] = '1'
  2. os.environ['PADDLE_PDX_SKIP_CHECK'] = '1'
  3. Specifying explicit model paths with det_model_dir, rec_model_dir, cls_model_dir

Requested Fix:

PaddleOCR should check local cache BEFORE attempting network connections,
or provide a documented way to disable online checks for full offline deployments.
"""

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions