🤖 AI disclaimer: this post was written by Claude Opus 5.5.

I wanted a copy of a Hugging Face model on ModelScope. Normally I’d download it to my laptop and upload it again, but with tens of gigabytes of weights, that pushes everything through my home connection twice and means leaving the laptop on and online until both finish.

Instead, I run the transfer on Google Colab. A free account with a CPU-only runtime is enough, since copying files doesn’t need a GPU. Colab’s network is fast, and the files go from Hugging Face to Colab to ModelScope without using my own bandwidth.

I use ms2hf for this. Its hf2ms command copies the repo one file at a time: it downloads a file from Hugging Face, uploads it to ModelScope, deletes the local copy, and moves on. That way Colab’s disk only holds a few files at once, even for a large model. Before uploading, it checks what’s already in the ModelScope repo and skips those files. If the Colab session drops, you can run the cell again and it picks up where it left off.

The script

Paste this into a single Colab cell:

# EDIT
MS_USER = "username"
SRC     = "org/model"
DST     = f"{MS_USER}/model"
DRY_RUN = True      # True = only list files + create repo. Then set False, rerun.
PRIVATE = False     # True = private ModelScope repo

# install
!pip install -q ms2hf

# tokens
import os
from getpass import getpass
if not os.environ.get("HF_TOKEN"):
    os.environ["HF_TOKEN"] = getpass("Hugging Face token: ")
if not os.environ.get("MS_TOKEN"):
    os.environ["MS_TOKEN"] = getpass("ModelScope token: ")

# sync
flags = ("--dry-run " if DRY_RUN else "") + ("--private" if PRIVATE else "")
!hf2ms {SRC} {DST} --repo-type model --create-target --workers 6 --work-dir /content/sync {flags}

Running it

  1. Get a Hugging Face token and a ModelScope token.
  2. Edit the top of the cell. SRC is the Hugging Face repo, and DST is the ModelScope repo you’re copying into. Set PRIVATE now, because the first run creates the repo.
  3. Run the cell with DRY_RUN = True and paste both tokens when asked. This creates the ModelScope repo and lists the files to copy without downloading anything.
  4. Set DRY_RUN = False and run the cell again. The tokens stay in the session, so it won’t ask for them a second time.

After that, wait for it to finish. --workers 6 copies six files in parallel, so if a model has very large weight files and Colab’s disk fills up, lower that number.