Skip to content

Commit

Permalink
Fix redownloading issue (#54)
Browse files Browse the repository at this point in the history
* Fix redownloading issue.

* Fix CI
  • Loading branch information
james77777778 authored Oct 20, 2024
1 parent ec8e096 commit cf61558
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion kimm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
from kimm._src.utils.model_registry import list_models
from kimm._src.version import version

__version__ = "0.2.3"
__version__ = "0.2.4"
4 changes: 2 additions & 2 deletions kimm/_src/layers/learnable_affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ def __init__(self, scale_value=1.0, bias_value=0.0, **kwargs):

def build(self, input_shape):
self.scale = self.add_weight(
shape=(1,),
shape=(),
initializer=lambda shape, dtype: ops.cast(self.scale_value, dtype),
trainable=True,
name="scale",
)
self.bias = self.add_weight(
shape=(1,),
shape=(),
initializer=lambda shape, dtype: ops.cast(self.bias_value, dtype),
trainable=True,
name="bias",
Expand Down
3 changes: 2 additions & 1 deletion kimm/_src/models/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,11 @@ def get_config(self):
"dropout_rate": self._dropout_rate,
"classes": self._classes,
"classifier_activation": self._classifier_activation,
"weights": self._weights,
# feature extractor
"feature_extractor": self._feature_extractor,
"feature_keys": self._feature_keys,
# Set `self._weight` to `None` to avoid redownloading issue.
"weights": None,
}
return config

Expand Down
5 changes: 5 additions & 0 deletions kimm/_src/models/models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ def test_weights_invalid_string(self):
):
SampleModel(weights="imagenet123")

def test_weights_none_in_config(self):
model = SampleModel()
config = model.get_config()
self.assertIsNone(config["weights"])


# Test some small models

Expand Down
2 changes: 1 addition & 1 deletion kimm/_src/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from kimm._src.kimm_export import kimm_export

__version__ = "0.2.3"
__version__ = "0.2.4"


@kimm_export("kimm")
Expand Down

0 comments on commit cf61558

Please sign in to comment.