Skip to content

Commit 6b4be33

Browse files
MechaCritterclaude
andcommitted
feat(encoders): deprecate loading from KMeansWeights/GMMWeights
Passing the weights enums to the encoder constructors now emits a DeprecationWarning; the enums and the loading path will be removed in a future release in favor of save_to_disk()/load_from_disk() with .encoder files. The enum docstrings carry the same notice. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 96f5b91 commit 6b4be33

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

pyvisim/encoders/_base_encoder.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ def load(self) -> object:
148148

149149

150150
class KMeansWeights(_PretrainedModels):
151+
"""
152+
Pretrained K-Means weights trained on the Oxford-102 flower dataset.
153+
154+
.. deprecated::
155+
Loading pretrained models via this enum is deprecated and will be
156+
removed in a future release. Use ``save_to_disk``/``load_from_disk``
157+
with ``.encoder`` files instead.
158+
"""
159+
151160
OXFORD102_K256_VGG16_PCA = (
152161
f"{PICKLE_MODEL_FILES_PATH}/k_means_k256_deep_features_vgg16_pca.pkl"
153162
)
@@ -173,6 +182,15 @@ class _PCA(_PretrainedModels):
173182

174183

175184
class GMMWeights(_PretrainedModels):
185+
"""
186+
Pretrained GMM weights trained on the Oxford-102 flower dataset.
187+
188+
.. deprecated::
189+
Loading pretrained models via this enum is deprecated and will be
190+
removed in a future release. Use ``save_to_disk``/``load_from_disk``
191+
with ``.encoder`` files instead.
192+
"""
193+
176194
OXFORD102_K256_VGG16_PCA = (
177195
f"{PICKLE_MODEL_FILES_PATH}/gmm_k256_deep_features_vgg16_pca.pkl"
178196
)
@@ -274,8 +292,18 @@ def _load_pretrained_weights(self, weights: KMeansWeights | GMMWeights) -> None:
274292
Loads a pretrained scikit-learn estimator (and its matching PCA,
275293
if any) into the encoder's clustering model class.
276294
295+
.. deprecated::
296+
Will be removed in a future release together with the weight enums.
297+
277298
:param weights: Pretrained weight enum member to load.
278299
"""
300+
warnings.warn(
301+
"Loading pretrained models via KMeansWeights/GMMWeights is "
302+
"deprecated and will be removed in a future release. Use "
303+
"save_to_disk()/load_from_disk() with .encoder files instead.",
304+
DeprecationWarning,
305+
stacklevel=3,
306+
)
279307
if "PCA" in weights.name:
280308
self.pca = PCA._from_sklearn(_CLUSTERING_TO_PCA_MAPPING[weights].load())
281309
self.clustering_model = self._clustering_model_cls._from_sklearn(weights.load())

0 commit comments

Comments
 (0)