microsoft / Cream

This is a collection of our NAS and Vision Transformer work.
MIT License
1.62k stars 220 forks source link

Minivit: change the image shape #158

Closed Twilighter9527 closed 1 year ago

Twilighter9527 commented 1 year ago

can the swin_tiny_patch4_window7_224_minivit handle the input image is 640*640? I want use it on the yolov5,but the input shape should be 640 640, I change the _C.DATA.IMG_SIZE = 640,it doesn't seem to work,shoud I change other configures? thanks! `from mini_swin.utils import parse_option from models import build_model from models import swin_transformer import torch import torch.nn as nn

if name == 'main': _, config = parse_option() model = build_model(config) x = torch.randn(3, 3, 640,640) y = model(x) y = 1`

/home/hugging/miniconda3/envs/torch110/lib/python3.8/site-packages/torch/functional.py:445: 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:2157.) return _VF.meshgrid(tensors, kwargs) # type: ignore[attr-defined] Traceback (most recent call last): File "/mnt/e/mm/demo/main.py", line 11, in y = model(x) File "/home/hugging/miniconda3/envs/torch110/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, *kwargs) File "/mnt/e/mm/demo/models/swin_transformer_minivit_distill.py", line 627, in forward x, qkv_tuple_return_list, hidden_tuple_return_list = self.forward_features(x, layer_id_list, is_hidden_org=is_hidden_rel) File "/mnt/e/mm/demo/models/swin_transformer_minivit_distill.py", line 609, in forward_features x, qkv_tuple_list, hidden_tuple_list = layer(x) File "/home/hugging/miniconda3/envs/torch110/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(input, kwargs) File "/mnt/e/mm/demo/models/swin_transformer_minivit_distill.py", line 429, in forward x, qkv_tuple_list_tmp, hidden_tuple_list_tmp = blk(x) File "/home/hugging/miniconda3/envs/torch110/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, *kwargs) File "/mnt/e/mm/demo/models/swin_transformer_minivit_distill.py", line 296, in forward x, qkv_tuple = self.forward_feature(x, init_window_shift, index) File "/mnt/e/mm/demo/models/swin_transformer_minivit_distill.py", line 257, in forward_feature x_windows = window_partition(shifted_x, self.window_size) # nWB, window_size, window_size, C File "/mnt/e/mm/demo/models/swin_transformer_minivit.py", line 37, in window_partition x = x.view(B, H // window_size, window_size, W // window_size, window_size, C) RuntimeError: shape '[3, 22, 7, 22, 7, 96]' is invalid for input of size 7372800

Process finished with exit code 1