stouputils 1.14.3__py3-none-any.whl → 1.15.0__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 (78) hide show
  1. stouputils/data_science/config/get.py +51 -51
  2. stouputils/data_science/data_processing/image/__init__.py +66 -66
  3. stouputils/data_science/data_processing/image/auto_contrast.py +79 -79
  4. stouputils/data_science/data_processing/image/axis_flip.py +58 -58
  5. stouputils/data_science/data_processing/image/bias_field_correction.py +74 -74
  6. stouputils/data_science/data_processing/image/binary_threshold.py +73 -73
  7. stouputils/data_science/data_processing/image/blur.py +59 -59
  8. stouputils/data_science/data_processing/image/brightness.py +54 -54
  9. stouputils/data_science/data_processing/image/canny.py +110 -110
  10. stouputils/data_science/data_processing/image/clahe.py +92 -92
  11. stouputils/data_science/data_processing/image/common.py +30 -30
  12. stouputils/data_science/data_processing/image/contrast.py +53 -53
  13. stouputils/data_science/data_processing/image/curvature_flow_filter.py +74 -74
  14. stouputils/data_science/data_processing/image/denoise.py +378 -378
  15. stouputils/data_science/data_processing/image/histogram_equalization.py +123 -123
  16. stouputils/data_science/data_processing/image/invert.py +64 -64
  17. stouputils/data_science/data_processing/image/laplacian.py +60 -60
  18. stouputils/data_science/data_processing/image/median_blur.py +52 -52
  19. stouputils/data_science/data_processing/image/noise.py +59 -59
  20. stouputils/data_science/data_processing/image/normalize.py +65 -65
  21. stouputils/data_science/data_processing/image/random_erase.py +66 -66
  22. stouputils/data_science/data_processing/image/resize.py +69 -69
  23. stouputils/data_science/data_processing/image/rotation.py +80 -80
  24. stouputils/data_science/data_processing/image/salt_pepper.py +68 -68
  25. stouputils/data_science/data_processing/image/sharpening.py +55 -55
  26. stouputils/data_science/data_processing/image/shearing.py +64 -64
  27. stouputils/data_science/data_processing/image/threshold.py +64 -64
  28. stouputils/data_science/data_processing/image/translation.py +71 -71
  29. stouputils/data_science/data_processing/image/zoom.py +83 -83
  30. stouputils/data_science/data_processing/image_augmentation.py +118 -118
  31. stouputils/data_science/data_processing/image_preprocess.py +183 -183
  32. stouputils/data_science/data_processing/prosthesis_detection.py +359 -359
  33. stouputils/data_science/data_processing/technique.py +481 -481
  34. stouputils/data_science/dataset/__init__.py +45 -45
  35. stouputils/data_science/dataset/dataset.py +292 -292
  36. stouputils/data_science/dataset/dataset_loader.py +135 -135
  37. stouputils/data_science/dataset/grouping_strategy.py +296 -296
  38. stouputils/data_science/dataset/image_loader.py +100 -100
  39. stouputils/data_science/dataset/xy_tuple.py +696 -696
  40. stouputils/data_science/metric_dictionnary.py +106 -106
  41. stouputils/data_science/mlflow_utils.py +206 -206
  42. stouputils/data_science/models/abstract_model.py +149 -149
  43. stouputils/data_science/models/all.py +85 -85
  44. stouputils/data_science/models/keras/all.py +38 -38
  45. stouputils/data_science/models/keras/convnext.py +62 -62
  46. stouputils/data_science/models/keras/densenet.py +50 -50
  47. stouputils/data_science/models/keras/efficientnet.py +60 -60
  48. stouputils/data_science/models/keras/mobilenet.py +56 -56
  49. stouputils/data_science/models/keras/resnet.py +52 -52
  50. stouputils/data_science/models/keras/squeezenet.py +233 -233
  51. stouputils/data_science/models/keras/vgg.py +42 -42
  52. stouputils/data_science/models/keras/xception.py +38 -38
  53. stouputils/data_science/models/keras_utils/callbacks/__init__.py +20 -20
  54. stouputils/data_science/models/keras_utils/callbacks/colored_progress_bar.py +219 -219
  55. stouputils/data_science/models/keras_utils/callbacks/learning_rate_finder.py +148 -148
  56. stouputils/data_science/models/keras_utils/callbacks/model_checkpoint_v2.py +31 -31
  57. stouputils/data_science/models/keras_utils/callbacks/progressive_unfreezing.py +249 -249
  58. stouputils/data_science/models/keras_utils/callbacks/warmup_scheduler.py +66 -66
  59. stouputils/data_science/models/keras_utils/losses/__init__.py +12 -12
  60. stouputils/data_science/models/keras_utils/losses/next_generation_loss.py +56 -56
  61. stouputils/data_science/models/keras_utils/visualizations.py +416 -416
  62. stouputils/data_science/models/sandbox.py +116 -116
  63. stouputils/data_science/range_tuple.py +234 -234
  64. stouputils/data_science/utils.py +285 -285
  65. stouputils/decorators.py +53 -39
  66. stouputils/decorators.pyi +2 -2
  67. stouputils/installer/__init__.py +18 -18
  68. stouputils/installer/linux.py +144 -144
  69. stouputils/installer/main.py +223 -223
  70. stouputils/installer/windows.py +136 -136
  71. stouputils/io.py +16 -9
  72. stouputils/print.py +229 -2
  73. stouputils/print.pyi +90 -1
  74. stouputils/py.typed +1 -1
  75. {stouputils-1.14.3.dist-info → stouputils-1.15.0.dist-info}/METADATA +1 -1
  76. {stouputils-1.14.3.dist-info → stouputils-1.15.0.dist-info}/RECORD +78 -78
  77. {stouputils-1.14.3.dist-info → stouputils-1.15.0.dist-info}/WHEEL +1 -1
  78. {stouputils-1.14.3.dist-info → stouputils-1.15.0.dist-info}/entry_points.txt +0 -0
