Closed jkh1 closed 7 months ago
Hi, I got the same issue and was about to report it. Fresh installation on a new workstation.
Hi Folks, Fresh install, getting the same error:
TypeError: The classmethod
SemanticSegmentationUnet.load_from_checkpointcannot be called on an instance. Please call it on the class type and make sure the return value is used
.
│ /membrain-seg/lib/python3.9/site-packages/pytorch_lightning/utilities/model_helpers.py:93 in get
│ 90 │ │ # Workaround for https://github.com/pytorch/pytorch/issues/67146 │
│ 91 │ │ is_scripting = any(os.path.join("torch", "jit") in frameinfo.filename for framei │
│ 92 │ │ if instance is not None and not is_scripting: │
│ ❱ 93 │ │ │ raise TypeError( │
│ 94 │ │ │ │ f"The classmethod {cls.__name__}.{self.method.__name__}
cannot be call │
│ 95 │ │ │ │ " Please call it on the class type and make sure the return value is use │
│ 96 │ │ │ ) │
Hi all, just to say I know that @LorenzLamm is away at the moment on holiday.
Not sure this ever worked, the correct API is to call the method on the class
model = ModelClass.load_from_checkpoint()
Easy fix if someone wants to open a PR
Thanks everyone who reported the issue. I managed to reproduce it in a fresh install. It looks like a recent update in pytorch-lightning (or some other dependency) broke our code.
My installation in an older environment works fine, so I post below the output of conda list
for that environment if anyone feels like playing with version matching.
Please bear with us while we work on a fix, which might take a couple days.
# packages in environment at /scicore/home/engel0006/GROUP/pool-engel/soft/membrain-seg/membrain-seg_env:
#
# Name Version Build Channel
_libgcc_mutex 0.1 main
_openmp_mutex 5.1 1_gnu
aiohttp 3.8.4 pypi_0 pypi
aiosignal 1.3.1 pypi_0 pypi
anyio 3.7.1 pypi_0 pypi
argon2-cffi 21.3.0 pypi_0 pypi
argon2-cffi-bindings 21.2.0 pypi_0 pypi
arrow 1.2.3 pypi_0 pypi
asttokens 2.2.1 pypi_0 pypi
async-lru 2.0.4 pypi_0 pypi
async-timeout 4.0.2 pypi_0 pypi
attrs 23.1.0 pypi_0 pypi
babel 2.12.1 pypi_0 pypi
backcall 0.2.0 pypi_0 pypi
beautifulsoup4 4.12.2 pypi_0 pypi
bleach 6.0.0 pypi_0 pypi
ca-certificates 2023.05.30 h06a4308_0
certifi 2023.5.7 pypi_0 pypi
cffi 1.15.1 pypi_0 pypi
charset-normalizer 3.1.0 pypi_0 pypi
click 8.1.3 pypi_0 pypi
cmake 3.26.4 pypi_0 pypi
colorama 0.4.6 pypi_0 pypi
comm 0.1.4 pypi_0 pypi
debugpy 1.6.7.post1 pypi_0 pypi
decorator 5.1.1 pypi_0 pypi
defusedxml 0.7.1 pypi_0 pypi
exceptiongroup 1.1.2 pypi_0 pypi
executing 1.2.0 pypi_0 pypi
fastjsonschema 2.18.0 pypi_0 pypi
filelock 3.12.2 pypi_0 pypi
fqdn 1.5.1 pypi_0 pypi
frozenlist 1.3.3 pypi_0 pypi
fsspec 2023.6.0 pypi_0 pypi
idna 3.4 pypi_0 pypi
imageio 2.31.1 pypi_0 pypi
importlib-metadata 6.8.0 pypi_0 pypi
ipykernel 6.25.1 pypi_0 pypi
ipython 8.14.0 pypi_0 pypi
isoduration 20.11.0 pypi_0 pypi
jedi 0.19.0 pypi_0 pypi
jinja2 3.1.2 pypi_0 pypi
json5 0.9.14 pypi_0 pypi
jsonpointer 2.4 pypi_0 pypi
jsonschema 4.19.0 pypi_0 pypi
jsonschema-specifications 2023.7.1 pypi_0 pypi
jupyter-client 8.3.0 pypi_0 pypi
jupyter-core 5.3.1 pypi_0 pypi
jupyter-events 0.7.0 pypi_0 pypi
jupyter-lsp 2.2.0 pypi_0 pypi
jupyter-server 2.7.0 pypi_0 pypi
jupyter-server-terminals 0.4.4 pypi_0 pypi
jupyterlab 4.0.4 pypi_0 pypi
jupyterlab-pygments 0.2.2 pypi_0 pypi
jupyterlab-server 2.24.0 pypi_0 pypi
lazy-loader 0.2 pypi_0 pypi
ld_impl_linux-64 2.38 h1181459_1
libffi 3.4.4 h6a678d5_0
libgcc-ng 11.2.0 h1234567_1
libgomp 11.2.0 h1234567_1
libstdcxx-ng 11.2.0 h1234567_1
lightning-utilities 0.8.0 pypi_0 pypi
lit 16.0.6 pypi_0 pypi
markdown-it-py 3.0.0 pypi_0 pypi
markupsafe 2.1.3 pypi_0 pypi
matplotlib-inline 0.1.6 pypi_0 pypi
mdurl 0.1.2 pypi_0 pypi
membrain-seg 0.1.dev44+gc132a79 pypi_0 pypi
mistune 3.0.1 pypi_0 pypi
monai 1.2.0 pypi_0 pypi
mpmath 1.3.0 pypi_0 pypi
mrcfile 1.4.3 pypi_0 pypi
multidict 6.0.4 pypi_0 pypi
nbclient 0.8.0 pypi_0 pypi
nbconvert 7.7.3 pypi_0 pypi
nbformat 5.9.2 pypi_0 pypi
ncurses 6.4 h6a678d5_0
nest-asyncio 1.5.7 pypi_0 pypi
networkx 3.1 pypi_0 pypi
notebook 7.0.2 pypi_0 pypi
notebook-shim 0.2.3 pypi_0 pypi
numexpr 2.8.5 pypi_0 pypi
numpy 1.25.0 pypi_0 pypi
nvidia-cublas-cu11 11.10.3.66 pypi_0 pypi
nvidia-cuda-cupti-cu11 11.7.101 pypi_0 pypi
nvidia-cuda-nvrtc-cu11 11.7.99 pypi_0 pypi
nvidia-cuda-runtime-cu11 11.7.99 pypi_0 pypi
nvidia-cudnn-cu11 8.5.0.96 pypi_0 pypi
nvidia-cufft-cu11 10.9.0.58 pypi_0 pypi
nvidia-curand-cu11 10.2.10.91 pypi_0 pypi
nvidia-cusolver-cu11 11.4.0.1 pypi_0 pypi
nvidia-cusparse-cu11 11.7.4.91 pypi_0 pypi
nvidia-nccl-cu11 2.14.3 pypi_0 pypi
nvidia-nvtx-cu11 11.7.91 pypi_0 pypi
openssl 3.0.8 h7f8727e_0
overrides 7.4.0 pypi_0 pypi
packaging 23.1 pypi_0 pypi
pandas 2.0.3 pypi_0 pypi
pandocfilters 1.5.0 pypi_0 pypi
parso 0.8.3 pypi_0 pypi
pexpect 4.8.0 pypi_0 pypi
pickleshare 0.7.5 pypi_0 pypi
pillow 9.5.0 pypi_0 pypi
pip 23.1.2 py39h06a4308_0
platformdirs 3.10.0 pypi_0 pypi
prometheus-client 0.17.1 pypi_0 pypi
prompt-toolkit 3.0.39 pypi_0 pypi
psutil 5.9.5 pypi_0 pypi
ptyprocess 0.7.0 pypi_0 pypi
pure-eval 0.2.2 pypi_0 pypi
pycparser 2.21 pypi_0 pypi
pygments 2.15.1 pypi_0 pypi
python 3.9.16 h955ad1f_3
python-dateutil 2.8.2 pypi_0 pypi
python-json-logger 2.0.7 pypi_0 pypi
pytorch-lightning 2.0.3 pypi_0 pypi
pytz 2023.3 pypi_0 pypi
pywavelets 1.4.1 pypi_0 pypi
pyyaml 6.0 pypi_0 pypi
pyzmq 25.1.1 pypi_0 pypi
readline 8.2 h5eee18b_0
referencing 0.30.2 pypi_0 pypi
requests 2.31.0 pypi_0 pypi
rfc3339-validator 0.1.4 pypi_0 pypi
rfc3986-validator 0.1.1 pypi_0 pypi
rich 13.4.2 pypi_0 pypi
rpds-py 0.9.2 pypi_0 pypi
scikit-image 0.21.0 pypi_0 pypi
scipy 1.10.1 pypi_0 pypi
send2trash 1.8.2 pypi_0 pypi
setuptools 67.8.0 py39h06a4308_0
shellingham 1.5.0.post1 pypi_0 pypi
simpleitk 2.2.1 pypi_0 pypi
six 1.16.0 pypi_0 pypi
sniffio 1.3.0 pypi_0 pypi
soupsieve 2.4.1 pypi_0 pypi
sqlite 3.41.2 h5eee18b_0
stack-data 0.6.2 pypi_0 pypi
sympy 1.12 pypi_0 pypi
terminado 0.17.1 pypi_0 pypi
tifffile 2023.4.12 pypi_0 pypi
tinycss2 1.2.1 pypi_0 pypi
tk 8.6.12 h1ccaba5_0
tomli 2.0.1 pypi_0 pypi
torch 2.0.1 pypi_0 pypi
torchmetrics 0.11.4 pypi_0 pypi
tornado 6.3.2 pypi_0 pypi
tqdm 4.65.0 pypi_0 pypi
traitlets 5.9.0 pypi_0 pypi
triton 2.0.0 pypi_0 pypi
typer 0.9.0 pypi_0 pypi
typing-extensions 4.6.3 pypi_0 pypi
tzdata 2023.3 pypi_0 pypi
uri-template 1.3.0 pypi_0 pypi
urllib3 2.0.3 pypi_0 pypi
wcwidth 0.2.6 pypi_0 pypi
webcolors 1.13 pypi_0 pypi
webencodings 0.5.1 pypi_0 pypi
websocket-client 1.6.1 pypi_0 pypi
wheel 0.38.4 py39h06a4308_0
xz 5.4.2 h5eee18b_0
yarl 1.9.2 pypi_0 pypi
zipp 3.16.2 pypi_0 pypi
zlib 1.2.13 h5eee18b_0
Hi everyone, Thanks a lot for reporting this issue and really sorry for the delay on fixing this. The issue was a mix of new versions of Pytorch-lightning and MONAI. In our new PR (https://github.com/teamtomo/membrain-seg/pull/41), we have fixed this issue.
So if you now git pull
the latest version of the repository and re-install MemBrain-seg, it should work normally again.
I'll leave this issue open for a couple of days in case a problem comes up.
Just to confirm that it's all good on my side. Thanks.
Great, thanks for the feedback. Closing this issue now.
Just cloned the repo and installation went fine. Now testing
membrain segment --tomogram-path some_tomo_gram.mrc --ckpt-path MemBrain_seg_v9b.ckpt
produces this error:
TypeError: The classmethod
SemanticSegmentationUnet.load_from_checkpointcannot be called on an instance. Please call it on the class type and make sure the return value is used.
coming from membrain_seg/segmentation/segment.py:82 in segmentIs this a bug or am I doing something wrong here?