Skip to content

Cannot import the latest swin transformer #6557

Closed
@NUS-Tim

Description

@NUS-Tim

🐛 Describe the bug

I'm trying to import swin transformer v2 as described below:

import torchvision
from torchvision import models

swin_transformer_v2 = models.swin_v2_s(weights='IMAGENET1K_V1')

However, the import failed with an error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [10], in <cell line: 1>()
----> 1 swin_transformer_v2 = models.swin_v2_s(weights='IMAGENET1K_V1')

AttributeError: module 'torchvision.models' has no attribute 'swin_v2_s'

It is weird as I can successfully do this for the swin transformer v1:

swin_transformer = models.swin_t(weights='IMAGENET1K_V1')

Should anyone has any suggestions, pls let me know. Thanks all in advance!

Versions

Collecting environment information...
PyTorch version: 1.12.1+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Microsoft Windows 10 Pro
GCC version: Could not collect
Clang version: Could not collect
CMake version: Could not collect
Libc version: N/A

Python version: 3.8.13 (default, Mar 28 2022, 06:59:08) [MSC v.1916 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-10-10.0.19043-SP0
Is CUDA available: False
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.22.3
[pip3] torch==1.12.1
[pip3] torchaudio==0.12.0
[pip3] torchsummary==1.5.1
[pip3] torchvision==0.13.1
[conda] blas                      1.0                         mkl  
[conda] cudatoolkit               11.3.1               h59b6b97_2  
[conda] mkl                       2021.4.0           haa95532_640  
[conda] mkl-service               2.4.0            py38h2bbff1b_0  
[conda] mkl_fft                   1.3.1            py38h277e83a_0  
[conda] mkl_random                1.2.2            py38hf11a4ad_0  
[conda] numpy                     1.22.3           py38h7a0a035_0  
[conda] numpy-base                1.22.3           py38hca35cd5_0  
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] torch                     1.12.1                   pypi_0    pypi
[conda] torchaudio                0.12.0               py38_cu113    pytorch
[conda] torchsummary              1.5.1                    pypi_0    pypi
[conda] torchvision               0.13.0                   pypi_0    pypi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions