KaggleHub Library

1.0.0 · active · verified Sat Apr 11

KaggleHub is a Python library that provides a unified interface to programmatically access and download Kaggle resources, primarily models and datasets, outside of the Kaggle platform. It aims to standardize resource paths and simplify integration with other ML frameworks. The current version is 1.0.0, and the library has a frequent release cadence, with minor versions often released every few weeks.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to download a pre-trained model using `kagglehub.model_download()`. Replace the `model_handle` with the desired model's identifier. For authentication, ensure your Kaggle API credentials (username and key) are set as environment variables (`KAGGLE_USERNAME`, `KAGGLE_KEY`) or available in a `~/.kaggle/kaggle.json` file.

import os
from kagglehub import model_download

# Ensure KAGGLE_USERNAME and KAGGLE_KEY environment variables are set
# or a kaggle.json file exists in ~/.kaggle/

# Example: Download a specific version of a model
model_handle = 'google/vit/tensorflow/vit-base-patch16-224-fe/2'
model_path = model_download(model_handle)

print(f"Downloaded model path: {model_path}")

# To run this, you need to have Kaggle API credentials configured.
# For local testing, ensure your `KAGGLE_USERNAME` and `KAGGLE_KEY`
# environment variables are set or a `kaggle.json` file is present.

view raw JSON →