LinuxCommandLibrary

kaggle-models

Download and manage Kaggle models

TLDR

Get a model

$ kaggle [[m|models]] get "[model_name]"
copy

List all models
$ kaggle [[m|models]] list
copy

Initialize metadata file for model creation
$ kaggle [[m|models]] init
copy

Create a new model
$ kaggle [[m|models]] create
copy

Delete a model
$ kaggle [[m|models]] delete "[model_name]"
copy

Update a model
$ kaggle [[m|models]] update
copy

SYNOPSIS

kaggle-models <action> [<model-path>] [<options>]

PARAMETERS

-h, --help
    Display help message and exit

--public
    Show only public models (for list)

--private
    Show only private models (for list)

--organization <ORG>, -o <ORG>
    Filter models by organization (for list)

-p <PAGE_SIZE>, --page-size <PAGE_SIZE>
    Models per page (default 20, for list)

-m <MAX_PAGE>, --max-page <MAX_PAGE>
    Max pages to fetch (for list)

--path <PATH>, -p <PATH>
    Download/upload directory

--dir <DIR>
    Model directory path (for create, version-create)

--message <MSG>
    Version commit message (for version-create)

-q, --quiet
    Suppress output

-v, --verbose
    Enable verbose logging

--retry <COUNT>
    Retry failed requests

DESCRIPTION

The kaggle-models command is a powerful Linux CLI tool from the Kaggle API suite, enabling seamless management of machine learning models hosted on the Kaggle Model Hub. Users can discover, download, create, version, and monitor models directly from the terminal, streamlining workflows for data scientists, ML engineers, and teams.

Core actions include listing models with filters (list), downloading pre-trained models like tensorflow/resnet50 (download), creating new model repos (create), checking upload status (status), and pushing versions (version-create). Pagination, organization filters, and custom paths enhance usability for large-scale operations.

Installation requires Python's pip: pip install kaggle. Authentication involves downloading kaggle.json from Kaggle settings and securing it at ~/.kaggle/kaggle.json with chmod 600. This tool integrates well with CI/CD pipelines, Jupyter, and scripts, reducing reliance on the web UI.

By leveraging Kaggle's community-driven models, kaggle-models accelerates prototyping and deployment, supporting formats like TensorFlow SavedModels, PyTorch, and ONNX.

CAVEATS

Requires valid Kaggle API token; large models (multi-GB) need ample disk space and bandwidth. Private models demand ownership/access rights. Rate limits apply to API calls.

INSTALLATION & SETUP

pip install kaggle
Download kaggle.json from Kaggle > Account > API.
mkdir -p ~/.kaggle && mv kaggle.json ~/.kaggle/ && chmod 600 ~/.kaggle/kaggle.json

EXAMPLE USAGE

kaggle-models list --public --page-size 10
kaggle-models download microsoft/resnet-50 --path ./models
kaggle-models create ./my-model --public

HISTORY

Added to Kaggle CLI (v1.6.12+) in December 2022 with Model Hub launch, evolving from datasets/competitions tools to support growing demand for shareable ML artifacts amid federated learning trends.

SEE ALSO

kaggle(1), curl(1), wget(1), git(1)

Copied to clipboard