timm documentation

Installation

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v1.0.11).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Installation

Before you start, you’ll need to setup your environment and install the appropriate packages. timm is tested on Python 3+.

Virtual Environment

You should install timm in a virtual environment to keep things tidy and avoid dependency conflicts.

  1. Create and navigate to your project directory:

    mkdir ~/my-project
    cd ~/my-project
  2. Start a virtual environment inside your directory:

    python -m venv .env
  3. Activate and deactivate the virtual environment with the following commands:

    # Activate the virtual environment
    source .env/bin/activate
    
    # Deactivate the virtual environment
    source .env/bin/deactivate

Once you’ve created your virtual environment, you can install timm in it.

Using pip

The most straightforward way to install timm is with pip:

pip install timm

Alternatively, you can install timm from GitHub directly to get the latest, bleeding-edge version:

pip install git+https://github.com/rwightman/pytorch-image-models.git

Run the following command to check if timm has been properly installed:

python -c "from timm import list_models; print(list_models(pretrained=True)[:5])"

This command lists the first five pretrained models available in timm (which are sorted alphebetically). You should see the following output:

['adv_inception_v3', 'bat_resnext26ts', 'beit_base_patch16_224', 'beit_base_patch16_224_in22k', 'beit_base_patch16_384']

From Source

Building timm from source lets you make changes to the code base. To install from the source, clone the repository and install with the following commands:

git clone https://github.com/rwightman/pytorch-image-models.git
cd pytorch-image-models
pip install -e .

Again, you can check if timm was properly installed with the following command:

python -c "from timm import list_models; print(list_models(pretrained=True)[:5])"
< > Update on GitHub