XPixelGroup / RethinkVSRAlignment

(NIPS 2022) Rethinking Alignment in Video Super-Resolution Transformers
112 stars 10 forks source link

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

Open laulampaul opened 1 year ago

laulampaul commented 1 year ago

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) # BnW, WdWhWw, 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 commented 1 year ago

Can you provide more information of your running conditions?

laulampaul commented 1 year ago

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

Shuweis commented 1 year ago

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

laulampaul commented 1 year ago

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 commented 1 year ago

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

DachunKai commented 2 months ago

Meet the same problem. How to solve it?

Desertstudentltsx commented 2 months ago

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