careamics 0.1.0rc1__py3-none-any.whl → 0.1.0rc3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of careamics might be problematic. Click here for more details.
- careamics/__init__.py +14 -4
- careamics/callbacks/__init__.py +6 -0
- careamics/callbacks/hyperparameters_callback.py +42 -0
- careamics/callbacks/progress_bar_callback.py +57 -0
- careamics/careamist.py +761 -0
- careamics/config/__init__.py +27 -3
- careamics/config/algorithm_model.py +167 -0
- careamics/config/architectures/__init__.py +17 -0
- careamics/config/architectures/architecture_model.py +29 -0
- careamics/config/architectures/custom_model.py +150 -0
- careamics/config/architectures/register_model.py +101 -0
- careamics/config/architectures/unet_model.py +96 -0
- careamics/config/architectures/vae_model.py +39 -0
- careamics/config/callback_model.py +92 -0
- careamics/config/configuration_factory.py +460 -0
- careamics/config/configuration_model.py +596 -0
- careamics/config/data_model.py +555 -0
- careamics/config/inference_model.py +283 -0
- careamics/config/noise_models.py +162 -0
- careamics/config/optimizer_models.py +181 -0
- careamics/config/references/__init__.py +45 -0
- careamics/config/references/algorithm_descriptions.py +131 -0
- careamics/config/references/references.py +38 -0
- careamics/config/support/__init__.py +33 -0
- careamics/config/support/supported_activations.py +24 -0
- careamics/config/support/supported_algorithms.py +18 -0
- careamics/config/support/supported_architectures.py +18 -0
- careamics/config/support/supported_data.py +82 -0
- careamics/{dataset/extraction_strategy.py → config/support/supported_extraction_strategies.py} +5 -2
- careamics/config/support/supported_loggers.py +8 -0
- careamics/config/support/supported_losses.py +25 -0
- careamics/config/support/supported_optimizers.py +55 -0
- careamics/config/support/supported_pixel_manipulations.py +15 -0
- careamics/config/support/supported_struct_axis.py +19 -0
- careamics/config/support/supported_transforms.py +23 -0
- careamics/config/tile_information.py +104 -0
- careamics/config/training_model.py +65 -0
- careamics/config/transformations/__init__.py +14 -0
- careamics/config/transformations/n2v_manipulate_model.py +63 -0
- careamics/config/transformations/nd_flip_model.py +32 -0
- careamics/config/transformations/normalize_model.py +31 -0
- careamics/config/transformations/transform_model.py +44 -0
- careamics/config/transformations/xy_random_rotate90_model.py +29 -0
- careamics/config/validators/__init__.py +5 -0
- careamics/config/validators/validator_utils.py +100 -0
- careamics/conftest.py +26 -0
- careamics/dataset/__init__.py +5 -0
- careamics/dataset/dataset_utils/__init__.py +19 -0
- careamics/dataset/dataset_utils/dataset_utils.py +100 -0
- careamics/dataset/dataset_utils/file_utils.py +140 -0
- careamics/dataset/dataset_utils/read_tiff.py +61 -0
- careamics/dataset/dataset_utils/read_utils.py +25 -0
- careamics/dataset/dataset_utils/read_zarr.py +56 -0
- careamics/dataset/in_memory_dataset.py +321 -131
- careamics/dataset/iterable_dataset.py +416 -0
- careamics/dataset/patching/__init__.py +8 -0
- careamics/dataset/patching/patch_transform.py +44 -0
- careamics/dataset/patching/patching.py +212 -0
- careamics/dataset/patching/random_patching.py +190 -0
- careamics/dataset/patching/sequential_patching.py +206 -0
- careamics/dataset/patching/tiled_patching.py +158 -0
- careamics/dataset/patching/validate_patch_dimension.py +60 -0
- careamics/dataset/zarr_dataset.py +149 -0
- careamics/lightning_datamodule.py +665 -0
- careamics/lightning_module.py +292 -0
- careamics/lightning_prediction_datamodule.py +390 -0
- careamics/lightning_prediction_loop.py +116 -0
- careamics/losses/__init__.py +4 -1
- careamics/losses/loss_factory.py +24 -13
- careamics/losses/losses.py +65 -5
- careamics/losses/noise_model_factory.py +40 -0
- careamics/losses/noise_models.py +524 -0
- careamics/model_io/__init__.py +8 -0
- careamics/model_io/bioimage/__init__.py +11 -0
- careamics/model_io/bioimage/_readme_factory.py +120 -0
- careamics/model_io/bioimage/bioimage_utils.py +48 -0
- careamics/model_io/bioimage/model_description.py +318 -0
- careamics/model_io/bmz_io.py +231 -0
- careamics/model_io/model_io_utils.py +80 -0
- careamics/models/__init__.py +4 -1
- careamics/models/activation.py +35 -0
- careamics/models/layers.py +244 -0
- careamics/models/model_factory.py +21 -202
- careamics/models/unet.py +46 -20
- careamics/prediction/__init__.py +1 -3
- careamics/prediction/stitch_prediction.py +73 -0
- careamics/transforms/__init__.py +41 -0
- careamics/transforms/n2v_manipulate.py +113 -0
- careamics/transforms/nd_flip.py +93 -0
- careamics/transforms/normalize.py +109 -0
- careamics/transforms/pixel_manipulation.py +383 -0
- careamics/transforms/struct_mask_parameters.py +18 -0
- careamics/transforms/tta.py +74 -0
- careamics/transforms/xy_random_rotate90.py +95 -0
- careamics/utils/__init__.py +10 -13
- careamics/utils/base_enum.py +32 -0
- careamics/utils/context.py +22 -2
- careamics/utils/metrics.py +0 -46
- careamics/utils/path_utils.py +24 -0
- careamics/utils/ram.py +13 -0
- careamics/utils/receptive_field.py +102 -0
- careamics/utils/running_stats.py +43 -0
- careamics/utils/torch_utils.py +89 -56
- careamics-0.1.0rc3.dist-info/METADATA +122 -0
- careamics-0.1.0rc3.dist-info/RECORD +109 -0
- {careamics-0.1.0rc1.dist-info → careamics-0.1.0rc3.dist-info}/WHEEL +1 -1
- careamics/bioimage/__init__.py +0 -15
- careamics/bioimage/docs/Noise2Void.md +0 -5
- careamics/bioimage/docs/__init__.py +0 -1
- careamics/bioimage/io.py +0 -271
- careamics/config/algorithm.py +0 -231
- careamics/config/config.py +0 -296
- careamics/config/config_filter.py +0 -44
- careamics/config/data.py +0 -194
- careamics/config/torch_optim.py +0 -118
- careamics/config/training.py +0 -534
- careamics/dataset/dataset_utils.py +0 -115
- careamics/dataset/patching.py +0 -493
- careamics/dataset/prepare_dataset.py +0 -174
- careamics/dataset/tiff_dataset.py +0 -211
- careamics/engine.py +0 -954
- careamics/manipulation/__init__.py +0 -4
- careamics/manipulation/pixel_manipulation.py +0 -158
- careamics/prediction/prediction_utils.py +0 -102
- careamics/utils/ascii_logo.txt +0 -9
- careamics/utils/augment.py +0 -65
- careamics/utils/normalization.py +0 -55
- careamics/utils/validators.py +0 -156
- careamics/utils/wandb.py +0 -121
- careamics-0.1.0rc1.dist-info/METADATA +0 -80
- careamics-0.1.0rc1.dist-info/RECORD +0 -46
- {careamics-0.1.0rc1.dist-info → careamics-0.1.0rc3.dist-info}/licenses/LICENSE +0 -0
careamics/__init__.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""Main module."""
|
|
2
|
-
|
|
1
|
+
"""Main CAREamics module."""
|
|
3
2
|
|
|
4
3
|
from importlib.metadata import PackageNotFoundError, version
|
|
5
4
|
|
|
@@ -8,7 +7,18 @@ try:
|
|
|
8
7
|
except PackageNotFoundError:
|
|
9
8
|
__version__ = "uninstalled"
|
|
10
9
|
|
|
11
|
-
__all__ = [
|
|
10
|
+
__all__ = [
|
|
11
|
+
"CAREamist",
|
|
12
|
+
"CAREamicsModule",
|
|
13
|
+
"Configuration",
|
|
14
|
+
"load_configuration",
|
|
15
|
+
"save_configuration",
|
|
16
|
+
"CAREamicsTrainDataModule",
|
|
17
|
+
"CAREamicsPredictDataModule",
|
|
18
|
+
]
|
|
12
19
|
|
|
20
|
+
from .careamist import CAREamist
|
|
13
21
|
from .config import Configuration, load_configuration, save_configuration
|
|
14
|
-
from .
|
|
22
|
+
from .lightning_datamodule import CAREamicsTrainDataModule
|
|
23
|
+
from .lightning_module import CAREamicsModule
|
|
24
|
+
from .lightning_prediction_datamodule import CAREamicsPredictDataModule
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from pytorch_lightning import LightningModule, Trainer
|
|
2
|
+
from pytorch_lightning.callbacks import Callback
|
|
3
|
+
|
|
4
|
+
from careamics.config import Configuration
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class HyperParametersCallback(Callback):
|
|
8
|
+
"""
|
|
9
|
+
Callback allowing saving CAREamics configuration as hyperparameters in the model.
|
|
10
|
+
|
|
11
|
+
This allows saving the configuration as dictionnary in the checkpoints, and
|
|
12
|
+
loading it subsequently in a CAREamist instance.
|
|
13
|
+
|
|
14
|
+
Attributes
|
|
15
|
+
----------
|
|
16
|
+
config : Configuration
|
|
17
|
+
CAREamics configuration to be saved as hyperparameter in the model.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def __init__(self, config: Configuration):
|
|
21
|
+
"""
|
|
22
|
+
Constructor.
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
config : Configuration
|
|
27
|
+
CAREamics configuration to be saved as hyperparameter in the model.
|
|
28
|
+
"""
|
|
29
|
+
self.config = config
|
|
30
|
+
|
|
31
|
+
def on_train_start(self, trainer: Trainer, pl_module: LightningModule):
|
|
32
|
+
"""
|
|
33
|
+
Update the hyperparameters of the model with the configuration on train start.
|
|
34
|
+
|
|
35
|
+
Parameters
|
|
36
|
+
----------
|
|
37
|
+
trainer : Trainer
|
|
38
|
+
PyTorch Lightning trainer.
|
|
39
|
+
pl_module : LightningModule
|
|
40
|
+
PyTorch Lightning module.
|
|
41
|
+
"""
|
|
42
|
+
pl_module.hparams.update(self.config.model_dump())
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from typing import Dict, Union
|
|
3
|
+
|
|
4
|
+
from pytorch_lightning import LightningModule, Trainer
|
|
5
|
+
from pytorch_lightning.callbacks import TQDMProgressBar
|
|
6
|
+
from tqdm import tqdm
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ProgressBarCallback(TQDMProgressBar):
|
|
10
|
+
"""Progress bar for training and validation steps."""
|
|
11
|
+
|
|
12
|
+
def init_train_tqdm(self) -> tqdm:
|
|
13
|
+
"""Override this to customize the tqdm bar for training."""
|
|
14
|
+
bar = tqdm(
|
|
15
|
+
desc="Training",
|
|
16
|
+
position=(2 * self.process_position),
|
|
17
|
+
disable=self.is_disabled,
|
|
18
|
+
leave=True,
|
|
19
|
+
dynamic_ncols=True,
|
|
20
|
+
file=sys.stdout,
|
|
21
|
+
smoothing=0,
|
|
22
|
+
)
|
|
23
|
+
return bar
|
|
24
|
+
|
|
25
|
+
def init_validation_tqdm(self) -> tqdm:
|
|
26
|
+
"""Override this to customize the tqdm bar for validation."""
|
|
27
|
+
# The main progress bar doesn't exist in `trainer.validate()`
|
|
28
|
+
has_main_bar = self.train_progress_bar is not None
|
|
29
|
+
bar = tqdm(
|
|
30
|
+
desc="Validating",
|
|
31
|
+
position=(2 * self.process_position + has_main_bar),
|
|
32
|
+
disable=self.is_disabled,
|
|
33
|
+
leave=False,
|
|
34
|
+
dynamic_ncols=True,
|
|
35
|
+
file=sys.stdout,
|
|
36
|
+
)
|
|
37
|
+
return bar
|
|
38
|
+
|
|
39
|
+
def init_test_tqdm(self) -> tqdm:
|
|
40
|
+
"""Override this to customize the tqdm bar for testing."""
|
|
41
|
+
bar = tqdm(
|
|
42
|
+
desc="Testing",
|
|
43
|
+
position=(2 * self.process_position),
|
|
44
|
+
disable=self.is_disabled,
|
|
45
|
+
leave=True,
|
|
46
|
+
dynamic_ncols=False,
|
|
47
|
+
ncols=100,
|
|
48
|
+
file=sys.stdout,
|
|
49
|
+
)
|
|
50
|
+
return bar
|
|
51
|
+
|
|
52
|
+
def get_metrics(
|
|
53
|
+
self, trainer: Trainer, pl_module: LightningModule
|
|
54
|
+
) -> Dict[str, Union[int, str, float, Dict[str, float]]]:
|
|
55
|
+
"""Override this to customize the metrics displayed in the progress bar."""
|
|
56
|
+
pbar_metrics = trainer.progress_bar_metrics
|
|
57
|
+
return {**pbar_metrics}
|