stouputils 1.14.0__py3-none-any.whl → 1.14.2__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.
Files changed (108) hide show
  1. stouputils/__init__.pyi +15 -0
  2. stouputils/_deprecated.pyi +12 -0
  3. stouputils/all_doctests.pyi +46 -0
  4. stouputils/applications/__init__.pyi +2 -0
  5. stouputils/applications/automatic_docs.py +3 -0
  6. stouputils/applications/automatic_docs.pyi +106 -0
  7. stouputils/applications/upscaler/__init__.pyi +3 -0
  8. stouputils/applications/upscaler/config.pyi +18 -0
  9. stouputils/applications/upscaler/image.pyi +109 -0
  10. stouputils/applications/upscaler/video.pyi +60 -0
  11. stouputils/archive.pyi +67 -0
  12. stouputils/backup.pyi +109 -0
  13. stouputils/collections.pyi +86 -0
  14. stouputils/continuous_delivery/__init__.pyi +5 -0
  15. stouputils/continuous_delivery/cd_utils.pyi +129 -0
  16. stouputils/continuous_delivery/github.pyi +162 -0
  17. stouputils/continuous_delivery/pypi.pyi +52 -0
  18. stouputils/continuous_delivery/pyproject.pyi +67 -0
  19. stouputils/continuous_delivery/stubs.pyi +39 -0
  20. stouputils/ctx.pyi +211 -0
  21. stouputils/data_science/config/get.py +51 -51
  22. stouputils/data_science/data_processing/image/__init__.py +66 -66
  23. stouputils/data_science/data_processing/image/auto_contrast.py +79 -79
  24. stouputils/data_science/data_processing/image/axis_flip.py +58 -58
  25. stouputils/data_science/data_processing/image/bias_field_correction.py +74 -74
  26. stouputils/data_science/data_processing/image/binary_threshold.py +73 -73
  27. stouputils/data_science/data_processing/image/blur.py +59 -59
  28. stouputils/data_science/data_processing/image/brightness.py +54 -54
  29. stouputils/data_science/data_processing/image/canny.py +110 -110
  30. stouputils/data_science/data_processing/image/clahe.py +92 -92
  31. stouputils/data_science/data_processing/image/common.py +30 -30
  32. stouputils/data_science/data_processing/image/contrast.py +53 -53
  33. stouputils/data_science/data_processing/image/curvature_flow_filter.py +74 -74
  34. stouputils/data_science/data_processing/image/denoise.py +378 -378
  35. stouputils/data_science/data_processing/image/histogram_equalization.py +123 -123
  36. stouputils/data_science/data_processing/image/invert.py +64 -64
  37. stouputils/data_science/data_processing/image/laplacian.py +60 -60
  38. stouputils/data_science/data_processing/image/median_blur.py +52 -52
  39. stouputils/data_science/data_processing/image/noise.py +59 -59
  40. stouputils/data_science/data_processing/image/normalize.py +65 -65
  41. stouputils/data_science/data_processing/image/random_erase.py +66 -66
  42. stouputils/data_science/data_processing/image/resize.py +69 -69
  43. stouputils/data_science/data_processing/image/rotation.py +80 -80
  44. stouputils/data_science/data_processing/image/salt_pepper.py +68 -68
  45. stouputils/data_science/data_processing/image/sharpening.py +55 -55
  46. stouputils/data_science/data_processing/image/shearing.py +64 -64
  47. stouputils/data_science/data_processing/image/threshold.py +64 -64
  48. stouputils/data_science/data_processing/image/translation.py +71 -71
  49. stouputils/data_science/data_processing/image/zoom.py +83 -83
  50. stouputils/data_science/data_processing/image_augmentation.py +118 -118
  51. stouputils/data_science/data_processing/image_preprocess.py +183 -183
  52. stouputils/data_science/data_processing/prosthesis_detection.py +359 -359
  53. stouputils/data_science/data_processing/technique.py +481 -481
  54. stouputils/data_science/dataset/__init__.py +45 -45
  55. stouputils/data_science/dataset/dataset.py +292 -292
  56. stouputils/data_science/dataset/dataset_loader.py +135 -135
  57. stouputils/data_science/dataset/grouping_strategy.py +296 -296
  58. stouputils/data_science/dataset/image_loader.py +100 -100
  59. stouputils/data_science/dataset/xy_tuple.py +696 -696
  60. stouputils/data_science/metric_dictionnary.py +106 -106
  61. stouputils/data_science/mlflow_utils.py +206 -206
  62. stouputils/data_science/models/abstract_model.py +149 -149
  63. stouputils/data_science/models/all.py +85 -85
  64. stouputils/data_science/models/keras/all.py +38 -38
  65. stouputils/data_science/models/keras/convnext.py +62 -62
  66. stouputils/data_science/models/keras/densenet.py +50 -50
  67. stouputils/data_science/models/keras/efficientnet.py +60 -60
  68. stouputils/data_science/models/keras/mobilenet.py +56 -56
  69. stouputils/data_science/models/keras/resnet.py +52 -52
  70. stouputils/data_science/models/keras/squeezenet.py +233 -233
  71. stouputils/data_science/models/keras/vgg.py +42 -42
  72. stouputils/data_science/models/keras/xception.py +38 -38
  73. stouputils/data_science/models/keras_utils/callbacks/__init__.py +20 -20
  74. stouputils/data_science/models/keras_utils/callbacks/colored_progress_bar.py +219 -219
  75. stouputils/data_science/models/keras_utils/callbacks/learning_rate_finder.py +148 -148
  76. stouputils/data_science/models/keras_utils/callbacks/model_checkpoint_v2.py +31 -31
  77. stouputils/data_science/models/keras_utils/callbacks/progressive_unfreezing.py +249 -249
  78. stouputils/data_science/models/keras_utils/callbacks/warmup_scheduler.py +66 -66
  79. stouputils/data_science/models/keras_utils/losses/__init__.py +12 -12
  80. stouputils/data_science/models/keras_utils/losses/next_generation_loss.py +56 -56
  81. stouputils/data_science/models/keras_utils/visualizations.py +416 -416
  82. stouputils/data_science/models/sandbox.py +116 -116
  83. stouputils/data_science/range_tuple.py +234 -234
  84. stouputils/data_science/utils.py +285 -285
  85. stouputils/decorators.pyi +242 -0
  86. stouputils/image.pyi +172 -0
  87. stouputils/installer/__init__.py +18 -18
  88. stouputils/installer/__init__.pyi +5 -0
  89. stouputils/installer/common.pyi +39 -0
  90. stouputils/installer/downloader.pyi +24 -0
  91. stouputils/installer/linux.py +144 -144
  92. stouputils/installer/linux.pyi +39 -0
  93. stouputils/installer/main.py +223 -223
  94. stouputils/installer/main.pyi +57 -0
  95. stouputils/installer/windows.py +136 -136
  96. stouputils/installer/windows.pyi +31 -0
  97. stouputils/io.pyi +213 -0
  98. stouputils/parallel.py +12 -10
  99. stouputils/parallel.pyi +211 -0
  100. stouputils/print.pyi +136 -0
  101. stouputils/py.typed +1 -1
  102. stouputils/stouputils/parallel.pyi +4 -4
  103. stouputils/version_pkg.pyi +15 -0
  104. {stouputils-1.14.0.dist-info → stouputils-1.14.2.dist-info}/METADATA +1 -1
  105. stouputils-1.14.2.dist-info/RECORD +171 -0
  106. stouputils-1.14.0.dist-info/RECORD +0 -140
  107. {stouputils-1.14.0.dist-info → stouputils-1.14.2.dist-info}/WHEEL +0 -0
  108. {stouputils-1.14.0.dist-info → stouputils-1.14.2.dist-info}/entry_points.txt +0 -0
