### Install Dependencies Source: https://github.com/huggingface/pytorch-image-models/blob/main/hfdocs/README.md Install the necessary packages for building Hugging Face documentation and for code formatting. ```bash pip install git+https://github.com/huggingface/doc-builder.git@main#egg=hf-doc-builder pip install watchdog black ``` -------------------------------- ### Install huggingface_hub Source: https://github.com/huggingface/pytorch-image-models/blob/main/hfdocs/source/hf_hub.mdx Install the necessary package for Hugging Face Hub integration. ```bash pip install huggingface_hub ``` -------------------------------- ### Install timm using pip Source: https://github.com/huggingface/pytorch-image-models/blob/main/hfdocs/source/installation.mdx Install the timm library using pip for the most straightforward installation. ```bash pip install timm ``` -------------------------------- ### EfficientNet-B2 Training with RandAugment Source: https://github.com/huggingface/pytorch-image-models/blob/main/hfdocs/source/training_script.mdx Example training command for EfficientNet-B2 with RandAugment, optimized for dual Titan RTX cards with NVIDIA Apex installed. This configuration achieved 80.4% top-1 accuracy. ```bash ./distributed_train.sh 2 --data-dir /imagenet/ --model efficientnet_b2 -b 128 --sched step --epochs 450 --decay-epochs 2.4 --decay-rate .97 --opt rmsproptf --opt-eps .001 -j 8 --warmup-lr 1e-6 --weight-decay 1e-5 --drop 0.3 --drop-path 0.2 --model-ema --model-ema-decay 0.9999 --aa rand-m9-mstd0.5 --remode pixel --reprob 0.2 --amp --lr .016 ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/huggingface/pytorch-image-models/blob/main/CONTRIBUTING.md Installs the project's main dependencies and development/testing dependencies using pip. ```bash python -m pip install -r requirements.txt ``` ```bash python -m pip install -r requirements-dev.txt # for testing ``` ```bash python -m pip install -e . ``` -------------------------------- ### Load Pretrained Wide ResNet Model Source: https://github.com/huggingface/pytorch-image-models/blob/main/hfdocs/source/models/wide-resnet.mdx Loads a pretrained Wide ResNet model. Use this to quickly get started with image classification tasks. ```python >>> import timm >>> model = timm.create_model('wide_resnet101_2', pretrained=True) >>> model.eval() ``` -------------------------------- ### Create and navigate to project directory Source: https://github.com/huggingface/pytorch-image-models/blob/main/hfdocs/source/installation.mdx Use these commands to create a new project directory and navigate into it. ```bash mkdir ~/my-project cd ~/my-project ``` -------------------------------- ### Create Model with No Classifier and Pooling Source: https://github.com/huggingface/pytorch-image-models/blob/main/hfdocs/source/feature_extraction.mdx Instantiate a model directly without a classifier and global pooling by setting `num_classes=0` and `global_pool=''`. This is an efficient way to get unpooled features from the start. ```python import torch import timm m = timm.create_model('resnet50', pretrained=True, num_classes=0, global_pool='') o = m(torch.randn(2, 3, 224, 224)) print(f'Unpooled shape: {o.shape}') ```