From cc7a2f9b28468e2d0d5dee682ce08c144b280a24 Mon Sep 17 00:00:00 2001 From: HubHop Date: Thu, 13 Oct 2022 13:48:04 +1100 Subject: [PATCH] update code for the latest timm --- .gitignore | 1 + README.md | 7 +++++-- classification/data/build.py | 5 ++++- classification/lr_scheduler.py | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 6f0080a..85d50c3 100644 --- a/.gitignore +++ b/.gitignore @@ -134,6 +134,7 @@ figures/* plots/* .idea/* checkpoints/ +output/* *.out *.err .vscode/ diff --git a/README.md b/README.md index a87f90f..2f930c0 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ By [Zizheng Pan](https://scholar.google.com.au/citations?user=w_VMopoAAAAJ&hl=en ## News +- **13/10/2022.** Fix compatibility with higher version of timm. + - **30/09/2022.** Add [benchmarking results](https://github.com/ziplab/LITv2#single-attention-layer-benchmark) for single attention layer. HiLo is super fast on both CPU and GPU! - **15/09/2022.** LITv2 is accepted by NeurIPS 2022! 🔥🔥🔥 @@ -55,7 +57,8 @@ torch.Size([64, 196, 384]) ### Requirements - Linux with Python ≥ 3.6 -- PyTorch 1.8.1 +- PyTorch >= 1.8.1 +- timm >= 0.3.2 - CUDA 11.1 - An NVIDIA GPU @@ -70,7 +73,7 @@ conda activate lit # Install Pytorch and TorchVision pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html -pip install timm==0.3.2 +pip install timm pip install ninja pip install tensorboard diff --git a/classification/data/build.py b/classification/data/build.py index e2574fa..3da141e 100644 --- a/classification/data/build.py +++ b/classification/data/build.py @@ -6,7 +6,10 @@ from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD from timm.data import Mixup from timm.data import create_transform -from timm.data.transforms import _pil_interp +try: + from timm.data.transforms import _pil_interp +except: + from timm.data.transforms import str_to_pil_interp as _pil_interp from .cached_image_folder import CachedImageFolder from .samplers import SubsetRandomSampler diff --git a/classification/lr_scheduler.py b/classification/lr_scheduler.py index 2513935..cccfd43 100644 --- a/classification/lr_scheduler.py +++ b/classification/lr_scheduler.py @@ -14,7 +14,7 @@ def build_scheduler(config, optimizer, n_iter_per_epoch): lr_scheduler = CosineLRScheduler( optimizer, t_initial=num_steps, - t_mul=1., + # t_mul=1., lr_min=config.TRAIN.MIN_LR, warmup_lr_init=config.TRAIN.WARMUP_LR, warmup_t=warmup_steps,