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

Simplify Noise2Void #307

Open
jdeschamps opened this issue Dec 6, 2024 · 0 comments
Open

Simplify Noise2Void #307

jdeschamps opened this issue Dec 6, 2024 · 0 comments
Labels
refactoring Streamline and improve source code
Milestone

Comments

@jdeschamps
Copy link
Member

Description

N2VManipulate as a transform makes everything complicated, including a lot of constraints on the Pydantic models and the potential for users to miss-configure their training, in particular in the Lightning API.

In addition, this transform returns a different number of objects has it returns also the original patch. The reason for that is the current implementation of the loss.

Overall, N2V requires many additional checks throughout the code.

Which part of the code?

Examples of N2V checks:

if SupportedTransform.N2V_MANIPULATE in transform_list:

N2V loss:

errors = (original_patches - manipulated_patches) ** 2

Potential solutions

Simplify transform

In N2VManipulate:

return patch * mask

Simplify loss

In n2v_loss, simply pass target:

mask = (target != 0).float()
errors = (target - manipulated_patches) ** 2
loss = torch.sum(errors * mask) / torch.sum(mask)

N2VModule as a subclass of UNetModule

N2VModule as a subclass of UNetModule would allow injecting the N2VManipulate transform. We would need to see how to instantiate it properly based on the configuration.

This would also simplify using N2V in the Lightning API, which is one way users have told us they intend to use N2V.

@jdeschamps jdeschamps added the refactoring Streamline and improve source code label Dec 6, 2024
@jdeschamps jdeschamps added this to the v0.2.0 milestone Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Streamline and improve source code
Projects
None yet
Development

No branches or pull requests

1 participant