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

ModuleNotFoundError: No module named 'surface_distance' when running train.py #45

Open
Jeevan-Neupane opened this issue Mar 4, 2025 · 2 comments

Comments

@Jeevan-Neupane
Copy link
Contributor

Description:

When trying to run train.py, the script fails with a ModuleNotFoundError due to the missing surface_distance package. This issue occurs in the XrayTo3DShape/utils/callbacks.py file.

Steps to Reproduce:

python train.py configs/paths/femur/30k/TotalSegmentor-femur-left-DRR-30k_train+val.csv \
    configs/paths/femur/30k/TotalSegmentor-femur-left-DRR-30k_test.csv \
    --tags model-compare --size 128 --batch_size 4 --accelerator cpu \
    --res 1.0 --model_name MultiScale2DPermuteConcat --epochs 100 \
    --loss DiceLoss --lr 0.002 --steps 4000 --dropout

The script fails with the following traceback:

Traceback (most recent call last):
  File "train.py", line 28, in <module>
    import XrayTo3DShape
  File "/home/jeevan-neupane/xrayto3D-benchmark/XrayTo3DShape/__init__.py", line 7, in <module>
    from .utils.registry import import_all_modules_for_register
  File "/home/jeevan-neupane/xrayto3D-benchmark/XrayTo3DShape/utils/__init__.py", line 11, in <module>
    from .callbacks import *
  File "/home/jeevan-neupane/xrayto3D-benchmark/XrayTo3DShape/utils/callbacks.py", line 22, in <module>
    from surface_distance.metrics import (
ModuleNotFoundError: No module named 'surface_distance'

System Information:

OS:Ubuntu
Python Version:3.8

@Jeevan-Neupane
Copy link
Contributor Author

Inorder to solve this we have update benchmark-requirements-cpu.yaml to install surface-distance directly from github repo of
https://github.com/google-deepmind/surface-distance

Updated yaml file

name: xrayto3d
channels:
  - conda-forge
  - defaults
dependencies:
  - python=3.8
  - numpy
  - monai
  - torchvision
  - nibabel
  - itk
  - simpleitk
  - scikit-image
  - pillow
  - pandas
  - matplotlib
  - pytorch  # CPU version (no GPU)
  - wandb
  - tqdm
  - einops
  - pytorch-lightning
  - pip
  - git  # Required for cloning repositories
  - pip:
      - git+https://github.com/deepmind/surface-distance.git

@msrepo
Copy link
Collaborator

msrepo commented Mar 4, 2025

Please close this issue if it has been resolved and PR merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants