0


通过git clone批量下载huggingface模型和数据集

目录


前言

想要下载huggingface的模型,却发现只能一个个文件下载非常不方便,又或者官方提供的api不好用或者下载不下来,这里提供一个通过git clone一次性下载整个数据集/模型下来的高效方法。


一、配置git全局代理【可选】

1.配置http或socks5代理

如果不使用代理clone非常慢,可以选择先配置git全局代理。在bash或者cmd中输入如下命令:

git config --global http.proxy 'http://127.0.0.1:此处换成http端口号'git config --global https.proxy 'https://127.0.0.1:此处换成https端口号'
git config --global http.proxy 'socks5://127.0.0.1:此处换成socks5端口号'git config --global https.proxy 'socks5://127.0.0.1:此处换成socks5端口号'

或在用户目录下的

.gitconfig

文件末尾加上:

[http]
 
proxy = socks5://127.0.0.1:此处换成socks5端口号
proxy = http://127.0.0.1:此处换成http端口号
 
[https]
 
proxy = socks5://127.0.0.1:此处换成socks5端口号
proxy = https://127.0.0.1:此处换成http端口号

2.取消代理配置

git config --global--unset http.proxy
git config --global--unset https.proxy

或删掉用户目录下

.gitconfig

文件里

[http]

[https]

后面的内容。

二、下载步骤

**1. 进入到你要下载的数据集(Dataset card)或模型(Model card)的

Files

目录下,然后从地址栏中复制url,如下图所示:**
在这里插入图片描述

2. bash或cmd中输入如下命令:

git clone '第1步中复制的url,将末尾的/tree/main换成.git'

如果所需要下载的文件较大,则需要使用git-lfs下载(安装及使用方法):

git lfs clone '第1步中复制的url,将末尾的/tree/main换成.git'

注意: 如果需要切换分支,同样只需要使用

git

-b

参数下载对应的分支即可。

3. 等待clone完成
如果clone中断,恢复clone可以尝试如下命令:

git checkout branchname -- .

问题

在第一次clone的时候遇到了git LFS错误,不确定原因,顺便记录一下解决过程,错误如下:

error: external filter 'git-lfs filter-process' failed
fatal: xxxxxxxxx: smudge filter lfs failed
warning: Clone succeeded, but checkout failed.

解决方法: Kerwen Blog


本文转载自: https://blog.csdn.net/weixin_44034841/article/details/131862553
版权归原作者 机智的枫树 所有, 如有侵权,请联系我们删除。

“通过git clone批量下载huggingface模型和数据集”的评论:

还没有评论