Giter Site home page Giter Site logo

Comments (14)

patriciacs1994 avatar patriciacs1994 commented on August 20, 2024 1

Hi @luozuo,
I solved it.
What I did is create a new environment in Anaconda AGAIN, and execute the following line:
pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI (now it worked)
Later I installed everything I needed.

But, when I tried to run the code in a jupyter notebook the same error showed up, so I executed again this:
pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI

and problem solved.

from tutorials.

Nic-Ma avatar Nic-Ma commented on August 20, 2024

Hi @Sebagam ,

I think you are using MONAI 0.3 and run the example in 0.3 tag.
Could you please help uninstall and use the below command to install again?

pip install -q "monai[itk]"

Thanks.

from tutorials.

Sebagam avatar Sebagam commented on August 20, 2024

Thanks, now Monai recognizes ITK.

However, now I get this error while executing that tutorial:


ValueError Traceback (most recent call last)
in ()
33 check_ds = NiftiDataset(image_files=images, labels=labels, transform=train_transforms)
34 check_loader = DataLoader(check_ds, batch_size=2, num_workers=2, pin_memory=torch.cuda.is_available())
---> 35 im, label = monai.utils.misc.first(check_loader)
36 print(type(im), im.shape, label)
37

4 frames
/usr/local/lib/python3.6/dist-packages/torch/_utils.py in reraise(self)
426 # have message field
427 raise self.exc_type(message=msg)
--> 428 raise self.exc_type(msg)
429
430

