đ¤ 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
- Get a Hugging Face token and a ModelScope token.
- Edit the top of the cell.
SRCis the Hugging Face repo, andDSTis the ModelScope repo youâre copying into. SetPRIVATEnow, because the first run creates the repo. - Run the cell with
DRY_RUN = Trueand paste both tokens when asked. This creates the ModelScope repo and lists the files to copy without downloading anything. - Set
DRY_RUN = Falseand 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.