分享

huggingface 下载模型安装官网的工具 现在全局环境就有了这个工具 检查工具是否安装上 在 Hugging Fa

 netouch 2025-05-02 发布于北京

AI 模型都比较大, 如果使用浏览器自带的下载,会很慢,然后可能会自动下载到一半,自动中断; 现在我们使用官方提供的下载工具下载模型。

  1. 安装官网的工具
shell
代码解读
复制代码
pip install -U huggingface_hub

现在全局环境就有了这个工具

shell
代码解读
复制代码
huggingface-cli --help
  1. 检查工具是否安装上
shell
代码解读
复制代码
> huggingface-cli --help usage: huggingface-cli <command> [<args>] positional arguments: {download,upload,repo-files,env,login,whoami,logout,auth,repo,lfs-enable-largefiles,lfs-multipart-upload,scan-cache,delete-cache,tag,version,upload-large-folder} huggingface-cli command helpers download Download files from the Hub upload Upload a file or a folder to a repo on the Hub repo-files Manage files in a repo on the Hub env Print information about the environment. login Log in using a token from /settings/tokens whoami Find out which account you are logged in as. logout Log out auth Other authentication related commands repo {create} Commands to interact with your repos. lfs-enable-largefiles Configure your repository to enable upload of files > 5GB. scan-cache Scan cache directory. delete-cache Delete revisions from the cache directory. tag (create, list, delete) tags for a repo in the hub version Print information about the huggingface-cli version. upload-large-folder Upload a large folder to a repo on the Hub options: -h, --help show this help message and exit
  1. 在 Hugging Face 中创建 访问令牌 access token

/settings/to…

请提前注册好账号

image.png

创建好令牌以后, Huggingface 会给你一段字符串,一定要自己存一下, 这个秘钥 后面会用到,如果丢失,请重新创建一个

image.png

  1. 登录
代码解读
复制代码
huggingface-cli login

把上面创建的秘钥粘贴在这里,然后 添加token到 git 中,输入Y

已经登录成功

vbnet
代码解读
复制代码
> huggingface-cli login _| _| _| _| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _|_|_|_| _|_| _|_|_| _|_|_|_| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _| _|_|_|_| _| _| _| _|_| _| _|_| _| _| _| _| _| _|_| _|_|_| _|_|_|_| _| _|_|_| _| _| _| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _| _| _| _|_| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _| _| _| _|_|_| _|_|_|_| To log in, `huggingface_hub` requires a token generated from https:///settings/tokens . Enter your token (input will not be visible): Add token as git credential? (Y/n) Y Token is valid (permission: fineGrained). The token `live-xia` has been saved to /Users/xia/.cache/huggingface/stored_tokens Your token has been saved in your configured git credential helpers (osxkeychain). Your token has been saved to /Users/xia/.cache/huggingface/token Login successful. The current active token is: `live-xia`

5. 下载模型

css
代码解读
复制代码
huggingface-cli download --resume-download --token hf_这里填写上面的秘钥字符串 --local-dir-use-symlinks False stabilityai/stable-video-diffusion-img2vid-xt-1-1
  • --resume-download 支持断点续传
  • --token 秘钥
  • --local-dir-use-symlinks 是否使用本地软连接,设置为False
  • stabilityai/stable-video-diffusion-img2vid-xt-1-1 模型名称

/stabilityai…

image.png

默认 模型会下载到 huggingface 的缓存路径

javascript
代码解读
复制代码
~/.cache/huggingface/hub

可以看到我们下载的模型, 现在把模型移到 Comfyui 的 models/checkpoints 目录下即可

shell
代码解读
复制代码
> cd ~/.cache/huggingface/hub > hub % ls models--stabilityai--stable-video-diffusion-img2vid-xt-1-1 version.txt
bash
代码解读
复制代码
mv models--stabilityai--stable-video-diffusion-img2vid-xt-1-1 .xxxxx/comfyui/models/checkpoints

重启,则可以看到 下载的模型

image.png

models--stabilityai--stable-video-diffusion-img2vid-xt-1-1 是 图生视频的模型

现在看到,终端已经在下载模型中。

image.png

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多