question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How we can set window image size on 112x112 image

See original GitHub issue

Hi

Thank you for your great work. My Image size is 112x112 and the head is 12 and my window size is 7. It does not work for me.

Traceback

  File "/raid/khawar/PycharmProjects/thesis/vit_pytorch/SwinT/swin.py", line 111, in forward
    q, k, v = map(
  File "/raid/khawar/PycharmProjects/thesis/vit_pytorch/SwinT/swin.py", line 112, in <lambda>
    lambda t: rearrange(t, 'b (nw_h w_h) (nw_w w_w) (h d) -> b h (nw_h nw_w) (w_h w_w) d',
  File "/raid/khawar/anaconda3/envs/vision-transformer-pytorch/lib/python3.8/site-packages/einops/einops.py", line 424, in rearrange
    return reduce(tensor, pattern, reduction='rearrange', **axes_lengths)
  File "/raid/khawar/anaconda3/envs/vision-transformer-pytorch/lib/python3.8/site-packages/einops/einops.py", line 376, in reduce
    raise EinopsError(message + '\n {}'.format(e))
einops.EinopsError:  Error while processing rearrange-reduction pattern "b (nw_h w_h) (nw_w w_w) (h d) -> b h (nw_h nw_w) (w_h w_w) d".
 Input tensor shape: torch.Size([1, 3, 3, 384]). Additional info: {'h': 24, 'w_h': 7, 'w_w': 7}.
 Shape mismatch, can't divide axis of length 3 in chunks of 7

Regards, Khawar

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ancientmoonercommented, Aug 12, 2021

Hi

Thank you for your great work. My Image size is 112x112 and the head is 12 and my window size is 7. It does not work for me.

Traceback

  File "/raid/khawar/PycharmProjects/thesis/vit_pytorch/SwinT/swin.py", line 111, in forward
    q, k, v = map(
  File "/raid/khawar/PycharmProjects/thesis/vit_pytorch/SwinT/swin.py", line 112, in <lambda>
    lambda t: rearrange(t, 'b (nw_h w_h) (nw_w w_w) (h d) -> b h (nw_h nw_w) (w_h w_w) d',
  File "/raid/khawar/anaconda3/envs/vision-transformer-pytorch/lib/python3.8/site-packages/einops/einops.py", line 424, in rearrange
    return reduce(tensor, pattern, reduction='rearrange', **axes_lengths)
  File "/raid/khawar/anaconda3/envs/vision-transformer-pytorch/lib/python3.8/site-packages/einops/einops.py", line 376, in reduce
    raise EinopsError(message + '\n {}'.format(e))
einops.EinopsError:  Error while processing rearrange-reduction pattern "b (nw_h w_h) (nw_w w_w) (h d) -> b h (nw_h nw_w) (w_h w_w) d".
 Input tensor shape: torch.Size([1, 3, 3, 384]). Additional info: {'h': 24, 'w_h': 7, 'w_w': 7}.
 Shape mismatch, can't divide axis of length 3 in chunks of 7

Regards, Khawar

You may change the window size of the last stage as 3x3 or 4x4 (the feature map size). Another solution is to use padding.

0reactions
ancientmoonercommented, Dec 20, 2021

@scott870430 You can try bicubic interpolation to leverage the pretrained model weights with different window size

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resize an image on your Windows PC or Mac
Open the image you want to resize using the Photos app. · Click the ellipsis button on the menu bar at the top,...
Read more >
How to Resize an Image on Windows Using Built-in Apps
1. Double-click the image file you want to resize to open it in Photos. · 2. Once it's opened, click the three dots...
Read more >
How to Use the Windows 10 Photos App to Resize Images
Resize Images Windows 10 Photos App. To resize an image, open the Photos app and choose the picture from your library that you...
Read more >
4.2. Change the Size of an Image (Scale)
Problem: you have a huge image and you want to resize the is so that it will ... image, GIMP will set the...
Read more >
Resize PNG Online - Resizing.app
Use Resizing.app, Photoshop, or built-in options of your operating system to resize png images by width, height, by percentage, or set custom parameters....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found