Spaces:
Runtime error
Runtime error
Update src/sbv2/utils.py
Browse files- src/sbv2/utils.py +7 -12
src/sbv2/utils.py
CHANGED
@@ -1,12 +1,7 @@
|
|
1 |
-
import
|
2 |
-
|
3 |
-
def load_checkpoint(filepath, model,
|
4 |
-
print(f"Loading checkpoint: {filepath}")
|
5 |
-
checkpoint_dict =
|
6 |
-
model.load_state_dict(checkpoint_dict
|
7 |
-
|
8 |
-
if optimizer is not None and "optimizer" in checkpoint_dict:
|
9 |
-
optimizer.load_state_dict(checkpoint_dict["optimizer"])
|
10 |
-
|
11 |
-
print("Checkpoint loaded.")
|
12 |
-
return model
|
|
|
1 |
+
from safetensors.torch import load_file
|
2 |
+
|
3 |
+
def load_checkpoint(filepath, model, strict=True):
|
4 |
+
print(f"Loading checkpoint: {filepath}")
|
5 |
+
checkpoint_dict = load_file(filepath)
|
6 |
+
model.load_state_dict(checkpoint_dict, strict=strict)
|
7 |
+
return model
|
|
|
|
|
|
|
|
|
|