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

HDN minimum example #396

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open

HDN minimum example #396

wants to merge 45 commits into from

Conversation

CatEek
Copy link
Contributor

@CatEek CatEek commented Feb 10, 2025

Description

Note

tldr:

MVE of HDN

Background - why do we need this PR?

Training HDN with careamist

Overview - what changed?

Changes Made

  • HDN relevant code in careamist.py
  • relevant config in hdn_algorithm_model.py
  • relevant changes in vae_algorithm_model.py
  • relevant changes in lvae_model.py
  • HDN configuration code in configuration_factory.py and relevant modules
  • HDN relevant code in lightning_module.py
  • HDN code in losses.py and loss factory
  • etc...

New features or files

Modified features or files

Removed features or files

How has this been tested?

Related Issues

  • Resolves #

Breaking changes

Additional Notes and Examples

--- BMZ doesn't work

Please ensure your PR meets the following requirements:

  • Code builds and passes tests locally, including doctests
  • New tests have been added (for bug fixes/features)
  • Pre-commit passes
  • PR to the documentation exists (for bug fixes / features)

@jdeschamps jdeschamps marked this pull request as draft February 10, 2025 15:02
@CatEek CatEek marked this pull request as ready for review February 11, 2025 16:52
Comment on lines 1032 to 1044
data_type: Literal["array", "tiff", "custom"],
axes: str,
patch_size: list[int],
batch_size: int,
num_epochs: int,
augmentations: Optional[list[Union[XYFlipModel, XYRandomRotate90Model]]] = None,
independent_channels: bool = True,
loss: Literal["mae", "mse"] = "mae",
n_channels_in: Optional[int] = None,
n_channels_out: Optional[int] = None,
logger: Literal["wandb", "tensorboard", "none"] = "none",
model_params: Optional[dict] = None,
dataloader_params: Optional[dict] = None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused parameters, should be passed to relevent configs.

Also this function needs more thought with how it will work with the _create_configuration function above that currently by default creates a UNet configuration.

Comment on lines 1084 to 1086
algorithm_params = create_algorithm_configuration()
data_params = create_data_configuration()
training_params = create_training_configuration()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions don't exist, I think you are looking for algorithm_factory, data_factory, and the training configuration is just implemented by initialising the TrainingConfig class directly since there is only one type.

"""
return [
"restoration",
"UNet",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove UNet tag

from .transformations.n2v_manipulate_model import (
N2VManipulateModel,
)
from .vae_algorithm_model import VAEAlgorithmConfig
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from .vae_algorithm_model import VAEAlgorithmConfig
from algorithms.vae_algorithm_model import VAEAlgorithmConfig

Comment on lines +15 to +16
from .data_model import DataConfig
from .fcn_algorithm_model import FCNAlgorithmConfig
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unresolved imports?

Comment on lines 195 to +198
if summary.status == "failed":
raise ValueError(f"Model description test failed: {summary}")
# raise ValueError(f"Model description test failed: {summary}")
print("I don't give a flying fuck!")
# TODO BMZ expect just one output but our VAE outputs a whole stack of things
Copy link
Member

@melisande-c melisande-c Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just have at the start of this function

if isinstance(model, VAEModule):
    raise NotImplementedError(
        "Exporting a VAE model to the Bioimage Model Zoo format has not been implemented yet, we are working on it!"
    )

Comment on lines +266 to +268
r"""Compute the log-probability.

at `x` of a Gaussian distribution
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this additional full stop and new line might have been an accident

elif isinstance(self.data_config, N2VDataConfig):
return self.patch_transform(patch=patch)
else:
raise ValueError(
"Something went wrong! No target provided (not supervised training) "
"while the algorithm is not Noise2Void."
)
return self.patch_transform(patch=patch)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still want to raise an error here if the user does not provide a target for a supervised algorithm

@melisande-c
Copy link
Member

Also if the LVAE model, LVAE losses and anything else related are not going to be sandboxed from the rest of CAREamics any more we need to edit pre-commit config to allow mypy to check the relevant code again

exclude: "^src/careamics/lvae_training/.*|^src/careamics/models/lvae/.*|^src/careamics/config/likelihood_model.py|^src/careamics/losses/loss_factory.py|^src/careamics/losses/lvae/losses.py"

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 this pull request may close these issues.

2 participants