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

Training in 2D images #131

Open
noseDewdrop opened this issue Oct 6, 2022 · 3 comments
Open

Training in 2D images #131

noseDewdrop opened this issue Oct 6, 2022 · 3 comments

Comments

@noseDewdrop
Copy link

Thanks for ur great job, I'm trying apply it on 2D images which were created by 3D datas of Brats2019. All of them has the shape of (160, 160). Therefore, I set them in the same folder.Dataset is ok, but I got this error when I run the main.py.

ValueError: input image size (img_size) should be divisible by stage-wise image resolution.

Here's the output on command .

python3.8 main.py --feature_size=48 --batch_size=1 --logdir=unetr_test_dir --fold=1 --optim_lr=1e-4 --lrschedule=warmup_cosine --infer_overlap=0.5 --save_checkpoint --val_every=10 --json_list='./jsons/brats21_folds.json' --data_dir=/mnt/sdb_newdisk/ljc_cnu/circle_cut/Tasks/MICCAI/ --use_checkpoint --noamp

0 gpu 0
Batch size is: 1 epochs 300
Traceback (most recent call last):
File "main.py", line 230, in
main()
File "main.py", line 104, in main
main_worker(gpu=0, args=args)
File "main.py", line 130, in main_worker
model = SwinUNETR(
File "/home/ljc_cnu/anaconda3/envs/swin/lib/python3.8/site-packages/monai/networks/nets/swin_unetr.py", line 111, in init
raise ValueError("input image size (img_size) should be divisible by stage-wise image resolution.")
ValueError: input image size (img_size) should be divisible by stage-wise image resolution.

can u give me a solution?

@noseDewdrop
Copy link
Author

That's the result after I change the roi from 96 to 48, maybe that's wrong. But I got the another error when I set that with 96.

Traceback (most recent call last):
File "/home/ljc_cnu/anaconda3/envs/swin/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "/home/ljc_cnu/anaconda3/envs/swin/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/ljc_cnu/anaconda3/envs/swin/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/ljc_cnu/anaconda3/envs/swin/lib/python3.8/site-packages/monai/data/dataset.py", line 105, in getitem
return self._transform(index)
File "/home/ljc_cnu/anaconda3/envs/swin/lib/python3.8/site-packages/monai/data/dataset.py", line 91, in _transform
return apply_transform(self.transform, data_i) if self.transform is not None else data_i
File "/home/ljc_cnu/anaconda3/envs/swin/lib/python3.8/site-packages/monai/transforms/transform.py", line 118, in apply_transform
raise RuntimeError(f"applying transform {transform}") from e
RuntimeError: applying transform <monai.transforms.compose.Compose object at 0x7fc9c22c4940>

@marvnmtz
Copy link

Thanks for ur great job, I'm trying apply it on 2D images which were created by 3D datas of Brats2019. All of them has the shape of (160, 160). Therefore, I set them in the same folder.Dataset is ok, but I got this error when I run the main.py.

ValueError: input image size (img_size) should be divisible by stage-wise image resolution.

Here's the output on command .

python3.8 main.py --feature_size=48 --batch_size=1 --logdir=unetr_test_dir --fold=1 --optim_lr=1e-4 --lrschedule=warmup_cosine --infer_overlap=0.5 --save_checkpoint --val_every=10 --json_list='./jsons/brats21_folds.json' --data_dir=/mnt/sdb_newdisk/ljc_cnu/circle_cut/Tasks/MICCAI/ --use_checkpoint --noamp

0 gpu 0 Batch size is: 1 epochs 300 Traceback (most recent call last): File "main.py", line 230, in main() File "main.py", line 104, in main main_worker(gpu=0, args=args) File "main.py", line 130, in main_worker model = SwinUNETR( File "/home/ljc_cnu/anaconda3/envs/swin/lib/python3.8/site-packages/monai/networks/nets/swin_unetr.py", line 111, in init raise ValueError("input image size (img_size) should be divisible by stage-wise image resolution.") ValueError: input image size (img_size) should be divisible by stage-wise image resolution.

can u give me a solution?

I don't know if you still have that issue, but I would try to crop the images to a multiple of 96, so for example 192 as it is the closest to 160.

@Saillxl
Copy link

Saillxl commented Jun 19, 2024

@noseDewdrop hello,do you remember how to solve this problem?

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

3 participants