Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: explicitly set weights_only to avoid FutureWarning #193

Merged
merged 6 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 2 additions & 1 deletion doc/changes/authors.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.. _Adam Li: https://github.com/adam2392
.. _Mathieu Scheltienne: https://github.com/mscheltienne
.. _Jacob Feitelberg: https://github.com/jacobf18
.. _Anand Saini: https://github.com/anandsaini024
.. _Anand Saini: https://github.com/anandsaini024
.. _Scott Huberty: https://github.com/scott-huberty
1 change: 1 addition & 0 deletions doc/changes/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ Version 0.7
===========

- Raise helpful error message when montage is incomplete (:pr:`181` by `Mathieu Scheltienne`_)
- Explicitly pass ``weights_only=False`` in all instances of ``torch.load`` used by mne-icalabel, to suppress a warning in PyTorch 2.4 (:pr:`193` by `Scott Huberty`_)
4 changes: 2 additions & 2 deletions mne_icalabel/iclabel/network/tests/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@

def test_weights_pytorch():
"""Compare the weights of pytorch model and matconvnet model."""
network_python = torch.load(torch_iclabel_path)
network_matlab = loadmat(matconvnet_iclabel_path)
network_python = torch.load(torch_iclabel_path, weights_only=False)
network_matlab = loadmat(matconvnet_iclabel_path, weights_only=False)
mscheltienne marked this conversation as resolved.
Show resolved Hide resolved

# load weights from matlab network
weights_matlab = network_matlab["params"]["value"][0, :]
Expand Down
2 changes: 1 addition & 1 deletion mne_icalabel/iclabel/network/torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def _run_iclabel(images: ArrayLike, psds: ArrayLike, autocorr: ArrayLike) -> NDA
# load weights
network_file = files("mne_icalabel.iclabel.network") / "assets" / "ICLabelNet.pt"
iclabel_net = ICLabelNet()
iclabel_net.load_state_dict(torch.load(network_file))
iclabel_net.load_state_dict(torch.load(network_file, weights_only=False))
# format inputs and run forward pass
labels = iclabel_net(
*_format_input_for_torch(*_format_input(images, psds, autocorr))
Expand Down
Loading