ValueError: Caught ValueError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/monai/transforms/utils.py", line 309, in apply_transform
return transform(data)
File "/usr/local/lib/python3.6/dist-packages/monai/transforms/spatial/array.py", line 360, in call
align_corners=self.align_corners if align_corners is None else align_corners,
File "/usr/local/lib/python3.6/dist-packages/monai/transforms/spatial/array.py", line 54, in _torch_interp
return torch.nn.functional.interpolate(recompute_scale_factor=True, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py", line 3110, in interpolate
raise ValueError("recompute_scale_factor is not meaningful with an explicit size.")
ValueError: recompute_scale_factor is not meaningful with an explicit size.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/monai/transforms/utils.py", line 309, in apply_transform
return transform(data)
File "/usr/local/lib/python3.6/dist-packages/monai/transforms/compose.py", line 233, in call
input_ = apply_transform(transform, input)
File "/usr/local/lib/python3.6/dist-packages/monai/transforms/utils.py", line 311, in apply_transform
raise type(e)(f"Applying transform {transform}.").with_traceback(e.traceback)
File "/usr/local/lib/python3.6/dist-packages/monai/transforms/utils.py", line 309, in apply_transform
return transform(data)
File "/usr/local/lib/python3.6/dist-packages/monai/transforms/spatial/array.py", line 360, in call
align_corners=self.align_corners if align_corners is None else align_corners,
File "/usr/local/lib/python3.6/dist-packages/monai/transforms/spatial/array.py", line 54, in _torch_interp
return torch.nn.functional.interpolate(recompute_scale_factor=True, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py", line 3110, in interpolate
raise ValueError("recompute_scale_factor is not meaningful with an explicit size.")
ValueError: Applying transform <monai.transforms.spatial.array.Resize object at 0x7fb425cfdb70>.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/worker.py", line 198, in _worker_loop
data = fetcher.fetch(index)
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/utils/fetch.py", line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/usr/local/lib/python3.6/dist-packages/monai/data/nifti_reader.py", line 102, in getitem
img = apply_transform(self.transform, img)
File "/usr/local/lib/python3.6/dist-packages/monai/transforms/utils.py", line 311, in apply_transform
raise type(e)(f"Applying transform {transform}.").with_traceback(e.traceback)
File "/usr/local/lib/python3.6/dist-packages/monai/transforms/utils.py", line 309, in apply_transform
return transform(data)
File "/usr/local/lib/python3.6/dist-packages/monai/transforms/compose.py", line 233, in call
input
= apply_transform(transform, input)
File "/usr/local/lib/python3.6/dist-packages/monai/transforms/utils.py", line 311, in apply_transform
raise type(e)(f"Applying transform {transform}.").with_traceback(e.traceback)
File "/usr/local/lib/python3.6/dist-packages/monai/transforms/utils.py", line 309, in apply_transform
return transform(data)
File "/usr/local/lib/python3.6/dist-packages/monai/transforms/spatial/array.py", line 360, in call
align_corners=self.align_corners if align_corners is None else align_corners,
File "/usr/local/lib/python3.6/dist-packages/monai/transforms/spatial/array.py", line 54, in _torch_interp
return torch.nn.functional.interpolate(recompute_scale_factor=True, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py", line 3110, in interpolate
raise ValueError("recompute_scale_factor is not meaningful with an explicit size.")
ValueError: Applying transform <monai.transforms.compose.Compose object at 0x7fb425cfdc18>.

from tutorials.

Nic-Ma avatar Nic-Ma commented on August 20, 2024

Are you using MONAI docker or installed all the requirements.txt locally?
Could you please help call below code to provide the env details?

from monai.config import print_config
print_config()

Thanks.

from tutorials.

Sebagam avatar Sebagam commented on August 20, 2024

Sure, this is my config

MONAI version: 0.3.0
Python version: 3.6.9 (default, Oct 8 2020, 12:12:24) [GCC 8.4.0]
OS version: Linux (4.19.112+)
Numpy version: 1.18.5
Pytorch version: 1.7.0+cu101
MONAI flags: HAS_EXT = False, USE_COMPILED = False

Optional dependencies:
Pytorch Ignite version: NOT INSTALLED or UNKNOWN VERSION.
Nibabel version: 3.0.2
scikit-image version: 0.16.2
Pillow version: 7.0.0
Tensorboard version: 2.3.0
gdown version: 3.6.4
TorchVision version: 0.8.1+cu101
ITK version: 5.1.2
tqdm version: 4.54.1

from tutorials.

Nic-Ma avatar Nic-Ma commented on August 20, 2024

Hi @Sebagam ,

I think Wenqi's PR can fix your problem.
Could you please update to use the latest MONAI master code and latest tutorial example?
You can install from latest source by command:

pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI

Thanks.

from tutorials.

Sebagam avatar Sebagam commented on August 20, 2024

from tutorials.

patriciacs1994 avatar patriciacs1994 commented on August 20, 2024

Hello @Nic-Ma.
I am getting the same error when I try to use Resize transformation like this:

    train_imtrans = Compose(
        [
            LoadImage(image_only=True),
            ScaleIntensity(),
            Resize(spatial_size = (192,192), mode = "nearest")
            AddChannel(), 
            ToTensor(),
        ]
    )

ValueError: Caught ValueError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\transforms\utils.py", line 309, in apply_transform
return transform(data)
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\transforms\spatial\array.py", line 360, in call
align_corners=self.align_corners if align_corners is None else align_corners,
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\transforms\spatial\array.py", line 54, in _torch_interp
return torch.nn.functional.interpolate(recompute_scale_factor=True, **kwargs)
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\nn\functional.py", line 3110, in interpolate
raise ValueError("recompute_scale_factor is not meaningful with an explicit size.")
ValueError: recompute_scale_factor is not meaningful with an explicit size.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\transforms\utils.py", line 309, in apply_transform
return transform(data)
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\transforms\compose.py", line 233, in call
input_ = apply_transform(transform, input)
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\transforms\utils.py", line 311, in apply_transform
raise type(e)(f"Applying transform {transform}.").with_traceback(e.traceback)
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\transforms\utils.py", line 309, in apply_transform
return transform(data)
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\transforms\spatial\array.py", line 360, in call
align_corners=self.align_corners if align_corners is None else align_corners,
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\transforms\spatial\array.py", line 54, in _torch_interp
return torch.nn.functional.interpolate(recompute_scale_factor=True, **kwargs)
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\nn\functional.py", line 3110, in interpolate
raise ValueError("recompute_scale_factor is not meaningful with an explicit size.")
ValueError: Applying transform <monai.transforms.spatial.array.Resize object at 0x00000000563826A0>.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\utils\data_utils\worker.py", line 198, in worker_loop
data = fetcher.fetch(index)
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\data\dataset.py", line 725, in getitem
return self.dataset[index]
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\data\dataset.py", line 622, in getitem
data.extend(to_list(dataset[index]))
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\data\dataset.py", line 66, in getitem
data = apply_transform(self.transform, data)
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\transforms\utils.py", line 311, in apply_transform
raise type(e)(f"Applying transform {transform}.").with_traceback(e.traceback)
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\transforms\utils.py", line 309, in apply_transform
return transform(data)
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\transforms\compose.py", line 233, in call
input
= apply_transform(transform, input)
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\transforms\utils.py", line 311, in apply_transform
raise type(e)(f"Applying transform {transform}.").with_traceback(e.traceback)
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\transforms\utils.py", line 309, in apply_transform
return transform(data)
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\transforms\spatial\array.py", line 360, in call
align_corners=self.align_corners if align_corners is None else align_corners,
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\monai\transforms\spatial\array.py", line 54, in _torch_interp
return torch.nn.functional.interpolate(recompute_scale_factor=True, **kwargs)
File "C:\Users\PASI\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\nn\functional.py", line 3110, in interpolate
raise ValueError("recompute_scale_factor is not meaningful with an explicit size.")
ValueError: Applying transform <monai.transforms.compose.Compose object at 0x0000000019110AC8>.

My config is the following one:
_MONAI version: 0.3.0
Python version: 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)]
OS version: Windows (10)
Numpy version: 1.19.3
Pytorch version: 1.7.0+cu101
MONAI flags: HAS_EXT = False, USE_COMPILED = False

Optional dependencies:
Pytorch Ignite version: 0.4.2
Nibabel version: 3.2.1
scikit-image version: 0.17.2
Pillow version: 8.0.1
Tensorboard version: 2.3.0
gdown version: 3.12.2
TorchVision version: 0.8.1+cu101
ITK version: 5.1.2
tqdm version: 4.51.0_

And when I try to use the following command with Anaconda:
pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI

I am getting the following error:

ERROR: Command errored out with exit status 1:
command: 'c:\users\pasi\appdata\local\programs\python\python36\python.exe' 'c:\users\pasi\appdata\local\programs\python\python36\lib\site-packages\pip' install --ignore-installed --no-user --prefix 'C:\Users\PASI\AppData\Local\Temp\pip-build-env-alugcjow\overlay' --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- wheel setuptools 'torch>=1.5' ninja
cwd: None
Complete output (7 lines):
Collecting ninja
Using cached ninja-1.10.0.post2-py3-none-win_amd64.whl (250 kB)
Collecting setuptools
Using cached setuptools-51.0.0-py3-none-any.whl (785 kB)
Collecting torch>=1.5
Using cached torch-1.7.0-cp36-cp36m-win_amd64.whl (184.0 MB)
ERROR: torch has an invalid wheel, .dist-info directory not found

ERROR: Command errored out with exit status 1: 'c:\users\pasi\appdata\local\programs\python\python36\python.exe' 'c:\users\pasi\appdata\local\programs\python\python36\lib\site-packages\pip' install --ignore-installed --no-user --prefix 'C:\Users\PASI\AppData\Local\Temp\pip-build-env-alugcjow\overlay' --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- wheel setuptools 'torch>=1.5' ninja Check the logs for full command output.

Do you know how to solve this?

Thank you in advance

from tutorials.

Nic-Ma avatar Nic-Ma commented on August 20, 2024

Hi @patriciacs1994 ,

I think you may have some compatible issue in your python env.
The easiest solution is to use the latest MONAI docker:

# with docker v19.03+
docker run --gpus all --rm -ti --ipc=host projectmonai/monai:latest

Thanks.

from tutorials.

Nic-Ma avatar Nic-Ma commented on August 20, 2024

Hi @Sebagam ,

Thanks for your suggestion, I will update the notebook to add the Colab link soon.

from tutorials.

patriciacs1994 avatar patriciacs1994 commented on August 20, 2024

Hi @Nic-Ma,
I don't have any experience with Docker.
There is not a requirements.txt file available?
I could create a new environment and install all the requirements for MONAI.
Do you think it could work?

Thank you

from tutorials.

luozuo avatar luozuo commented on August 20, 2024

Hi, I got the same problem when running brats_segmentation_3d.ipynb.
image
However, I did install itk using %pip install -q "monai[nibabel, tqdm, itk]" in Colab. Any hints on this? Thanks!

from tutorials.

luozuo avatar luozuo commented on August 20, 2024

Hi @luozuo,
I solved it.
What I did is create a new environment in Anaconda AGAIN, and execute the following line:
pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI (now it worked)
Later I installed everything I needed.

But, when I tried to run the code in a jupyter notebook the same error showed up, so I executed again this:
pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI

and problem solved.

It worked, thx!

from tutorials.

Nic-Ma avatar Nic-Ma commented on August 20, 2024

Cool! And thanks @patriciacs1994 for your help here!

from tutorials.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.