@@ -1,149 +1,149 @@
1
- """ Abstract base class for all model implementations.
2
- Defines the interface that all concrete model classes must implement.
3
-
4
- Provides abstract methods for core model operations including:
5
-
6
- - Class routine management
7
- - Model loading
8
- - Training procedures
9
- - Prediction functionality
10
- - Evaluation metrics
11
-
12
- Classes inheriting from AbstractModel must implement all methods.
13
- """
14
-
15
- # Imports
16
- from __future__ import annotations
17
-
18
- import multiprocessing.queues
19
- from collections.abc import Iterable
20
- from tempfile import TemporaryDirectory
21
- from typing import Any
22
-
23
- from ...decorators import abstract, LogLevels
24
-
25
- from ..dataset import Dataset
26
-
27
-
28
- # Base class
29
- class AbstractModel:
30
- """ Abstract class for all models to copy and implement the methods. """
31
- # Class methods
32
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
33
- def __init__(
34
- self, num_classes: int, kfold: int = 0, transfer_learning: str = "imagenet", **override_params: Any
35
- ) -> None:
36
- pass
37
-
38
-
39
- ## Public abstract methods
40
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
41
- def routine_full(self, dataset: Dataset, verbose: int = 0) -> AbstractModel:
42
- return self
43
-
44
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
45
- def class_load(self) -> None:
46
- pass
47
-
48
-
49
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
50
- def class_train(self, dataset: Dataset, verbose: int = 0) -> bool:
51
- return False
52
-
53
-
54
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
55
- def class_predict(self, X_test: Iterable[Any]) -> Iterable[Any]:
56
- return []
57
-
58
-
59
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
60
- def class_evaluate(
61
- self,
62
- dataset: Dataset,
63
- metrics_names: tuple[str, ...] = (),
64
- save_model: bool = False,
65
- verbose: int = 0
66
- ) -> bool:
67
- return False
68
-
69
-
70
- ## Protected abstract methods
71
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
72
- def _fit(
73
- self,
74
- model: Any,
75
- x: Any,
76
- y: Any | None = None,
77
- validation_data: tuple[Any, Any] | None = None,
78
- shuffle: bool = True,
79
- batch_size: int | None = None,
80
- epochs: int = 1,
81
- callbacks: list[Any] | None = None,
82
- class_weight: dict[int, float] | None = None,
83
- verbose: int = 0,
84
- *args: Any,
85
- **kwargs: Any
86
- ) -> Any:
87
- pass
88
-
89
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
90
- def _get_callbacks(self) -> list[Any]:
91
- return []
92
-
93
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
94
- def _get_metrics(self) -> list[Any]:
95
- return []
96
-
97
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
98
- def _get_optimizer(self, learning_rate: float = 0.0) -> Any:
99
- pass
100
-
101
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
102
- def _get_loss(self) -> Any:
103
- pass
104
-
105
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
106
- def _get_base_model(self) -> Any:
107
- pass
108
-
109
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
110
- def _get_architectures(
111
- self, optimizer: Any = None, loss: Any = None, metrics: list[Any] | None = None
112
- ) -> tuple[Any, Any]:
113
- return (None, None)
114
-
115
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
116
- def _find_best_learning_rate(self, dataset: Dataset, verbose: int = 0) -> float:
117
- return 0.0
118
-
119
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
120
- def _train_fold(self, dataset: Dataset, fold_number: int = 0, mlflow_prefix: str = "history", verbose: int = 0) -> Any:
121
- pass
122
-
123
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
124
- def _log_final_model(self) -> None:
125
- pass
126
-
127
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
128
- def _find_best_learning_rate_subprocess(
129
- self, dataset: Dataset, queue: multiprocessing.queues.Queue[Any] | None = None, verbose: int = 0
130
- ) -> dict[str, Any] | None:
131
- pass
132
-
133
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
134
- def _find_best_unfreeze_percentage_subprocess(
135
- self, dataset: Dataset, queue: multiprocessing.queues.Queue[Any] | None = None, verbose: int = 0
136
- ) -> dict[str, Any] | None:
137
- pass
138
-
139
- @abstract(error_log=LogLevels.ERROR_TRACEBACK)
140
- def _train_subprocess(
141
- self,
142
- dataset: Dataset,
143
- checkpoint_path: str,
144
- temp_dir: TemporaryDirectory[str] | None = None,
145
- queue: multiprocessing.queues.Queue[Any] | None = None,
146
- verbose: int = 0
147
- ) -> dict[str, Any] | None:
148
- pass
149
-
1
+ """ Abstract base class for all model implementations.
2
+ Defines the interface that all concrete model classes must implement.
3
+
4
+ Provides abstract methods for core model operations including:
5
+
6
+ - Class routine management
7
+ - Model loading
8
+ - Training procedures
9
+ - Prediction functionality
10
+ - Evaluation metrics
11
+
12
+ Classes inheriting from AbstractModel must implement all methods.
13
+ """
14
+
15
+ # Imports
16
+ from __future__ import annotations
17
+
18
+ import multiprocessing.queues
19
+ from collections.abc import Iterable
20
+ from tempfile import TemporaryDirectory
21
+ from typing import Any
22
+
23
+ from ...decorators import abstract, LogLevels
24
+
25
+ from ..dataset import Dataset
26
+
27
+
28
+ # Base class
29
+ class AbstractModel:
30
+ """ Abstract class for all models to copy and implement the methods. """
31
+ # Class methods
32
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
33
+ def __init__(
34
+ self, num_classes: int, kfold: int = 0, transfer_learning: str = "imagenet", **override_params: Any
35
+ ) -> None:
36
+ pass
37
+
38
+
39
+ ## Public abstract methods
40
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
41
+ def routine_full(self, dataset: Dataset, verbose: int = 0) -> AbstractModel:
42
+ return self
43
+
44
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
45
+ def class_load(self) -> None:
46
+ pass
47
+
48
+
49
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
50
+ def class_train(self, dataset: Dataset, verbose: int = 0) -> bool:
51
+ return False
52
+
53
+
54
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
55
+ def class_predict(self, X_test: Iterable[Any]) -> Iterable[Any]:
56
+ return []
57
+
58
+
59
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
60
+ def class_evaluate(
61
+ self,
62
+ dataset: Dataset,
63
+ metrics_names: tuple[str, ...] = (),
64
+ save_model: bool = False,
65
+ verbose: int = 0
66
+ ) -> bool:
67
+ return False
68
+
69
+
70
+ ## Protected abstract methods
71
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
72
+ def _fit(
73
+ self,
74
+ model: Any,
75
+ x: Any,
76
+ y: Any | None = None,
77
+ validation_data: tuple[Any, Any] | None = None,
78
+ shuffle: bool = True,
79
+ batch_size: int | None = None,
80
+ epochs: int = 1,
81
+ callbacks: list[Any] | None = None,
82
+ class_weight: dict[int, float] | None = None,
83
+ verbose: int = 0,
84
+ *args: Any,
85
+ **kwargs: Any
86
+ ) -> Any:
87
+ pass
88
+
89
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
90
+ def _get_callbacks(self) -> list[Any]:
91
+ return []
92
+
93
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
94
+ def _get_metrics(self) -> list[Any]:
95
+ return []
96
+
97
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
98
+ def _get_optimizer(self, learning_rate: float = 0.0) -> Any:
99
+ pass
100
+
101
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
102
+ def _get_loss(self) -> Any:
103
+ pass
104
+
105
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
106
+ def _get_base_model(self) -> Any:
107
+ pass
108
+
109
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
110
+ def _get_architectures(
111
+ self, optimizer: Any = None, loss: Any = None, metrics: list[Any] | None = None
112
+ ) -> tuple[Any, Any]:
113
+ return (None, None)
114
+
115
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
116
+ def _find_best_learning_rate(self, dataset: Dataset, verbose: int = 0) -> float:
117
+ return 0.0
118
+
119
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
120
+ def _train_fold(self, dataset: Dataset, fold_number: int = 0, mlflow_prefix: str = "history", verbose: int = 0) -> Any:
121
+ pass
122
+
123
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
124
+ def _log_final_model(self) -> None:
125
+ pass
126
+
127
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
128
+ def _find_best_learning_rate_subprocess(
129
+ self, dataset: Dataset, queue: multiprocessing.queues.Queue[Any] | None = None, verbose: int = 0
130
+ ) -> dict[str, Any] | None:
131
+ pass
132
+
133
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
134
+ def _find_best_unfreeze_percentage_subprocess(
135
+ self, dataset: Dataset, queue: multiprocessing.queues.Queue[Any] | None = None, verbose: int = 0
136
+ ) -> dict[str, Any] | None:
137
+ pass
138
+
139
+ @abstract(error_log=LogLevels.ERROR_TRACEBACK)
140
+ def _train_subprocess(
141
+ self,
142
+ dataset: Dataset,
143
+ checkpoint_path: str,
144
+ temp_dir: TemporaryDirectory[str] | None = None,
145
+ queue: multiprocessing.queues.Queue[Any] | None = None,
146
+ verbose: int = 0
147
+ ) -> dict[str, Any] | None:
148
+ pass
149
+
@@ -1,85 +1,85 @@
1
-
2
- # Imports
3
- import itertools
4
-
5
- from .keras.all import (
6
- VGG16,
7
- VGG19,
8
- ConvNeXtBase,
9
- ConvNeXtLarge,
10
- ConvNeXtSmall,
11
- ConvNeXtTiny,
12
- ConvNeXtXLarge,
13
- DenseNet121,
14
- DenseNet169,
15
- DenseNet201,
16
- EfficientNetB0,
17
- EfficientNetV2B0,
18
- EfficientNetV2L,
19
- EfficientNetV2M,
20
- EfficientNetV2S,
21
- MobileNet,
22
- MobileNetV2,
23
- MobileNetV3Large,
24
- MobileNetV3Small,
25
- ResNet50V2,
26
- ResNet101V2,
27
- ResNet152V2,
28
- SqueezeNet,
29
- Xception,
30
- )
31
- from .model_interface import ModelInterface
32
-
33
- # Other models
34
- from .sandbox import Sandbox
35
-
36
-
37
- # Create a custom dictionary class to allow for documentation
38
- class ModelClassMap(dict[type[ModelInterface], tuple[str, ...]]):
39
- pass
40
-
41
- # Routine map
42
- CLASS_MAP: ModelClassMap = ModelClassMap({
43
- SqueezeNet: ("squeezenet", "squeezenets", "all", "often"),
44
-
45
- DenseNet121: ("densenet121", "densenets", "all", "often", "good"),
46
- DenseNet169: ("densenet169", "densenets", "all", "often", "good"),
47
- DenseNet201: ("densenet201", "densenets", "all", "often", "good"),
48
-
49
- EfficientNetB0: ("efficientnetb0", "efficientnets", "all"),
50
- EfficientNetV2B0: ("efficientnetv2b0", "efficientnets", "all"),
51
- EfficientNetV2S: ("efficientnetv2s", "efficientnets", "all", "often"),
52
- EfficientNetV2M: ("efficientnetv2m", "efficientnets", "all", "often"),
53
- EfficientNetV2L: ("efficientnetv2l", "efficientnets", "all", "often"),
54
-
55
- ConvNeXtTiny: ("convnexttiny", "convnexts", "all", "often", "good"),
56
- ConvNeXtSmall: ("convnextsmall", "convnexts", "all", "often"),
57
- ConvNeXtBase: ("convnextbase", "convnexts", "all", "often", "good"),
58
- ConvNeXtLarge: ("convnextlarge", "convnexts", "all", "often"),
59
- ConvNeXtXLarge: ("convnextxlarge", "convnexts", "all", "often", "good"),
60
-
61
- VGG16: ("vgg16", "vggs", "all"),
62
- VGG19: ("vgg19", "vggs", "all"),
63
-
64
- MobileNet: ("mobilenet", "mobilenets", "all"),
65
- MobileNetV2: ("mobilenetv2", "mobilenets", "all", "often"),
66
- MobileNetV3Small: ("mobilenetv3small", "mobilenets", "all", "often"),
67
- MobileNetV3Large: ("mobilenetv3large", "mobilenets", "all", "often", "good"),
68
-
69
- ResNet50V2: ("resnet50v2", "resnetsv2", "resnets", "all", "often"),
70
- ResNet101V2: ("resnet101v2", "resnetsv2", "resnets", "all", "often"),
71
- ResNet152V2: ("resnet152v2", "resnetsv2", "resnets", "all", "often"),
72
-
73
- Xception: ("xception", "xceptions", "all", "often"),
74
- Sandbox: ("sandbox",),
75
- })
76
-
77
- # All models names and aliases
78
- ALL_MODELS: list[str] = sorted(set(itertools.chain.from_iterable(v for v in CLASS_MAP.values())))
79
- """ All models names and aliases found in the `CLASS_MAP` dictionary. """
80
-
81
- # Additional docstring
82
- new_docstring: str = "\n\n" + "\n".join(f"- {k.__name__}: {v}" for k, v in CLASS_MAP.items())
83
- ModelClassMap.__doc__ = "Dictionary mapping class to their names and aliases. " + new_docstring
84
- CLASS_MAP.__doc__ = ModelClassMap.__doc__
85
-
1
+
2
+ # Imports
3
+ import itertools
4
+
5
+ from .keras.all import (
6
+ VGG16,
7
+ VGG19,
8
+ ConvNeXtBase,
9
+ ConvNeXtLarge,
10
+ ConvNeXtSmall,
11
+ ConvNeXtTiny,
12
+ ConvNeXtXLarge,
13
+ DenseNet121,
14
+ DenseNet169,
15
+ DenseNet201,
16
+ EfficientNetB0,
17
+ EfficientNetV2B0,
18
+ EfficientNetV2L,
19
+ EfficientNetV2M,
20
+ EfficientNetV2S,
21
+ MobileNet,
22
+ MobileNetV2,
23
+ MobileNetV3Large,
24
+ MobileNetV3Small,
25
+ ResNet50V2,
26
+ ResNet101V2,
27
+ ResNet152V2,
28
+ SqueezeNet,
29
+ Xception,
30
+ )
31
+ from .model_interface import ModelInterface
32
+
33
+ # Other models
34
+ from .sandbox import Sandbox
35
+
36
+
37
+ # Create a custom dictionary class to allow for documentation
38
+ class ModelClassMap(dict[type[ModelInterface], tuple[str, ...]]):
39
+ pass
40
+
41
+ # Routine map
42
+ CLASS_MAP: ModelClassMap = ModelClassMap({
43
+ SqueezeNet: ("squeezenet", "squeezenets", "all", "often"),
44
+
45
+ DenseNet121: ("densenet121", "densenets", "all", "often", "good"),
46
+ DenseNet169: ("densenet169", "densenets", "all", "often", "good"),
47
+ DenseNet201: ("densenet201", "densenets", "all", "often", "good"),
48
+
49
+ EfficientNetB0: ("efficientnetb0", "efficientnets", "all"),
50
+ EfficientNetV2B0: ("efficientnetv2b0", "efficientnets", "all"),
51
+ EfficientNetV2S: ("efficientnetv2s", "efficientnets", "all", "often"),
52
+ EfficientNetV2M: ("efficientnetv2m", "efficientnets", "all", "often"),
53
+ EfficientNetV2L: ("efficientnetv2l", "efficientnets", "all", "often"),
54
+
55
+ ConvNeXtTiny: ("convnexttiny", "convnexts", "all", "often", "good"),
56
+ ConvNeXtSmall: ("convnextsmall", "convnexts", "all", "often"),
57
+ ConvNeXtBase: ("convnextbase", "convnexts", "all", "often", "good"),
58
+ ConvNeXtLarge: ("convnextlarge", "convnexts", "all", "often"),
59
+ ConvNeXtXLarge: ("convnextxlarge", "convnexts", "all", "often", "good"),
60
+
61
+ VGG16: ("vgg16", "vggs", "all"),
62
+ VGG19: ("vgg19", "vggs", "all"),
63
+
64
+ MobileNet: ("mobilenet", "mobilenets", "all"),
65
+ MobileNetV2: ("mobilenetv2", "mobilenets", "all", "often"),
66
+ MobileNetV3Small: ("mobilenetv3small", "mobilenets", "all", "often"),
67
+ MobileNetV3Large: ("mobilenetv3large", "mobilenets", "all", "often", "good"),
68
+
69
+ ResNet50V2: ("resnet50v2", "resnetsv2", "resnets", "all", "often"),
70
+ ResNet101V2: ("resnet101v2", "resnetsv2", "resnets", "all", "often"),
71
+ ResNet152V2: ("resnet152v2", "resnetsv2", "resnets", "all", "often"),
72
+
73
+ Xception: ("xception", "xceptions", "all", "often"),
74
+ Sandbox: ("sandbox",),
75
+ })
76
+
77
+ # All models names and aliases
78
+ ALL_MODELS: list[str] = sorted(set(itertools.chain.from_iterable(v for v in CLASS_MAP.values())))
79
+ """ All models names and aliases found in the `CLASS_MAP` dictionary. """
80
+
81
+ # Additional docstring
82
+ new_docstring: str = "\n\n" + "\n".join(f"- {k.__name__}: {v}" for k, v in CLASS_MAP.items())
83
+ ModelClassMap.__doc__ = "Dictionary mapping class to their names and aliases. " + new_docstring
84
+ CLASS_MAP.__doc__ = ModelClassMap.__doc__
85
+
@@ -1,38 +1,38 @@
1
-
2
- # Imports
3
- from .convnext import ConvNeXtBase, ConvNeXtLarge, ConvNeXtSmall, ConvNeXtTiny, ConvNeXtXLarge
4
- from .densenet import DenseNet121, DenseNet169, DenseNet201
5
- from .efficientnet import EfficientNetB0, EfficientNetV2B0, EfficientNetV2L, EfficientNetV2M, EfficientNetV2S
6
- from .mobilenet import MobileNet, MobileNetV2, MobileNetV3Large, MobileNetV3Small
7
- from .resnet import ResNet50V2, ResNet101V2, ResNet152V2
8
- from .squeezenet import SqueezeNet
9
- from .vgg import VGG16, VGG19
10
- from .xception import Xception
11
-
12
- __all__ = [
13
- "VGG16",
14
- "VGG19",
15
- "ConvNeXtBase",
16
- "ConvNeXtLarge",
17
- "ConvNeXtSmall",
18
- "ConvNeXtTiny",
19
- "ConvNeXtXLarge",
20
- "DenseNet121",
21
- "DenseNet169",
22
- "DenseNet201",
23
- "EfficientNetB0",
24
- "EfficientNetV2B0",
25
- "EfficientNetV2L",
26
- "EfficientNetV2M",
27
- "EfficientNetV2S",
28
- "MobileNet",
29
- "MobileNetV2",
30
- "MobileNetV3Large",
31
- "MobileNetV3Small",
32
- "ResNet50V2",
33
- "ResNet101V2",
34
- "ResNet152V2",
35
- "SqueezeNet",
36
- "Xception",
37
- ]
38
-
1
+
2
+ # Imports
3
+ from .convnext import ConvNeXtBase, ConvNeXtLarge, ConvNeXtSmall, ConvNeXtTiny, ConvNeXtXLarge
4
+ from .densenet import DenseNet121, DenseNet169, DenseNet201
5
+ from .efficientnet import EfficientNetB0, EfficientNetV2B0, EfficientNetV2L, EfficientNetV2M, EfficientNetV2S
6
+ from .mobilenet import MobileNet, MobileNetV2, MobileNetV3Large, MobileNetV3Small
7
+ from .resnet import ResNet50V2, ResNet101V2, ResNet152V2
8
+ from .squeezenet import SqueezeNet
9
+ from .vgg import VGG16, VGG19
10
+ from .xception import Xception
11
+
12
+ __all__ = [
13
+ "VGG16",
14
+ "VGG19",
15
+ "ConvNeXtBase",
16
+ "ConvNeXtLarge",
17
+ "ConvNeXtSmall",
18
+ "ConvNeXtTiny",
19
+ "ConvNeXtXLarge",
20
+ "DenseNet121",
21
+ "DenseNet169",
22
+ "DenseNet201",
23
+ "EfficientNetB0",
24
+ "EfficientNetV2B0",
25
+ "EfficientNetV2L",
26
+ "EfficientNetV2M",
27
+ "EfficientNetV2S",
28
+ "MobileNet",
29
+ "MobileNetV2",
30
+ "MobileNetV3Large",
31
+ "MobileNetV3Small",
32
+ "ResNet50V2",
33
+ "ResNet101V2",
34
+ "ResNet152V2",
35
+ "SqueezeNet",
36
+ "Xception",
37
+ ]
38
+
@@ -1,62 +1,62 @@
1
- """ ConvNeXt models implementation.
2
-
3
- This module provides wrapper classes for the ConvNeXt family of models from the Keras applications.
4
- ConvNeXt models are a family of pure convolutional networks that match or outperform
5
- Vision Transformers (ViTs) while maintaining the simplicity and efficiency of CNNs.
6
-
7
- Available models:
8
-
9
- - ConvNeXtTiny: Smallest variant with fewer parameters for resource-constrained environments
10
- - ConvNeXtSmall: Compact model balancing performance and size
11
- - ConvNeXtBase: Standard model with good performance for general use cases
12
- - ConvNeXtLarge: Larger model with higher capacity for complex tasks
13
- - ConvNeXtXLarge: Largest variant with maximum capacity for demanding applications
14
-
15
- All models support transfer learning from ImageNet pre-trained weights.
16
- """
17
- # pyright: reportUnknownVariableType=false
18
- # pyright: reportMissingTypeStubs=false
19
-
20
- # Imports
21
- from __future__ import annotations
22
-
23
- from keras.models import Model
24
- from keras.src.applications.convnext import ConvNeXtBase as ConvNeXtBase_keras
25
- from keras.src.applications.convnext import ConvNeXtLarge as ConvNeXtLarge_keras
26
- from keras.src.applications.convnext import ConvNeXtSmall as ConvNeXtSmall_keras
27
- from keras.src.applications.convnext import ConvNeXtTiny as ConvNeXtTiny_keras
28
- from keras.src.applications.convnext import ConvNeXtXLarge as ConvNeXtXLarge_keras
29
-
30
- from ....decorators import simple_cache
31
- from ..base_keras import BaseKeras
32
- from ..model_interface import CLASS_ROUTINE_DOCSTRING, MODEL_DOCSTRING
33
-
34
-
35
- # Classes
36
- class ConvNeXtTiny(BaseKeras):
37
- def _get_base_model(self) -> Model:
38
- return ConvNeXtTiny_keras(include_top=False, classes=self.num_classes)
39
-
40
- class ConvNeXtSmall(BaseKeras):
41
- def _get_base_model(self) -> Model:
42
- return ConvNeXtSmall_keras(include_top=False, classes=self.num_classes)
43
-
44
- class ConvNeXtBase(BaseKeras):
45
- def _get_base_model(self) -> Model:
46
- return ConvNeXtBase_keras(include_top=False, classes=self.num_classes)
47
-
48
- class ConvNeXtLarge(BaseKeras):
49
- def _get_base_model(self) -> Model:
50
- return ConvNeXtLarge_keras(include_top=False, classes=self.num_classes)
51
-
52
- class ConvNeXtXLarge(BaseKeras):
53
- def _get_base_model(self) -> Model:
54
- return ConvNeXtXLarge_keras(include_top=False, classes=self.num_classes)
55
-
56
-
57
- # Docstrings
58
- for model in [ConvNeXtTiny, ConvNeXtSmall, ConvNeXtBase, ConvNeXtLarge, ConvNeXtXLarge]:
59
- model.__doc__ = MODEL_DOCSTRING.format(model=model.__name__)
60
- model.class_routine = simple_cache(model.class_routine)
61
- model.class_routine.__doc__ = CLASS_ROUTINE_DOCSTRING.format(model=model.__name__)
62
-
1
+ """ ConvNeXt models implementation.
2
+
3
+ This module provides wrapper classes for the ConvNeXt family of models from the Keras applications.
4
+ ConvNeXt models are a family of pure convolutional networks that match or outperform
5
+ Vision Transformers (ViTs) while maintaining the simplicity and efficiency of CNNs.
6
+
7
+ Available models:
8
+
9
+ - ConvNeXtTiny: Smallest variant with fewer parameters for resource-constrained environments
10
+ - ConvNeXtSmall: Compact model balancing performance and size
11
+ - ConvNeXtBase: Standard model with good performance for general use cases
12
+ - ConvNeXtLarge: Larger model with higher capacity for complex tasks
13
+ - ConvNeXtXLarge: Largest variant with maximum capacity for demanding applications
14
+
15
+ All models support transfer learning from ImageNet pre-trained weights.
16
+ """
17
+ # pyright: reportUnknownVariableType=false
18
+ # pyright: reportMissingTypeStubs=false
19
+
20
+ # Imports
21
+ from __future__ import annotations
22
+
23
+ from keras.models import Model
24
+ from keras.src.applications.convnext import ConvNeXtBase as ConvNeXtBase_keras
25
+ from keras.src.applications.convnext import ConvNeXtLarge as ConvNeXtLarge_keras
26
+ from keras.src.applications.convnext import ConvNeXtSmall as ConvNeXtSmall_keras
27
+ from keras.src.applications.convnext import ConvNeXtTiny as ConvNeXtTiny_keras
28
+ from keras.src.applications.convnext import ConvNeXtXLarge as ConvNeXtXLarge_keras
29
+
30
+ from ....decorators import simple_cache
31
+ from ..base_keras import BaseKeras
32
+ from ..model_interface import CLASS_ROUTINE_DOCSTRING, MODEL_DOCSTRING
33
+
34
+
35
+ # Classes
36
+ class ConvNeXtTiny(BaseKeras):
37
+ def _get_base_model(self) -> Model:
38
+ return ConvNeXtTiny_keras(include_top=False, classes=self.num_classes)
39
+
40
+ class ConvNeXtSmall(BaseKeras):
41
+ def _get_base_model(self) -> Model:
42
+ return ConvNeXtSmall_keras(include_top=False, classes=self.num_classes)
43
+
44
+ class ConvNeXtBase(BaseKeras):
45
+ def _get_base_model(self) -> Model:
46
+ return ConvNeXtBase_keras(include_top=False, classes=self.num_classes)
47
+
48
+ class ConvNeXtLarge(BaseKeras):
49
+ def _get_base_model(self) -> Model:
50
+ return ConvNeXtLarge_keras(include_top=False, classes=self.num_classes)
51
+
52
+ class ConvNeXtXLarge(BaseKeras):
53
+ def _get_base_model(self) -> Model:
54
+ return ConvNeXtXLarge_keras(include_top=False, classes=self.num_classes)
55
+
56
+
57
+ # Docstrings
58
+ for model in [ConvNeXtTiny, ConvNeXtSmall, ConvNeXtBase, ConvNeXtLarge, ConvNeXtXLarge]:
59
+ model.__doc__ = MODEL_DOCSTRING.format(model=model.__name__)
60
+ model.class_routine = simple_cache(model.class_routine)
61
+ model.class_routine.__doc__ = CLASS_ROUTINE_DOCSTRING.format(model=model.__name__)
62
+