Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add padding while evaluating on the original mask size #261

Open
blumenstiel opened this issue Nov 26, 2024 · 8 comments · May be fixed by #342
Open

Add padding while evaluating on the original mask size #261

blumenstiel opened this issue Nov 26, 2024 · 8 comments · May be fixed by #342
Assignees

Comments

@blumenstiel
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
Some model have a specific patch size which only allow to run images with multiples of these sizes. E.g., a patch size of 14 and image size of 512 is not possible.

Describe the solution you'd like
A simple approach is to add padding (e.g. nearest or mirror padding) to increase the image size to e.. 518 (which is divisible by 14).
However, doing this using albumentation.PadIfNeeded would probably also increase the mask (not tested, just an assumption). The evaluation should be performed on the original 512 mask, not the 518 padded mask, as this would upsample the edge pixels. Therefore, TerraTorch needs to handle this in some way.

Describe alternatives you've considered (optional)
Alternatively, the padding is performed only on the images, and the mask is cropped afterwards to the original size. This could happened in the TerraTorch tasks.

@daniszw @paolo-fraccaro

@Joao-L-S-Almeida Joao-L-S-Almeida self-assigned this Nov 26, 2024
@singam96
Copy link
Contributor

This is currently possible

backbone = timm.create_model(model_name, pretrained=False, features_only=True, num_frames=NUM_FRAMES, out_indices=out_indices, padding='constant')

We can use padding modes from https://pytorch.org/vision/main/generated/torchvision.transforms.Pad.html

@paolofraccaro
Copy link
Collaborator

But not all models are instantiated through timm right?

@romeokienzler
Copy link
Collaborator

@Joao-L-S-Almeida thinks this might be already solved by one of @blumenstiel 's PR's, let's test

@blumenstiel
Copy link
Collaborator Author

No, it's not working at the moment and IMHO it is a must have.

Some models support padding as pointed out earlier. But the important part is that the tasks only evaluate the original area (which is currently not implemented).

@Joao-L-S-Almeida
Copy link
Member

Joao-L-S-Almeida commented Dec 23, 2024 via email

@Joao-L-S-Almeida Joao-L-S-Almeida linked a pull request Dec 23, 2024 that will close this issue
@Joao-L-S-Almeida
Copy link
Member

It's being implemented in #342.

@romeokienzler
Copy link
Collaborator

@blumenstiel is it ok now?

@romeokienzler
Copy link
Collaborator

@blumenstiel lmc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants