Algorithms
Algorithm configurations.
CAREAlgorithm
Bases: UNetBasedAlgorithm
CARE algorithm configuration.
Attributes:
algorithm = 'care'
class-attribute
instance-attribute
CARE Algorithm name.
loss = 'mae'
class-attribute
instance-attribute
CARE-compatible loss function.
lr_scheduler = LrSchedulerConfig()
class-attribute
instance-attribute
Learning rate scheduler to use, defined in SupportedLrScheduler.
model
instance-attribute
UNet without a final activation function, without the n2v2 modifications, and
without independent channels for mismatching input/output channel numbers.
optimizer = OptimizerConfig()
class-attribute
instance-attribute
Optimizer to use, defined in SupportedOptimizer.
__str__()
get_algorithm_citations()
Return a list of citation entries of the current algorithm.
This is used to generate the model description for the BioImage Model Zoo.
Returns:
-
List[CiteEntry]–List of citation entries.
get_algorithm_description()
get_algorithm_friendly_name()
get_algorithm_references()
Get the algorithm references.
This is used to generate the README of the BioImage Model Zoo export.
Returns:
-
str–Algorithm references.
get_num_input_channels()
is_supervised()
classmethod
uses_batch_norm()
Return whether the model uses batch normalization.
Returns:
-
bool–Whether the model uses batch normalization.
HDNAlgorithm
Bases: VAEBasedAlgorithm
HDN algorithm configuration.
optimizer = OptimizerConfig()
class-attribute
instance-attribute
Optimizer to use, defined in SupportedOptimizer.
__str__()
algorithm_cross_validation()
get_algorithm_citations()
Return a list of citation entries of the current algorithm.
This is used to generate the model description for the BioImage Model Zoo.
Returns:
-
List[CiteEntry]–List of citation entries.
get_algorithm_description()
get_algorithm_friendly_name()
get_algorithm_references()
Get the algorithm references.
This is used to generate the README of the BioImage Model Zoo export.
Returns:
-
str–Algorithm references.
get_compatible_algorithms()
classmethod
Get the list of compatible algorithms.
Returns:
-
list of str–List of compatible algorithms.
output_channels_validation()
Validate the consistency between number of out channels and noise models.
Returns:
-
Self–The validated model.
predict_logvar_validation()
Validate the consistency of predict_logvar throughout the model.
Returns:
-
Self–The validated model.
MicroSplitAlgorithm
Bases: VAEBasedAlgorithm
MicroSplit algorithm configuration.
optimizer = OptimizerConfig()
class-attribute
instance-attribute
Optimizer to use, defined in SupportedOptimizer.
__str__()
algorithm_cross_validation()
get_algorithm_citations()
Return a list of citation entries of the current algorithm.
This is used to generate the model description for the BioImage Model Zoo.
Returns:
-
List[CiteEntry]–List of citation entries.
get_algorithm_description()
get_algorithm_friendly_name()
get_algorithm_references()
Get the algorithm references.
This is used to generate the README of the BioImage Model Zoo export.
Returns:
-
str–Algorithm references.
get_compatible_algorithms()
classmethod
Get the list of compatible algorithms.
Returns:
-
list of str–List of compatible algorithms.
output_channels_validation()
Validate the consistency between number of out channels and noise models.
Returns:
-
Self–The validated model.
predict_logvar_validation()
Validate the consistency of predict_logvar throughout the model.
Returns:
-
Self–The validated model.
N2NAlgorithm
Bases: UNetBasedAlgorithm
Noise2Noise Algorithm configuration.
algorithm = 'n2n'
class-attribute
instance-attribute
N2N Algorithm name.
loss = 'mae'
class-attribute
instance-attribute
N2N-compatible loss function.
lr_scheduler = LrSchedulerConfig()
class-attribute
instance-attribute
Learning rate scheduler to use, defined in SupportedLrScheduler.
model
instance-attribute
UNet without a final activation function, without the n2v2 modifications, and
without independent channels for mismatching input/output channel numbers.
optimizer = OptimizerConfig()
class-attribute
instance-attribute
Optimizer to use, defined in SupportedOptimizer.
__str__()
get_algorithm_citations()
Return a list of citation entries of the current algorithm.
This is used to generate the model description for the BioImage Model Zoo.
Returns:
-
List[CiteEntry]–List of citation entries.
get_algorithm_description()
get_algorithm_friendly_name()
get_algorithm_references()
Get the algorithm references.
This is used to generate the README of the BioImage Model Zoo export.
Returns:
-
str–Algorithm references.
get_num_input_channels()
is_supervised()
classmethod
uses_batch_norm()
Return whether the model uses batch normalization.
Returns:
-
bool–Whether the model uses batch normalization.
N2VAlgorithm
Bases: UNetBasedAlgorithm
N2V Algorithm configuration.
algorithm = 'n2v'
class-attribute
instance-attribute
N2V Algorithm name.
loss = 'n2v'
class-attribute
instance-attribute
N2V loss function.
lr_scheduler = LrSchedulerConfig()
class-attribute
instance-attribute
Learning rate scheduler to use, defined in SupportedLrScheduler.
model
instance-attribute
Model parameters.
monitor_metric = 'val_loss'
class-attribute
instance-attribute
Metric to monitor for the learning rate scheduler. Used in the returned dict of
PyTorch Lightning configure_optimizers method.
n2v_config = N2VManipulateConfig()
class-attribute
instance-attribute
Noise2Void pixel manipulation configuration.
optimizer = OptimizerConfig()
class-attribute
instance-attribute
Optimizer to use, defined in SupportedOptimizer.
__str__()
get_algorithm_citations()
Return a list of citation entries of the current algorithm.
This is used to generate the model description for the BioImage Model Zoo.
Returns:
-
List[CiteEntry]–List of citation entries.
get_algorithm_description()
Return a description of the algorithm.
This method is used to generate the README of the BioImage Model Zoo export.
Returns:
-
str–Description of the algorithm.
get_algorithm_friendly_name()
get_algorithm_references()
Get the algorithm references.
This is used to generate the README of the BioImage Model Zoo export.
Returns:
-
str–Algorithm references.
get_num_input_channels()
is_struct_n2v()
Check if the configuration is using structN2V.
Returns:
-
bool–Whether the configuration is using structN2V.
is_supervised()
classmethod
set_n2v2(use_n2v2)
Set the configuration to use N2V2 or the vanilla Noise2Void.
This method ensures that N2V2 is set correctly and remain coherent, as opposed to setting the different parameters individually.
Parameters:
-
use_n2v2(bool) –Whether to use N2V2.
uses_batch_norm()
Return whether the model uses batch normalization.
Returns:
-
bool–Whether the model uses batch normalization.
validate_n2v2()
Validate that the N2V2 strategy and models are set correctly.
Returns:
-
Self–The validateed configuration.
Raises:
-
ValueError–If N2V2 is used with the wrong pixel manipulation strategy.
PN2VAlgorithm
Bases: UNetBasedAlgorithm
PN2V Algorithm configuration.
algorithm = 'pn2v'
class-attribute
instance-attribute
PN2V Algorithm name.
loss = 'pn2v'
class-attribute
instance-attribute
PN2V loss function (uses N2V loss with noise model).
lr_scheduler = LrSchedulerConfig()
class-attribute
instance-attribute
Learning rate scheduler to use, defined in SupportedLrScheduler.
noise_model
instance-attribute
Noise model configuration for probabilistic denoising.
optimizer = OptimizerConfig()
class-attribute
instance-attribute
Optimizer to use, defined in SupportedOptimizer.
__str__()
get_algorithm_citations()
Return a list of citation entries of the current algorithm.
This is used to generate the model description for the BioImage Model Zoo.
Returns:
-
List[CiteEntry]–List of citation entries.
get_algorithm_description()
Return a description of the algorithm.
This method is used to generate the README of the BioImage Model Zoo export.
Returns:
-
str–Description of the algorithm.
get_algorithm_friendly_name()
get_algorithm_references()
Get the algorithm references.
This is used to generate the README of the BioImage Model Zoo export.
Returns:
-
str–Algorithm references.
get_num_input_channels()
is_struct_n2v()
Check if the configuration is using structPN2V.
Returns:
-
bool–Whether the configuration is using structPN2V.
set_n2v2(use_n2v2)
Set the configuration to use PN2V2 or the vanilla Probabilistic Noise2Void.
This method ensures that PN2V2 is set correctly and remain coherent, as opposed to setting the different parameters individually.
Parameters:
-
use_n2v2(bool) –Whether to use PN2V2.
uses_batch_norm()
Return whether the model uses batch normalization.
Returns:
-
bool–Whether the model uses batch normalization.
validate_n2v2()
Validate that the N2V2 strategy and models are set correctly.
Returns:
-
Self–The validated configuration.
Raises:
-
ValueError–If N2V2 is used with the wrong pixel manipulation strategy.
UNetBasedAlgorithm
Bases: BaseModel
General UNet-based algorithm configuration.
This Pydantic model validates the parameters governing the components of the training algorithm: which algorithm, loss function, model architecture, optimizer, and learning rate scheduler to use.
Currently, we only support N2V, CARE, N2N, and PN2V algorithms. In order to train
these algorithms, use the corresponding configuration child classes (e.g.
N2VAlgorithm) to ensure coherent parameters (e.g. specific losses).
Attributes:
-
algorithm({n2v, care, n2n, pn2v}) –Algorithm to use.
-
loss({n2v, mae, mse}) –Loss function to use.
-
model(UNetConfig) –Model architecture to use.
-
optimizer((OptimizerConfig, optional)) –Optimizer to use.
-
lr_scheduler((LrSchedulerConfig, optional)) –Learning rate scheduler to use.
Raises:
-
ValueError–Algorithm parameter type validation errors.
-
ValueError–If the algorithm, loss and model are not compatible.
algorithm
instance-attribute
Algorithm name, as defined in SupportedAlgorithm.
loss
instance-attribute
Loss function to use, as defined in SupportedLoss.
lr_scheduler = LrSchedulerConfig()
class-attribute
instance-attribute
Learning rate scheduler to use, defined in SupportedLrScheduler.
model
instance-attribute
UNet model configuration.
optimizer = OptimizerConfig()
class-attribute
instance-attribute
Optimizer to use, defined in SupportedOptimizer.
__str__()
get_num_input_channels()
uses_batch_norm()
Return whether the model uses batch normalization.
Returns:
-
bool–Whether the model uses batch normalization.
VAEBasedAlgorithm
Bases: BaseModel
VAE-based algorithm configuration.
optimizer = OptimizerConfig()
class-attribute
instance-attribute
Optimizer to use, defined in SupportedOptimizer.
__str__()
algorithm_cross_validation()
get_compatible_algorithms()
classmethod
Get the list of compatible algorithms.
Returns:
-
list of str–List of compatible algorithms.
output_channels_validation()
Validate the consistency between number of out channels and noise models.
Returns:
-
Self–The validated model.
predict_logvar_validation()
Validate the consistency of predict_logvar throughout the model.
Returns:
-
Self–The validated model.