Pangoraw / PaDiM

:dolphin: Re-implementation of PaDiM and code for the article "Weakly Supervised Detection of Marine Animals in High Resolution Aerial Images"
https://arxiv.org/abs/2011.08785
MIT License
27 stars 4 forks source link

Other Image sizes for the Model #2

Closed SDJustus closed 3 years ago

SDJustus commented 3 years ago

Hi there,

first of all, thanks for your awesome work. It is very nice to be able to use more than like 500 images to run the model. :)

Now the question.. What and how do i have to change, if i want to run the model with another image size than 418x418 (from semmacape for example). I think i have to adjust the num_embeddings but i am not sure how to determine the correct size.

If I run the code with 256x256 i get the following error:

File "./padim/padim.py", line 45, in train_one_batch
    (-1, self.num_embeddings, self.num_patches))  # b * c * (w * h)
RuntimeError: shape '[-1, 100, 10816]' is invalid for input of size 13107200

I ran python examples/main.py for this

Would be really cool, if you could help me!

Best regards

SDJustus commented 3 years ago

this is the line failing btw: embeddings = embeddings.reshape((-1, self.num_embeddings, self.num_patches)) # b * c * (w * h)

Pangoraw commented 3 years ago

Hi! This is something that I wanted to do for a long time, but since all my images are 416x416 I never took the time to do it. You can try something like in https://github.com/Pangoraw/PaDiM/commit/8c434e2872088a711fbba94f34bd422223099883 with the flag --size 256x256. I will merge in main when I am sure that model serialization is not broken ;)

SDJustus commented 3 years ago

Thank you very much for the quick answer/solution! Will test it today. Closing this issue for now :)