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

A question about the PSRT-Sliding model in psrt_sliding_arch.py #3

Open
laulampaul opened this issue Oct 10, 2022 · 7 comments
Open

Comments

@laulampaul
Copy link

When I run the code [psrt_sliding_arch.py] , I face one bug

Traceback (most recent call last):
File "model.py", line 969, in
x = model(x)
File "/home/ma-user/anaconda3/envs/PyTorch-1.8/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "model.py", line 859, in forward
feats = self.forward_features(x)
File "model.py", line 833, in forward_features
x = layer(x.contiguous(), x_size , attn_mask)
File "/home/ma-user/anaconda3/envs/PyTorch-1.8/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "model.py", line 502, in forward
x = self.residual_group(x, x_size,attn_mask)
File "/home/ma-user/anaconda3/envs/PyTorch-1.8/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "model.py", line 401, in forward
x = blk(x, x_size,attn_mask)
File "/home/ma-user/anaconda3/envs/PyTorch-1.8/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "model.py", line 287, in forward
attn_windows = attn_windows.view(-1, *(self.window_size + [c,]))
TypeError: can only concatenate tuple (not "list") to tuple

And I try to change
attn_windows = attn_windows.view(-1, *(self.window_size + [c,]))
to
attn_windows = attn_windows.view(-1, self.window_size[0], self.window_size[1],self.window_size[2],c)

And face a new bug

(PyTorch-1.8) [ma-user rethinking]$python model.py
/home/ma-user/anaconda3/envs/PyTorch-1.8/lib/python3.7/site-packages/requests/init.py:104: RequestsDependencyWarning: urllib3 (1.26.12) or chardet (5.0.0)/charset_normalizer (2.0.12) doesn't match a supported version!
RequestsDependencyWarning)
/home/ma-user/anaconda3/envs/PyTorch-1.8/lib/python3.7/site-packages/torch/functional.py:478: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:2895.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
Traceback (most recent call last):
File "model.py", line 969, in
x = model(x)
File "/home/ma-user/anaconda3/envs/PyTorch-1.8/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "model.py", line 859, in forward
feats = self.forward_features(x)
File "model.py", line 833, in forward_features
x = layer(x.contiguous(), x_size , attn_mask)
File "/home/ma-user/anaconda3/envs/PyTorch-1.8/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(input, **kwargs)
File "model.py", line 502, in forward
x = self.residual_group(x, x_size,attn_mask)
File "/home/ma-user/anaconda3/envs/PyTorch-1.8/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(input, **kwargs)
File "model.py", line 401, in forward
x = blk(x, x_size,attn_mask)
File "/home/ma-user/anaconda3/envs/PyTorch-1.8/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(input, **kwargs)
File "model.py", line 281, in forward
attn_windows = self.attn(x_windows, mask=attn_mask) # B
nW, Wd
Wh
Ww, C
File "/home/ma-user/anaconda3/envs/PyTorch-1.8/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in call_impl
return forward_call(*input, **kwargs)
File "model.py", line 162, in forward
attn = attn.view(B
// nW, nW, self.num_heads, N, N) + mask.unsqueeze(1).unsqueeze(0)
RuntimeError: shape '[1, 2178, 6, 128, 128]' is invalid for input of size 321159168

How can I solve it ??

@Shuweis
Copy link
Member

Shuweis commented Oct 31, 2022

Can you provide more information of your running conditions?

@laulampaul
Copy link
Author

python== 3.8.8
pytorch==1.9.0
torchvision==0.9.0

@Shuweis
Copy link
Member

Shuweis commented Nov 2, 2022

I mean how do you run the psrt_sliding_arch.py? Your input size or other information

@laulampaul
Copy link
Author

just use the code in psrt_sliding_arch.py

if name == 'main':
upscale = 4
window_size = (2, 8, 8)
height = (1024 // upscale // window_size[1] + 1) * window_size[1]
width = (1024 // upscale // window_size[2] + 1) * window_size[2]

model = SwinIRFM(
    img_size=height,
    patch_size=1,
    in_chans=3,
    embed_dim=96,
    depths=(6, 6, 6, 6),
    num_heads=(6, 6, 6, 6),
    window_size=window_size,
    mlp_ratio=2,
    qkv_bias=True,
    qk_scale=None,
    drop_rate=0.,
    attn_drop_rate=0.,
    drop_path_rate=0.1,
    norm_layer=nn.LayerNorm,
    ape=False,
    patch_norm=True,
    use_checkpoint=False,
    upscale=2,
    img_range=1.,
    upsampler='pixelshuffle',
)

print(model)
#print(height, width, model.flops() / 1e9)

x = torch.randn((1, 5, 3, height, width))
x = model(x)
print(x.shape)

@chenzean
Copy link

chenzean commented Jul 1, 2023

I also show this problem:
TypeError: can only concatenate tuple (not "int") to tuple.
How can I solve it?

@DachunKai
Copy link

Meet the same problem. How to solve it?

@Desertstudentltsx
Copy link

I also meet the question, what can I do??

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

5 participants