Skip to content

Commit 3e11446

Browse files
Update weights_only handling
1 parent 0db92fc commit 3e11446

File tree

1 file changed

+2
-8
lines changed
  • synaptic_reconstruction/tools

1 file changed

+2
-8
lines changed

synaptic_reconstruction/tools/util.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import torch
66
import numpy as np
77
import pooch
8-
import warnings
98

109
from ..inference.vesicles import segment_vesicles
1110
from ..inference.mitochondria import segment_mitochondria
@@ -16,12 +15,7 @@ def load_custom_model(model_path: str, device: Optional[Union[str, torch.device]
1615
if device is None:
1716
device = get_device(device)
1817
try:
19-
warnings.filterwarnings(
20-
"ignore",
21-
message="You are using `torch.load` with `weights_only=False`",
22-
category=FutureWarning
23-
)
24-
model = torch.load(model_path, map_location=torch.device(device))
18+
model = torch.load(model_path, map_location=torch.device(device), weights_only=False)
2519
except Exception as e:
2620
print(e)
2721
print("model path", model_path)
@@ -57,7 +51,7 @@ def get_model(model_type: str, device: Optional[Union[str, torch.device]] = None
5751
if device is None:
5852
device = get_device(device)
5953
model_path = get_model_path(model_type)
60-
model = torch.load(model_path, weights_only=True)
54+
model = torch.load(model_path, weights_only=False)
6155
model.to(device)
6256
return model
6357

0 commit comments

Comments
 (0)