[Bugfix] Fix missing return value in load_weights method of adapters.py (#15542)

Signed-off-by: noc-turne <2270929247@qq.com>
This commit is contained in:
Mrm 2025-03-31 21:56:42 +08:00 committed by GitHub
parent c2e7507ad4
commit 037bcd942c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -99,16 +99,17 @@ def _create_pooling_model_cls(
mapper = WeightsMapper(orig_to_new_prefix={"model.": ""})
weights = mapper.apply(weights)
self.model.load_weights(weights)
return
loaded_params = self.model.load_weights(weights)
loaded_params = {f"model.{name}" for name in loaded_params}
return loaded_params
# For most other models
if hasattr(orig_cls, "load_weights"):
orig_cls.load_weights(self, weights) # type: ignore
return orig_cls.load_weights(self, weights) # type: ignore
# Fallback
else:
loader = AutoWeightsLoader(self)
loader.load_weights(weights)
return loader.load_weights(weights)
return ModelForPooling # type: ignore