TypeError: expected str, bytes or os.PathLike object, not Image #5447
Replies: 11 comments 5 replies
-
Hi @SiYeon-Kwon, it seems you passed MONAI/monai/transforms/io/array.py Lines 222 to 227 in ef68f16 Hope it can help you, thanks! |
Beta Was this translation helpful? Give feedback.
-
I tried printing the type of my code. |
Beta Was this translation helpful? Give feedback.
-
I think MONAI's own transform doesn't fit other codes. |
Beta Was this translation helpful? Give feedback.
-
Hi @SiYeon-Kwon, could you please give more details, you print which variable's type? |
Beta Was this translation helpful? Give feedback.
-
@KumoLiu Can I show you the code? |
Beta Was this translation helpful? Give feedback.
-
Of course, if you could. |
Beta Was this translation helpful? Give feedback.
-
// import torchvision from timeit import default_timer as timer from monai.transforms import (
@KumoLiu Thanks a lot KumoLiu, everytime!!! |
Beta Was this translation helpful? Give feedback.
-
Hi @SiYeon-Kwon, you load the image in
or remove
Thanks! |
Beta Was this translation helpful? Give feedback.
-
Hi, @KumoLiu |
Beta Was this translation helpful? Give feedback.
-
Hi @SiYeon-Kwon, you could apply transforms like this. Lines 85 to 90 in a9f9987 And I will transfer this issue to discussions, thanks! |
Beta Was this translation helpful? Give feedback.
-
In my opinion, I don't think deleting Image.open or LoadImage will solve the problem. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I am using MONAI tutorial.
I'm making a new code by combining the codes of tutorial and Kaggle, but there's been a problem recently.
I googled the problem, but I haven't found the answer yet. Can you help me?
Thank you to everyone.
//
Exception has occurred: RuntimeError
Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/kwon/my/MONAI/monai/transforms/transform.py", line 102, in apply_transform
return _apply_transform(transform, data, unpack_items)
File "/home/kwon/my/MONAI/monai/transforms/transform.py", line 66, in _apply_transform
return transform(parameters)
File "/home/kwon/my/MONAI/monai/transforms/io/array.py", line 231, in call
filename = tuple(f"{Path(s).expanduser()}" for s in ensure_tuple(filename)) # allow Path objects
File "/home/kwon/my/MONAI/monai/transforms/io/array.py", line 231, in
filename = tuple(f"{Path(s).expanduser()}" for s in ensure_tuple(filename)) # allow Path objects
File "/usr/lib/python3.10/pathlib.py", line 960, in new
self = cls._from_parts(args)
File "/usr/lib/python3.10/pathlib.py", line 594, in _from_parts
drv, root, parts = self._parse_args(args)
File "/usr/lib/python3.10/pathlib.py", line 578, in _parse_args
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not Image
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/kwon/.local/lib/python3.10/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "/home/kwon/.local/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 58, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/kwon/.local/lib/python3.10/site-packages/torch/utils/data/utils/fetch.py", line 58, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/kwon/my/MONAI/brain_tumor_monai.py", line 94, in getitem
img = self.transform(img)
File "/home/kwon/my/MONAI/monai/transforms/compose.py", line 174, in call
input = apply_transform(transform, input, self.map_items, self.unpack_items, self.log_stats)
File "/home/kwon/my/MONAI/monai/transforms/transform.py", line 129, in apply_transform
raise RuntimeError(f"applying transform {transform}") from e
RuntimeError: applying transform <monai.transforms.io.array.LoadImage object at 0x7f9bc2bda6b0>
File "/home/kwon/my/MONAI/brain_tumor_monai.py", line 149, in
for batch_data in train_loader:
//
Beta Was this translation helpful? Give feedback.
All reactions