TomerRonen34 / mixed-resolution-vit

48 stars 2 forks source link

Error when using min_patch_size=4 #5

Closed Walid-Ahmed closed 1 year ago

Walid-Ahmed commented 1 year ago

Hi, thanks for this great work.

I am trying to use the following parameters for Tokenization : image_size = 224 min_patch_size = 4 max_patch_size = 8 quadtree_num_patches = 2002

I am getting the following error when using FeatureBasedPatchScorer: /examples/mixed_res/patch_scorers/patch_scorer.py", line 82, in _calculate_scores raise ValueError( ValueError: map_size (7) < grid_size (28)

If I use RandomPatchScorer(), it works fine Can you please help me understand and reslove this error?

Thanks in advance

TomerRonen34 commented 1 year ago

This error is due to the patch scorer features being a factor of x32 smaller than the image, while you require them to be x8 smaller than the image in order to rank patches of size 8x8 pixels. You can try taking a shallower level of the CNN inside the FeatureBased patch scorer (after 3 downsamples instead of after 5 downsamples which is the default). Another option is to use the PixelBlur patch scorer without any code changes, although I only recommend it for playground testing, as it's far less semantically strong than the FeatureBased scorer.

On Sun, Sep 17, 2023 at 5:10 AM Walid Ahmed @.***> wrote:

Hi, thanks for this great work.

I am trying to use the following parameters for Tokenization: image_size = 224 min_patch_size = 4 max_patch_size = 8 quadtree_num_patches = 2002

I am getting the following error: /examples/mixed_res/patch_scorers/patch_scorer.py", line 82, in _calculate_scores raise ValueError( ValueError: map_size (7) < grid_size (28)

Can you please help me understand and reslove this error?

Thanks in advance

— Reply to this email directly, view it on GitHub https://github.com/TomerRonen34/mixed-resolution-vit/issues/5, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJEJEULSJDN35OVNIL25OYLX2ZLYHANCNFSM6AAAAAA43JCHRA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Walid-Ahmed commented 1 year ago

Thanks a lot I followed your advice and code is working now

TomerRonen34 commented 1 year ago

That's great to hear :) I hope it works well

On Sun, 17 Sept 2023, 22:56 Walid Ahmed, @.***> wrote:

Thanks a lot I followed your advice and code is working now

— Reply to this email directly, view it on GitHub https://github.com/TomerRonen34/mixed-resolution-vit/issues/5#issuecomment-1722554961, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJEJEUIN5G2KOWV5DGX5T5LX25IW5ANCNFSM6AAAAAA43JCHRA . You are receiving this because you commented.Message ID: @.***>