更新时间:2024-04-11 GMT+08:00
分享

使用Gallery CLI配置工具下载文件

在服务器(ModelArts Lite云服务器或者是本地Windows/Linux等服务器)上登录Gallery CLI配置工具后,通过命令“gallery-cli download”可以从AI Gallery仓库下载资源。

命令说明

登录Gallery CLI配置工具后,使用命令“gallery-cli download --help”可以获取Gallery CLI配置工具下载文件的帮助信息。

gallery-cli download --help

获得命令“gallery-cli download”可用选项的完整列表如下所示。

Usage: gallery-cli download [OPTIONS] REPO_ID [FILENAMES]...

Download files from the AI Gallery

╭─ Arguments ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *    repo_id        TEXT            ID of the repo to download from (e.g. `username/repo-name`). [required]                   │
│      filenames      [FILENAMES]...  Files to download (e.g. `config.json`,`data/metadata.jsonl`).                             │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --include         TEXT  Glob patterns to match files to download.                                                             │
│ --exclude         TEXT  Glob patterns to exclude from files to download.                                                      │
│ --local-dir       TEXT  Specified local dir to store model or dataset                                                         │
│ --help                  Show this message and exit.                                                                           │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

准备工作

获取“repo_id”和待下载的文件名。

  • 获取“repo_id”
    在AI Gallery页面的资产详情页,单击复制完整的资产名称,如图1所示,获取到的信息即为“repo_id”。例如,复制出的信息为“ur5468675/test_cli_model1”,则该资产的“repo_id”为“ur5468675/test_cli_model1”。
    图1 复制完整资产名称

    如果资产详情页没有按钮,则表示该资产不支持使用Gallery CLI配置工具下载文件。

  • 获取待下载的文件名

    在AI Gallery页面的资产详情页,如果是模型资产,则选择“模型文件”页签,如果是数据集资产,则选择“文件版本”页签,获取“文件名称”

下载单个文件

在服务器执行如下命令,可以从AI Gallery仓库下载单个文件到服务器的缓存目录下。

gallery-cli download {repo_id} {文件名}

如下所示,表示下载文件“config.json”到服务器的缓存目录“/test”下,当回显“100%”时表示下载完成。

gallery-cli download ur5468675/test_cli_model1 config.json

Download config.json: 100%|############################################################################| 665/665 [00:00<?, ?B/s]

/test/ur5468675--test_cli_model1/config.json

下载多个文件

  • 根据文件名下载文件

    在服务器执行如下命令,将待下载的文件名枚举出来即可从AI Gallery仓库依次下载多个文件到云服务器的缓存目录下。

    gallery-cli download {repo_id} {文件名} {文件名}

    其中,“repo_id”如何获取,文件名如何获取。

    如下所示,表示下载文件“config.json”“merges.txt”到服务器的缓存目录“/test”下,当回显“100%”时表示下载完成。

    gallery-cli download ur5468675/test_cli_model1 config.json merges.txt
    
    Download 1/2 config.json: 100%|#################################################################| 665/665 [00:00<?, ?B/s]
    Download 2/2 merges.txt: 100%|##################################################################| 456k/456k [00:00<00:00, 2.13MB/s]
    
    /test/ur5468675--test_cli_model1
  • 通过include下载文件

    在服务器执行如下命令,通过“--include”从AI Gallery仓库依次下载包含某种格式的文件到云服务器的缓存目录下。

    gallery-cli download {repo_id} --include "*.json"

    如下所示,表示下载所有“.json”格式的文件到服务器的缓存目录“/test”下,当回显“100%”时表示下载完成。

    gallery-cli download ur5468675/test_cli_model1 --include "*.json"
    
    Download 1/4 config.json: 100%|###############################################################| 665/665 [00:00<?, ?B/s]
    Download 2/4 generation_config.json: 100%|####################################################| 124/124 [00:00<?, ?B/s]
    Download 3/4 tokenizer.json: 100%|############################################################| 1.36M/1.36M [00:00<00:00, 5.54MB/s]
    Download 4/4 vocab.json: 100%|################################################################| 1.04M/1.04M [00:00<00:00, 4.10MB/s]
    
    /test/ur5468675--test_cli_model1
  • 通过exclude下载文件

    在服务器执行如下命令,通过“--exclude”从AI Gallery仓库依次下载除某种格式之外的其他格式的文件到服务器的缓存目录下。

    gallery-cli download {repo_id} --exclude "*.json"

    如下所示,表示下载除“.json”格式之外的其他格式的文件到服务器的缓存目录“/test”下,当回显“100%”时表示下载完成。

    gallery-cli download ur5468675/test_cli_model1 --exclude "*.json"
    
    Download 1/2 merges.txt: 100%|##################################################################| 456k/456k [00:00<00:00, 2.78MB/s]
    Download 2/2 model.safetensors: 100%|###########################################################| 548M/548M [00:13<00:00, 41.8MB/s]
    
    /test/ur5468675--test_cli_model1

下载文件到指定路径

在服务器执行如下命令,可以从AI Gallery仓库下载单个文件到服务器的指定路径下。

gallery-cli download {repo_id} {文件名} --local-dir={存放路径}

如下所示,表示下载文件“config.json”到服务器的“/tmp”路径下,当回显“100%”时表示下载完成。

gallery-cli download ur5468675/test_cli_model1 config.json --local-dir=/tmp

Download config.json: 100%|############################################################| 665/665 [00:00<?, ?B/s] 

/tmp/config.json

下载单个AI Gallery仓库

在服务器执行如下命令,可以将AI Gallery仓库的所有文件下载到服务器的缓存目录下。

gallery-cli download {repo_id}

如下所示,表示下载AI Gallery仓库“test_cli_model1”到服务器的缓存目录“/test”下,当回显“100%”时表示下载完成。

gallery-cli download ur5468675/test_cli_model1

Download 1/6 config.json: 100%|##############################################################| 665/665 [00:00<?, ?B/s]
Download 2/6 generation_config.json: 100%|###################################################| 124/124 [00:00<?, ?B/s]
Download 3/6 merges.txt: 100%|###############################################################| 456k/456k [00:00<00:00, 2.69MB/s]
Download 4/6 model.safetensors: 100%|########################################################| 548M/548M [00:17<00:00, 32.0MB/s]
Download 5/6 tokenizer.json: 100%|###########################################################| 1.36M/1.36M [00:00<00:00, 4.88MB/s]
Download 6/6 vocab.json: 100%|###############################################################| 1.04M/1.04M [00:00<00:00, 4.43MB/s]

/test/ur5468675--test_cli_model1
分享:

    相关文档

    相关产品