Download scripts/push_ms.py from baicai1145/g2pS: direct link, hf CLI and curl.
- Browser
- Download file 794 Bytes
-
https://huggingface.co/baicai1145/g2pS/resolve/main/scripts/push_ms.py
- Command line
-
hf download hf://baicai1145/g2pS/scripts/push_ms.py
-
curl -L -o push_ms.py https://huggingface.co/baicai1145/g2pS/resolve/main/scripts/push_ms.py
794 Bytes
| """Upload weights to ModelScope. Usage: MS_TOKEN=xxx python scripts/push_ms.py [namespace/g2pS]""" | |
| import os | |
| import sys | |
| from modelscope.hub.api import HubApi | |
| repo = sys.argv[1] if len(sys.argv) > 1 else 'baicai-1145/g2pS' | |
| api = HubApi() | |
| api.login(os.environ['MS_TOKEN']) | |
| api.create_repo(repo, repo_type='model', exist_ok=True) | |
| # upload weights + meta (skip code dirs) | |
| folders = ['models', 'torch_weights'] | |
| files = ['README.md', 'MODEL_CARD.md', 'LICENSE'] | |
| for f in files: | |
| api.upload_file(repo_id=repo, repo_type='model', path_or_fileobj=f, path_in_repo=f) | |
| for d in folders: | |
| for root, _, fs in os.walk(d): | |
| for f in fs: | |
| p = os.path.join(root, f) | |
| api.upload_file(repo_id=repo, repo_type='model', path_or_fileobj=p, path_in_repo=p) | |
| print('uploaded', repo) | |