Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/brainways/model/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ def load_model(model_dir: Path) -> SiameseModel:

# Load state dict
state_dict_path = model_dir / "state_dict.pt"
state_dict = torch.load(state_dict_path, weights_only=True)
state_dict = torch.load(
state_dict_path,
map_location="cpu",
weights_only=True,
)
model.load_state_dict(state_dict)

# Set model to evaluation mode and move to GPU
model.eval()
model.to("cuda")

# Move model to GPU if available
if torch.cuda.is_available():
model.to("cuda")

return model
8 changes: 8 additions & 0 deletions src/brainways/utils/_tests/test_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from brainways.utils.setup import BrainwaysSetup


def test_setup():
BrainwaysSetup(
atlas_names=["whs_sd_rat_39um", "allen_mouse_25um"],
progress_callback=lambda x: None,
).run()