-
Notifications
You must be signed in to change notification settings - Fork 6
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
Enforce specific tile size in UNet to reduce artifacts #121
Conversation
Translational invariance is broken in UNets, due to the pooling layers. To avoid artefacts in during prediction, `tile_size` are now forced to be a multiple of 2**depth. This does not impact the "Lightning API", and can be an issue for small Z depth during prediction. In such a case, padding can be added or using prediction while by passing the CAREamist.
Is it possible for Pydantic to validate a field based on another field? If so, the tile size could be validated directly in the |
Yes Pydantic supports the validation between fields, but unfortunately the The problem I faced here is that the DL-model configuration lives in a different Pydantic class than the tiling... So two choices:
I agree the second one is more elegant, but I think it is not compatible with the so-called "Lightning API", where people might be using the A middle ground would be to minimize the number of fields, maybe something like: class InferenceModel(BaseModel):
...
unet_depth: Optional[int] = None
... That is a bit odd, but at least a single parameter that can be left In the end, I still prefer the first solution because it does not have a strange parameter added to the |
My bad, I did know that and I think I just read through the code too quickly. Still getting used to Pydantic! This all makes sense then! Thank you for the detailed explanation. I agree that having the |
Description
Pooling layers in the UNet break the translation invariance, which can lead to artifacts during tile prediction if the tiles have the wrong size. This PR adds a check for tile size different than k*2**depth, to insure artifact free prediction.
Changes Made
Additional Notes and Examples
Two important consequences arise:
PredictDataWrapper