創建huggingface賬號和token
在https://huggingface.co/join注冊huggingface賬號,登錄賬號后,在https://huggingface.co/settings/tokens創建token,注意需要將token的類型設置為WRITE。
安裝必要軟件包和初始化環境
安裝git lfs
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs
git lfs install
安裝并登錄huggingface-cli
pip install huggingface_hub
注意,這里需要輸入你創建的token
創建repo
huggingface-cli repo create model_name
上傳自己的模型
首先git clone到本地
git lfs install
git clone https://huggingface.co/your_username/model_name
然后將你的模型(checkpoint)保存到這個repo中。
再進行git repo的上傳。
git add .
git commit -m "commit from $USER"
git push
其中,$USER指的是你配置的github的用戶名或郵箱。關于如何配置,見https://blog.csdn.net/weixin_44022515/article/details/105967226。
之后,再打開huggingface你模型地址的網頁,即可看到自己發布的模型。(我上傳的網速好慢,才1.6MB/s)
更新
執行git push很久后,終于成功上傳,但是,出現了如下錯誤
error: failed to push some refs to 'https://huggingface.co/itpossible/JiuZhou'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
原來是,在他上傳過程中,我閑著沒事,去huggingface的repo里改了readme,導致版本出現更改。
解決方法:
git pull origin 分支名(如main)
這個時候,我們會發現,readme會更新到我們的服務器上。此時再執行git pull,便能成功,