1. 环境配置
# git 安装:https://git-scm.com/
# git lfs安装:https://git-lfs.com
git lfs install
# huggingface-cli 安装:https://huggingface.co/docs/hub/index
pip install huggingface_hub
2. 网站直接下载模型
可能会中断,中断后刷新继续即可
3. 客户端下载模型
指令格式:
huggingface-cli download 线上库名
示例:
huggingface-cli download genai-archive/anything-v5 anything-v5.safetensors --resume-download --local-dir .\hf-model\
解释:
下载genai-archive/anything-v5库中anything-v5.safetensors模型到当前hf-model子目录
常用参数:
--resume-download:全部库文件
file1 file2:下载file1, file2多个文件
--include:下载特定文件
--exclude:不下载特定文件
--local-dir:本地存储目录
--token:如果仓库是受保护的,需要提供访问令牌。
--repo-type:指定下载的资源类型,可以是model、dataset或space。
--revision:指定下载的版本号,可以是分支名、标签或提交哈希。
--cache-dir:指定缓存目录。
--local-dir-use-symlinks:是否使用软链接,默认为auto,可以设置为True或False。
--force-download:强制重新下载,即使文件已存在。
--quiet:在下载过程中不显示进度信息。
4. 通过镜像下载模型
hf-mirror.com代替huggingface.co