A guide on solving failed downloads due to token expiration on slow networks. Why I use ModelScope CLI for specific files and Git LFS for full repositories.

If you frequently deploy local AI models (like LLMs or ComfyUI workflows), you know the pain of downloading massive .safetensors files.

While downloading from ModelScope or Hugging Face is usually straightforward, it becomes a nightmare in low-bandwidth environments.

The Problem: HTTP Timeouts & Token Expiry

I often run into a specific issue when using standard tools like wget or a web browser to download large model weights (5GB+):

  1. The Connection Drops: On a slow network, a download might take over an hour.
  2. Token Expiration: The secure download link generated by the web interface often has a lifespan. If your download takes too long, the authentication token expires mid-stream.
  3. Result: The connection is severed, wget cannot resume, and you have to start over from zero.

To solve this, I’ve adopted a hybrid workflow: using ModelScope CLI for surgical, single-file downloads, and Git LFS for full repository management.

1. The Solution: ModelScope CLI

The ModelScope Command Line Interface (CLI) is the most robust way to download individual files. Unlike a raw HTTP request, the CLI handles authentication refreshing and is generally more resilient to network fluctuations.

Installation

First, ensure you have the library installed:

pip install modelscope

This is my go-to method when I just need a specific weight file (e.g., a ControlNet model) without cloning the entire history or auxiliary files.

Command Syntax: modelscope download --model <repo_id> <filename> --local_dir <path>

Example: Downloading the README.md (or a model file) from the Comfy-Org/Qwen-Image-DiffSynth-ControlNets repo to a specific directory:

modelscope download --model Comfy-Org/Qwen-Image-DiffSynth-ControlNets README.md --local_dir ./dir

Why this is better:

  • Stability: It doesn’t fail after 1 hour due to token issues.
  • Precision: You don’t waste bandwidth downloading the .git folder or unnecessary FP32 weights when you only need FP16.
  • Organization: The --local_dir flag lets you target your specific model folder directly.

Downloading the Full Repo via CLI

If you prefer using the CLI for everything, you can omit the filename to grab the whole repo:

modelscope download --model Comfy-Org/Qwen-Image-DiffSynth-ControlNets --local_dir ./Qwen-Image-DiffSynth-ControlNets

2. The Classic Method: Git LFS

While the CLI is great for picking specific files, I still prefer Git LFS (Large File Storage) when I need to manage the entire project version control or when I need to pull updates regularly.

Prerequisites

Make sure LFS is initialized:

git lfs install

Cloning the Repository

git clone https://www.modelscope.cn/Comfy-Org/Qwen-Image-DiffSynth-ControlNets.git

Pro Tip: Skipping Large Files

Sometimes you want to clone the repository structure and code (Python scripts, configs) without downloading the massive binary files immediately (perhaps to check the code first). You can skip the “smudge” process:

GIT_LFS_SKIP_SMUDGE=1 git clone https://www.modelscope.cn/Comfy-Org/Qwen-Image-DiffSynth-ControlNets.git

3. Alternative: Python SDK

If you are writing an automation script or a Docker setup script, using the Python SDK is cleaner than calling shell commands.

from modelscope import snapshot_download

# Downloads the whole repo to the default cache dir  
model_dir = snapshot_download('Comfy-Org/Qwen-Image-DiffSynth-ControlNets')

print(f"Model downloaded to: {model_dir}")

Summary

Here is my rule of thumb for bandwidth-constrained environments:

ScenarioRecommended ToolReason
Single file (e.g., .safetensors)ModelScope CLIBest stability; prevents token expiration timeouts.
Full Project / CodebaseGit LFSBetter version control; standard Git workflow.
Automated ScriptsPython SDKEasier to handle paths and variables in code.

Stop fighting with wget timeouts—use the CLI tools designed for the job.