-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add scripts to mirror hf model to modelscope
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
hf_model | ||
ms_model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# copy-to-modelscope | ||
|
||
Scripts to copy huggingface model to modelscope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
MODEL_ID=$1 | ||
ACCESS_TOKEN=$2 | ||
|
||
usage() { | ||
echo "Usage: $0 <model_id> <access_token>" | ||
exit 1 | ||
} | ||
|
||
if [ -z "${MODEL_ID}" ]; then | ||
usage | ||
fi | ||
|
||
git clone https://huggingface.co/$MODEL_ID hf_model | ||
git clone https://oauth2:${ACCESS_TOKEN}@www.modelscope.cn/$MODEL_ID.git ms_model | ||
|
||
echo "Sync directory" | ||
rsync -a --exclude '.git' hf_model/ ms_model/ | ||
|
||
echo "Create README.md" | ||
cat <<EOF >ms_model/README.md | ||
--- | ||
license: other | ||
tasks: | ||
- text-generation | ||
--- | ||
# ${MODEL_ID} | ||
This is an mirror of [${MODEL_ID}](https://huggingface.co/${MODEL_ID}). | ||
EOF | ||
|
||
echo "Create configuration.json" | ||
cat <<EOF >ms_model/configuration.json | ||
{ | ||
"framework": "pytorch", | ||
"task": "text-generation", | ||
"pipeline": { | ||
"type": "text-generation-pipeline" | ||
} | ||
} | ||
EOF | ||
|
||
set -x | ||
cd ms_model | ||
git add . | ||
git commit -m "sync with upstream" | ||
git push origin | ||
|
||
echo "Success!" | ||
rm -rf hf_model | ||
rm -rf ms_model |