@@ -1,116 +1,116 @@
1
- """ Sandbox model implementation. (Where I try strange things)
2
-
3
- Tested:
4
-
5
- - ConvNeXtBase with input_shape=(1024, 1024, 3)
6
- - Custom CNN architecture for implant classification (fixed / not fixed)
7
-
8
- """
9
-
10
- # pyright: reportUnknownArgumentType=false
11
- # pyright: reportUnknownVariableType=false
12
- # pyright: reportMissingTypeStubs=false
13
-
14
- # Imports
15
- from __future__ import annotations
16
-
17
- from keras.layers import (
18
- BatchNormalization,
19
- Conv2D,
20
- Input,
21
- MaxPooling2D,
22
- SpatialDropout2D,
23
- )
24
- from keras.models import Model
25
-
26
- from ...print import warning
27
- from ...decorators import simple_cache
28
- from .base_keras import BaseKeras
29
- from .model_interface import CLASS_ROUTINE_DOCSTRING, MODEL_DOCSTRING
30
-
31
-
32
- class Sandbox(BaseKeras):
33
- def _get_base_model(self) -> Model:
34
- return self.custom_architecture()
35
-
36
- def custom_architecture(self) -> Model:
37
- """ Create a custom architecture for implant classification.
38
-
39
- This model uses a series of convolutional blocks with increasing depth,
40
- batch normalization, spatial and regular dropout for regularization.
41
- It's designed to detect features relevant to implant fixation status.
42
-
43
- Note: This is a custom architecture that does not use transfer learning.
44
- The transfer_learning attribute is ignored.
45
-
46
- Returns:
47
- Model: A Keras model without top layers for implant classification
48
- """
49
- if self.transfer_learning != "":
50
- warning(
51
- f"Transfer learning '{self.transfer_learning}' specified but not supported for custom architecture. "
52
- f"Using a model trained from scratch instead."
53
- )
54
-
55
- # Default input shape based on dataset loading defaults (224x224x3)
56
- input_shape: tuple[int, int, int] = (224, 224, 3)
57
-
58
- # Input layer
59
- inputs = Input(shape=input_shape)
60
-
61
- # Block 1: Initial feature extraction
62
- x = Conv2D(64, (3, 3), activation="relu", padding="same", name="block1_conv1")(inputs)
63
- x = BatchNormalization()(x)
64
- x = Conv2D(64, (3, 3), activation="relu", padding="same", name="block1_conv2")(x)
65
- x = BatchNormalization()(x)
66
- x = MaxPooling2D((2, 2), strides=(2, 2), name="block1_pool")(x)
67
- x = SpatialDropout2D(0.1)(x)
68
-
69
- # Block 2: Intermediate features
70
- x = Conv2D(128, (3, 3), activation="relu", padding="same", name="block2_conv1")(x)
71
- x = BatchNormalization()(x)
72
- x = Conv2D(128, (3, 3), activation="relu", padding="same", name="block2_conv2")(x)
73
- x = BatchNormalization()(x)
74
- x = MaxPooling2D((2, 2), strides=(2, 2), name="block2_pool")(x)
75
- x = SpatialDropout2D(0.1)(x)
76
-
77
- # Block 3: More complex features
78
- x = Conv2D(256, (3, 3), activation="relu", padding="same", name="block3_conv1")(x)
79
- x = BatchNormalization()(x)
80
- x = Conv2D(256, (3, 3), activation="relu", padding="same", name="block3_conv2")(x)
81
- x = BatchNormalization()(x)
82
- x = Conv2D(256, (3, 3), activation="relu", padding="same", name="block3_conv3")(x)
83
- x = BatchNormalization()(x)
84
- x = MaxPooling2D((2, 2), strides=(2, 2), name="block3_pool")(x)
85
- x = SpatialDropout2D(0.1)(x)
86
-
87
- # Block 4: Deep features
88
- x = Conv2D(512, (3, 3), activation="relu", padding="same", name="block4_conv1")(x)
89
- x = BatchNormalization()(x)
90
- x = Conv2D(512, (3, 3), activation="relu", padding="same", name="block4_conv2")(x)
91
- x = BatchNormalization()(x)
92
- x = Conv2D(512, (3, 3), activation="relu", padding="same", name="block4_conv3")(x)
93
- x = BatchNormalization()(x)
94
- x = MaxPooling2D((2, 2), strides=(2, 2), name="block4_pool")(x)
95
- x = SpatialDropout2D(0.1)(x)
96
-
97
- # Block 5: High-level abstract features
98
- x = Conv2D(512, (3, 3), activation="relu", padding="same", name="block5_conv1")(x)
99
- x = BatchNormalization()(x)
100
- x = Conv2D(512, (3, 3), activation="relu", padding="same", name="block5_conv2")(x)
101
- x = BatchNormalization()(x)
102
- x = Conv2D(512, (3, 3), activation="relu", padding="same", name="block5_conv3")(x)
103
- x = BatchNormalization()(x)
104
-
105
- # Create the model
106
- model = Model(inputs, x, name="implant_classifier")
107
-
108
- return model
109
-
110
-
111
- # Docstrings
112
- for model in [Sandbox]:
113
- model.__doc__ = MODEL_DOCSTRING.format(model=model.__name__)
114
- model.class_routine = simple_cache(model.class_routine)
115
- model.class_routine.__doc__ = CLASS_ROUTINE_DOCSTRING.format(model=model.__name__)
116
-
1
+ """ Sandbox model implementation. (Where I try strange things)
2
+
3
+ Tested:
4
+
5
+ - ConvNeXtBase with input_shape=(1024, 1024, 3)
6
+ - Custom CNN architecture for implant classification (fixed / not fixed)
7
+
8
+ """
9
+
10
+ # pyright: reportUnknownArgumentType=false
11
+ # pyright: reportUnknownVariableType=false
12
+ # pyright: reportMissingTypeStubs=false
13
+
14
+ # Imports
15
+ from __future__ import annotations
16
+
17
+ from keras.layers import (
18
+ BatchNormalization,
19
+ Conv2D,
20
+ Input,
21
+ MaxPooling2D,
22
+ SpatialDropout2D,
23
+ )
24
+ from keras.models import Model
25
+
26
+ from ...print import warning
27
+ from ...decorators import simple_cache
28
+ from .base_keras import BaseKeras
29
+ from .model_interface import CLASS_ROUTINE_DOCSTRING, MODEL_DOCSTRING
30
+
31
+
32
+ class Sandbox(BaseKeras):
33
+ def _get_base_model(self) -> Model:
34
+ return self.custom_architecture()
35
+
36
+ def custom_architecture(self) -> Model:
37
+ """ Create a custom architecture for implant classification.
38
+
39
+ This model uses a series of convolutional blocks with increasing depth,
40
+ batch normalization, spatial and regular dropout for regularization.
41
+ It's designed to detect features relevant to implant fixation status.
42
+
43
+ Note: This is a custom architecture that does not use transfer learning.
44
+ The transfer_learning attribute is ignored.
45
+
46
+ Returns:
47
+ Model: A Keras model without top layers for implant classification
48
+ """
49
+ if self.transfer_learning != "":
50
+ warning(
51
+ f"Transfer learning '{self.transfer_learning}' specified but not supported for custom architecture. "
52
+ f"Using a model trained from scratch instead."
53
+ )
54
+
55
+ # Default input shape based on dataset loading defaults (224x224x3)
56
+ input_shape: tuple[int, int, int] = (224, 224, 3)
57
+
58
+ # Input layer
59
+ inputs = Input(shape=input_shape)
60
+
61
+ # Block 1: Initial feature extraction
62
+ x = Conv2D(64, (3, 3), activation="relu", padding="same", name="block1_conv1")(inputs)
63
+ x = BatchNormalization()(x)
64
+ x = Conv2D(64, (3, 3), activation="relu", padding="same", name="block1_conv2")(x)
65
+ x = BatchNormalization()(x)
66
+ x = MaxPooling2D((2, 2), strides=(2, 2), name="block1_pool")(x)
67
+ x = SpatialDropout2D(0.1)(x)
68
+
69
+ # Block 2: Intermediate features
70
+ x = Conv2D(128, (3, 3), activation="relu", padding="same", name="block2_conv1")(x)
71
+ x = BatchNormalization()(x)
72
+ x = Conv2D(128, (3, 3), activation="relu", padding="same", name="block2_conv2")(x)
73
+ x = BatchNormalization()(x)
74
+ x = MaxPooling2D((2, 2), strides=(2, 2), name="block2_pool")(x)
75
+ x = SpatialDropout2D(0.1)(x)
76
+
77
+ # Block 3: More complex features
78
+ x = Conv2D(256, (3, 3), activation="relu", padding="same", name="block3_conv1")(x)
79
+ x = BatchNormalization()(x)
80
+ x = Conv2D(256, (3, 3), activation="relu", padding="same", name="block3_conv2")(x)
81
+ x = BatchNormalization()(x)
82
+ x = Conv2D(256, (3, 3), activation="relu", padding="same", name="block3_conv3")(x)
83
+ x = BatchNormalization()(x)
84
+ x = MaxPooling2D((2, 2), strides=(2, 2), name="block3_pool")(x)
85
+ x = SpatialDropout2D(0.1)(x)
86
+
87
+ # Block 4: Deep features
88
+ x = Conv2D(512, (3, 3), activation="relu", padding="same", name="block4_conv1")(x)
89
+ x = BatchNormalization()(x)
90
+ x = Conv2D(512, (3, 3), activation="relu", padding="same", name="block4_conv2")(x)
91
+ x = BatchNormalization()(x)
92
+ x = Conv2D(512, (3, 3), activation="relu", padding="same", name="block4_conv3")(x)
93
+ x = BatchNormalization()(x)
94
+ x = MaxPooling2D((2, 2), strides=(2, 2), name="block4_pool")(x)
95
+ x = SpatialDropout2D(0.1)(x)
96
+
97
+ # Block 5: High-level abstract features
98
+ x = Conv2D(512, (3, 3), activation="relu", padding="same", name="block5_conv1")(x)
99
+ x = BatchNormalization()(x)
100
+ x = Conv2D(512, (3, 3), activation="relu", padding="same", name="block5_conv2")(x)
101
+ x = BatchNormalization()(x)
102
+ x = Conv2D(512, (3, 3), activation="relu", padding="same", name="block5_conv3")(x)
103
+ x = BatchNormalization()(x)
104
+
105
+ # Create the model
106
+ model = Model(inputs, x, name="implant_classifier")
107
+
108
+ return model
109
+
110
+
111
+ # Docstrings
112
+ for model in [Sandbox]:
113
+ model.__doc__ = MODEL_DOCSTRING.format(model=model.__name__)
114
+ model.class_routine = simple_cache(model.class_routine)
115
+ model.class_routine.__doc__ = CLASS_ROUTINE_DOCSTRING.format(model=model.__name__)
116
+