Open AymanAbaid opened 4 months ago
This error mostly occurs due to memory issues. Please try again with fewer number of images in the training folder; let's say try with 2 images inside the training folder instead of 50. Let me know if it works? Kind Regards M. Imran
On Mon, Jun 3, 2024 at 4:13 PM AymanAbaid @.***> wrote:
I encountered a RuntimeError while trying to load a dataset using MONAI transforms in the train.py script of the AortaSeg24-main project. The error indicates that LoadImage cannot find a suitable reader for the file format used in my dataset. Specifically, the error message states that it cannot find a suitable reader for the file data/images/subject001_CTA.mha.
`Namespace(root_dir='./data/', saved_model_dir='./best_model/', output_csv='training_info.csv', num_classes=24, max_iterations=2, eval_num=2, num_train_images=1, patch_size=128, spatial_dims=3, feature_size=96, num_samples=1)
Loading dataset: 0%| | 0/1 [00:00<?, ?it/s] Traceback (most recent call last): File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/transform.py", line 141, in apply_transform return _apply_transform(transform, data, unpack_items, lazy, overrides, log_stats) File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/transform.py", line 98, in _apply_transform return transform(data, lazy=lazy) if isinstance(transform, LazyTrait) else transform(data) File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/io/dictionary.py", line 162, in call data = self._loader(d[key], reader) File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/io/array.py", line 274, in call raise RuntimeError( RuntimeError: LoadImage cannot find a suitable reader for file: data/images/subject001_CTA.mha. Please install the reader libraries, see also the installation instructions:
https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies . The current registered: [<monai.data.image_reader.NumpyReader object at 0x7cdeb5608670>, <monai.data.image_reader.PILReader object at 0x7cdeb56086d0>].
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/home/ayman/SwinUNetR/AortaSeg24-main/training/train.py", line 104, in main(args) File "/home/ayman/SwinUNetR/AortaSeg24-main/training/train.py", line 48, in main train_ds = CacheDataset(data=train_files, transform=train_transforms, cache_num=len(train_files), cache_rate=1.0, num_workers=num_cpus) File "/home/ayman/venv/lib/python3.10/site-packages/monai/data/dataset.py", line 823, in init self.set_data(data) File "/home/ayman/venv/lib/python3.10/site-packages/monai/data/dataset.py", line 850, in set_data self._cache = self._fill_cache(indices) File "/home/ayman/venv/lib/python3.10/site-packages/monai/data/dataset.py", line 879, in _fill_cache return list(tqdm(p.imap(self._load_cache_item, indices), total=len(indices), desc="Loading dataset")) File "/home/ayman/venv/lib/python3.10/site-packages/tqdm/std.py", line 1181, in iter for obj in iterable: File "/usr/lib/python3.10/multiprocessing/pool.py", line 873, in next raise value File "/usr/lib/python3.10/multiprocessing/pool.py", line 125, in worker result = (True, func(*args, *kwds)) File "/home/ayman/venv/lib/python3.10/site-packages/monai/data/dataset.py", line 892, in _load_cache_item item = self.transform(item, end=first_random, threading=True) File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/compose.py", line 335, in call result = execute_compose( File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/compose.py", line 111, in execute_compose data = apply_transform( File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/transform.py", line 171, in apply_transform ` Steps to Reproduce* Prepare the dataset with .mha files. Configure the train.py script with the provided parameters. Run the train.py script.
— Reply to this email directly, view it on GitHub https://github.com/ImranNust/AortaSeg24/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIIGJN5QQAZHSD5UWXA36JDZFTFABAVCNFSM6AAAAABIXFTOPCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGMZTCOJWGA3TKMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
This error mostly occurs due to memory issues. Please try again with fewer number of images in the training folder; let's say try with 2 images inside the training folder instead of 50. Let me know if it works? Kind Regards M. Imran LinkedIn http://www.linkedin.com/in/muhammad-imran-b7865495 | GitHub https://github.com/ImranNust … On Mon, Jun 3, 2024 at 4:13 PM AymanAbaid @.> wrote: I encountered a RuntimeError while trying to load a dataset using MONAI transforms in the train.py script of the AortaSeg24-main project. The error indicates that LoadImage cannot find a suitable reader for the file format used in my dataset. Specifically, the error message states that it cannot find a suitable reader for the file data/images/subject001_CTA.mha. `Namespace(root_dir='./data/', saved_model_dir='./best_model/', output_csv='training_info.csv', num_classes=24, max_iterations=2, eval_num=2, num_train_images=1, patch_size=128, spatial_dims=3, feature_size=96, num_samples=1) ------------------------------ Loading dataset: 0%| | 0/1 [00:00<?, ?it/s] Traceback (most recent call last): File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/transform.py", line 141, in apply_transform return _apply_transform(transform, data, unpack_items, lazy, overrides, log_stats) File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/transform.py", line 98, in _apply_transform return transform(data, lazy=lazy) if isinstance(transform, LazyTrait) else transform(data) File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/io/dictionary.py", line 162, in call data = self._loader(d[key], reader) File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/io/array.py", line 274, in call raise RuntimeError( RuntimeError: LoadImage cannot find a suitable reader for file: data/images/subject001_CTA.mha. Please install the reader libraries, see also the installation instructions: https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies . The current registered: [<monai.data.image_reader.NumpyReader object at 0x7cdeb5608670>, <monai.data.image_reader.PILReader object at 0x7cdeb56086d0>]. The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/ayman/SwinUNetR/AortaSeg24-main/training/train.py", line 104, in main(args) File "/home/ayman/SwinUNetR/AortaSeg24-main/training/train.py", line 48, in main train_ds = CacheDataset(data=train_files, transform=train_transforms, cache_num=len(train_files), cache_rate=1.0, num_workers=num_cpus) File "/home/ayman/venv/lib/python3.10/site-packages/monai/data/dataset.py", line 823, in init self.set_data(data) File "/home/ayman/venv/lib/python3.10/site-packages/monai/data/dataset.py", line 850, in set_data self._cache = self._fill_cache(indices) File "/home/ayman/venv/lib/python3.10/site-packages/monai/data/dataset.py", line 879, in _fill_cache return list(tqdm(p.imap(self._load_cache_item, indices), total=len(indices), desc="Loading dataset")) File "/home/ayman/venv/lib/python3.10/site-packages/tqdm/std.py", line 1181, in iter for obj in iterable: File "/usr/lib/python3.10/multiprocessing/pool.py", line 873, in next raise value File "/usr/lib/python3.10/multiprocessing/pool.py", line 125, in worker result = (True, func(args, kwds)) File "/home/ayman/venv/lib/python3.10/site-packages/monai/data/dataset.py", line 892, in _load_cache_item item = self.transform(item, end=first_random, threading=True) File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/compose.py", line 335, in call result = execute_compose( File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/compose.py", line 111, in execute_compose data = apply_transform( File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/transform.py", line 171, in apply_transform ` Steps to Reproduce Prepare the dataset with .mha files. Configure the train.py script with the provided parameters. Run the train.py script. — Reply to this email directly, view it on GitHub <#1>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIIGJN5QQAZHSD5UWXA36JDZFTFABAVCNFSM6AAAAABIXFTOPCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGMZTCOJWGA3TKMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
my data folder has only 2 .mha files in images and masks directory Also i am using following command to run train.py python3 train.py --root_dir "./data/" --saved_model_dir "./best_model/" --output_csv "training_info.csv" --num_classes 24 --max_iterations 2 --eval_num 2 --num_samples 1 --num_train_images 1
make num_workers = 0 and reduce the patch_size to let's say 48 and then try Kind Regards M. Imran
On Mon, Jun 3, 2024 at 4:13 PM AymanAbaid @.***> wrote:
I encountered a RuntimeError while trying to load a dataset using MONAI transforms in the train.py script of the AortaSeg24-main project. The error indicates that LoadImage cannot find a suitable reader for the file format used in my dataset. Specifically, the error message states that it cannot find a suitable reader for the file data/images/subject001_CTA.mha.
`Namespace(root_dir='./data/', saved_model_dir='./best_model/', output_csv='training_info.csv', num_classes=24, max_iterations=2, eval_num=2, num_train_images=1, patch_size=128, spatial_dims=3, feature_size=96, num_samples=1)
Loading dataset: 0%| | 0/1 [00:00<?, ?it/s] Traceback (most recent call last): File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/transform.py", line 141, in apply_transform return _apply_transform(transform, data, unpack_items, lazy, overrides, log_stats) File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/transform.py", line 98, in _apply_transform return transform(data, lazy=lazy) if isinstance(transform, LazyTrait) else transform(data) File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/io/dictionary.py", line 162, in call data = self._loader(d[key], reader) File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/io/array.py", line 274, in call raise RuntimeError( RuntimeError: LoadImage cannot find a suitable reader for file: data/images/subject001_CTA.mha. Please install the reader libraries, see also the installation instructions:
https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies . The current registered: [<monai.data.image_reader.NumpyReader object at 0x7cdeb5608670>, <monai.data.image_reader.PILReader object at 0x7cdeb56086d0>].
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/home/ayman/SwinUNetR/AortaSeg24-main/training/train.py", line 104, in main(args) File "/home/ayman/SwinUNetR/AortaSeg24-main/training/train.py", line 48, in main train_ds = CacheDataset(data=train_files, transform=train_transforms, cache_num=len(train_files), cache_rate=1.0, num_workers=num_cpus) File "/home/ayman/venv/lib/python3.10/site-packages/monai/data/dataset.py", line 823, in init self.set_data(data) File "/home/ayman/venv/lib/python3.10/site-packages/monai/data/dataset.py", line 850, in set_data self._cache = self._fill_cache(indices) File "/home/ayman/venv/lib/python3.10/site-packages/monai/data/dataset.py", line 879, in _fill_cache return list(tqdm(p.imap(self._load_cache_item, indices), total=len(indices), desc="Loading dataset")) File "/home/ayman/venv/lib/python3.10/site-packages/tqdm/std.py", line 1181, in iter for obj in iterable: File "/usr/lib/python3.10/multiprocessing/pool.py", line 873, in next raise value File "/usr/lib/python3.10/multiprocessing/pool.py", line 125, in worker result = (True, func(*args, *kwds)) File "/home/ayman/venv/lib/python3.10/site-packages/monai/data/dataset.py", line 892, in _load_cache_item item = self.transform(item, end=first_random, threading=True) File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/compose.py", line 335, in call result = execute_compose( File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/compose.py", line 111, in execute_compose data = apply_transform( File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/transform.py", line 171, in apply_transform ` Steps to Reproduce* Prepare the dataset with .mha files. Configure the train.py script with the provided parameters. Run the train.py script.
— Reply to this email directly, view it on GitHub https://github.com/ImranNust/AortaSeg24/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIIGJN5QQAZHSD5UWXA36JDZFTFABAVCNFSM6AAAAABIXFTOPCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGMZTCOJWGA3TKMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Wrong, this is not a memory issue. You are missing dependencies for monai. In the special case the missing dependency is itk. You can add the dependency via:
pip install monai[itk]==1.3.0
But probably want to add all dependencies
pip install monai[all]==1.3.0
We had issues with install all because of failing fire
dependency
Thanks for the suggestions! Yes,
pip install monai[all]
will install all the dependencies.
I encountered a RuntimeError while trying to load a dataset using MONAI transforms in the train.py script of the AortaSeg24-main project. The error indicates that LoadImage cannot find a suitable reader for the file format used in my dataset. Specifically, the error message states that it cannot find a suitable reader for the file data/images/subject001_CTA.mha.
`Namespace(root_dir='./data/', saved_model_dir='./best_model/', output_csv='training_info.csv', num_classes=24, max_iterations=2, eval_num=2, num_train_images=1, patch_size=128, spatial_dims=3, feature_size=96, num_samples=1)
Loading dataset: 0%| | 0/1 [00:00<?, ?it/s] Traceback (most recent call last): File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/transform.py", line 141, in apply_transform return _apply_transform(transform, data, unpack_items, lazy, overrides, log_stats) File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/transform.py", line 98, in _apply_transform return transform(data, lazy=lazy) if isinstance(transform, LazyTrait) else transform(data) File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/io/dictionary.py", line 162, in call data = self._loader(d[key], reader) File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/io/array.py", line 274, in call raise RuntimeError( RuntimeError: LoadImage cannot find a suitable reader for file: data/images/subject001_CTA.mha. Please install the reader libraries, see also the installation instructions: https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies. The current registered: [<monai.data.image_reader.NumpyReader object at 0x7cdeb5608670>, <monai.data.image_reader.PILReader object at 0x7cdeb56086d0>].
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/home/ayman/SwinUNetR/AortaSeg24-main/training/train.py", line 104, in
main(args)
File "/home/ayman/SwinUNetR/AortaSeg24-main/training/train.py", line 48, in main
train_ds = CacheDataset(data=train_files, transform=train_transforms, cache_num=len(train_files), cache_rate=1.0, num_workers=num_cpus)
File "/home/ayman/venv/lib/python3.10/site-packages/monai/data/dataset.py", line 823, in init
self.set_data(data)
File "/home/ayman/venv/lib/python3.10/site-packages/monai/data/dataset.py", line 850, in set_data
self._cache = self._fill_cache(indices)
File "/home/ayman/venv/lib/python3.10/site-packages/monai/data/dataset.py", line 879, in _fill_cache
return list(tqdm(p.imap(self._load_cache_item, indices), total=len(indices), desc="Loading dataset"))
File "/home/ayman/venv/lib/python3.10/site-packages/tqdm/std.py", line 1181, in iter
for obj in iterable:
File "/usr/lib/python3.10/multiprocessing/pool.py", line 873, in next
raise value
File "/usr/lib/python3.10/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, kwds))
File "/home/ayman/venv/lib/python3.10/site-packages/monai/data/dataset.py", line 892, in _load_cache_item
item = self.transform(item, end=first_random, threading=True)
File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/compose.py", line 335, in call
result = execute_compose(
File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/compose.py", line 111, in execute_compose
data = apply_transform(
File "/home/ayman/venv/lib/python3.10/site-packages/monai/transforms/transform.py", line 171, in apply_transform
`
Steps to Reproduce**
Prepare the dataset with .mha files.
Configure the train.py script with the provided parameters.
Run the train.py script.
Any help in resolving this issue would be greatly appreciated. Thank you!