Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import the latest swin transformer #6557

Closed
NUS-Tim opened this issue Sep 10, 2022 · 2 comments
Closed

Cannot import the latest swin transformer #6557

NUS-Tim opened this issue Sep 10, 2022 · 2 comments

Comments

@NUS-Tim
Copy link

NUS-Tim commented Sep 10, 2022

🐛 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
@abhi-glitchhg
Copy link
Contributor

abhi-glitchhg commented Sep 10, 2022

Hey @NUS-Tim , I think to use swin transformer v2, you will have to install a nightly build.

I am pretty sure that 0.13.0 does not have Swin V2 models available, and I also can't find it in the release notes for the 0.13.1 version.
Edit: Just confirmed this, Swin V2 is not available in V0.13.1, PR for the SwinV2 was merged later and you can find that here

To install the nightly version, you can follow the PyTorch website, I recommend doing this in a separate environment. (had a quick look at your current environment, and I think conda install pytorch torchvision cudatoolkit=11.3 -c pytorch-nightly command would work for you)

lmk if this resolves the issue :)

@NUS-Tim
Copy link
Author

NUS-Tim commented Sep 12, 2022

Hi @abhi-glitchhg, sorry for the late reply, I just go back to my lab. I just checked your solution and it works, thanks for your useful and fast reply!

@NUS-Tim NUS-Tim closed this as completed Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants