test
Closed this issue · 32 comments
Hello, author, I run according to your test.py. The following problems occur. What is the reason? We look forward to you.
Working with 1 GPUs
invalid literal for int() with base 10: ''
using default group number
[24, 48, 96, 192]
total number of trainable parameters 4793895
Validation Input Directory /input
Bench Test dataset number of batch: 1
=> loading checkpoint runs/brats_2021/model_1/model_best.pth.tar
=> loaded checkpoint 'runs/brats_2021/model_1/model_best.pth.tar' (epoch 3)
Traceback (most recent call last):
File "test.py", line 117, in
main(arguments)
File "test.py", line 111, in main
generate_segmentations(bench_loader, model_1, args)
File "test.py", line 40, in generate_segmentations
for i, batch in enumerate(data_loader):
File "/home/hkw/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 530, in next
data = self._next_data()
File "/home/hkw/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1224, in _next_data
return self._process_data(data)
File "/home/hkw/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1250, in _process_data
data.reraise()
File "/home/hkw/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/_utils.py", line 457, in reraise
raise exception
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/hkw/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
data = fetcher.fetch(index)
File "/home/hkw/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/hkw/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/media/hkw/hkwdisk/viv-test/vizviva_brats_2021-main (1)/vizviva_brats_2021-main/dataset/brats.py", line 39, in getitem
patient_image = {key: self.load_nii(_patient[key]) for key in _patient if key not in ["id", "seg"]}
File "/media/hkw/hkwdisk/viv-test/vizviva_brats_2021-main (1)/vizviva_brats_2021-main/dataset/brats.py", line 39, in
patient_image = {key: self.load_nii(_patient[key]) for key in _patient if key not in ["id", "seg"]}
File "/media/hkw/hkwdisk/viv-test/vizviva_brats_2021-main (1)/vizviva_brats_2021-main/dataset/brats.py", line 67, in load_nii
return sitk.GetArrayFromImage(sitk.ReadImage(str(path_folder)))
File "/home/hkw/anaconda3/envs/pytorch/lib/python3.7/site-packages/SimpleITK/SimpleITK.py", line 8876, in ReadImage
return _SimpleITK.ReadImage(*args)
RuntimeError: Exception thrown in SimpleITK ReadImage: /tmp/SimpleITK/Code/IO/src/sitkImageReaderBase.cxx:99:
sitk::ERROR: The file "/media/hkw/hkwdisk/viv-test/vizviva_brats_2021-main (1)/vizviva_brats_2021-main/BRATS2021/Data/valid/BraTS2021_00046_t1.nii.gz" does not exist.
The data set format is arranged according to your style. This error always appears. It's very confusing
Is this path is correct ? /media/hkw/hkwdisk/viv-test/vizviva_brats_2021-main (1)/vizviva_brats_2021-main/BRATS2021/Data/valid/BraTS2021_00046_t1.nii.gz
My path in config is BRATS_TEST_FOLDER ='/media/hkw/hkwdisk/viv-test/vizviva_brats_2021-main (1)/vizviva_brats_2021-main/BRATS2021/Data/valid' . Valid contains BraTS2021_00046 folder,I don't know why BraTS2021_00046 is missing
I don't know why I don't recognize the BraTS2021_00046 folder and ask to display the files contained in it
There was no problem with the training. I kept reporting this error during the test. I'm very distressed. I don't know why. I look forward to your help
Try using get_dataset_val method in brats_train.py script.
https://github.com/himashi92/vizviva_brats_2021/blob/main/dataset/brats_train.py#L113
Change this line of code in your test.py
https://github.com/himashi92/vizviva_brats_2021/blob/main/test.py#L18
from dataset.brats_train import get_datasets_val
Hello, can you tell me how to modify which code and how to modify it?
I added from dataset.brats_train import get_datasets_val and still reported the same error.
Working with 1 GPUs
invalid literal for int() with base 10: ''
using default group number
[24, 48, 96, 192]
total number of trainable parameters 4793895
Validation Input Directory /input
Bench Test dataset number of batch: 1
=> loading checkpoint runs/brats_2021/model_1/model_best.pth.tar
=> loaded checkpoint 'runs/brats_2021/model_1/model_best.pth.tar' (epoch 3)
Traceback (most recent call last):
File "test.py", line 117, in
main(arguments)
File "test.py", line 111, in main
generate_segmentations(bench_loader, model_1, args)
File "test.py", line 40, in generate_segmentations
for i, batch in enumerate(data_loader):
File "/home/hkw/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 530, in next
data = self._next_data()
File "/home/hkw/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1224, in _next_data
return self._process_data(data)
File "/home/hkw/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1250, in _process_data
data.reraise()
File "/home/hkw/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/_utils.py", line 457, in reraise
raise exception
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/hkw/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
data = fetcher.fetch(index)
File "/home/hkw/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/hkw/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/media/hkw/hkwdisk/viv-test/vizviva_brats_2021-main (1)/vizviva_brats_2021-main/dataset/brats.py", line 39, in getitem
patient_image = {key: self.load_nii(_patient[key]) for key in _patient if key not in ["id", "seg"]}
File "/media/hkw/hkwdisk/viv-test/vizviva_brats_2021-main (1)/vizviva_brats_2021-main/dataset/brats.py", line 39, in
patient_image = {key: self.load_nii(_patient[key]) for key in _patient if key not in ["id", "seg"]}
File "/media/hkw/hkwdisk/viv-test/vizviva_brats_2021-main (1)/vizviva_brats_2021-main/dataset/brats.py", line 67, in load_nii
return sitk.GetArrayFromImage(sitk.ReadImage(str(path_folder)))
File "/home/hkw/anaconda3/envs/pytorch/lib/python3.7/site-packages/SimpleITK/extra.py", line 346, in ReadImage
return reader.Execute()
File "/home/hkw/anaconda3/envs/pytorch/lib/python3.7/site-packages/SimpleITK/SimpleITK.py", line 8015, in Execute
return _SimpleITK.ImageFileReader_Execute(self)
RuntimeError: Exception thrown in SimpleITK ImageFileReader_Execute: /tmp/SimpleITK/Code/IO/src/sitkImageReaderBase.cxx:97:
sitk::ERROR: The file "/media/hkw/hkwdisk/viv-test/vizviva_brats_2021-main (1)/vizviva_brats_2021-main/BRATS2021/Data/valid/BraTS2021_00046_t1.nii.gz" does not exist.
Do not know whether to def generate_ Segmentation (data_loader, model, args) code needs to be modified?
I look forward to your help
Still, your script is referring to brats.py, not brats_train.py
Can you tell me how to modify which line of code? Thank you very much
Working with 1 GPUs
invalid literal for int() with base 10: ''
using default group number
[24, 48, 96, 192]
total number of trainable parameters 4793895
Traceback (most recent call last):
File "test.py", line 117, in
main(arguments)
File "test.py", line 104, in main
bench_dataset = get_datasets_val()
TypeError: get_datasets_val() missing 1 required positional argument: 'seed'
I used from dataset.brats_train import get_datasets_val and the above problems occurred
1 was used bench_dataset = get_datasets_val(args.seed) and the following problems occurred.
Working with 1 GPUs
invalid literal for int() with base 10: ''
using default group number
[24, 48, 96, 192]
total number of trainable parameters 4793895
Train Input Directory /input
/media/hkw/hkwdisk/viv-test/vizviva_brats_2021-main (1)/vizviva_brats_2021-main/BRATS2021/Data/RSNA_ASNR_MICCAI_BraTS2021_TrainingData
first idx of train 0
first idx of test 7
Bench Test dataset number of batch: 3
=> loading checkpoint runs/brats_2021/model_1/model_best.pth.tar
=> loaded checkpoint 'runs/brats_2021/model_1/model_best.pth.tar' (epoch 3)
torch.Size([4, 137, 164, 137])
Traceback (most recent call last):
File "test.py", line 117, in
main(arguments)
File "test.py", line 111, in main
generate_segmentations(bench_loader, model_1, args)
File "test.py", line 46, in generate_segmentations
inputs, pads = pad_batch1_to_compatible_size(inputs)
File "/media/hkw/hkwdisk/viv-test/vizviva_brats_2021-main (1)/vizviva_brats_2021-main/dataset/batch_utils.py", line 50, in pad_batch1_to_compatible_size
zpad, ypad, xpad = zmax - batch.size(2), ymax - batch.size(3), xmax - batch.size(4)
IndexError: Dimension out of range (expected to be in range of [-4, 3], but got 4)
I look forward to your help in solving this problem. Thank you very much and look forward to your reply
I still feel that def generate_segmentations(data_loader, model, args): of test.py needs to be modified
Please check test Whether the code in py needs to be updated, thank you very much
for patient_dir in patients_dir:
patient_id = patient_dir.name
paths = [patient_dir / f"{patient_id}{value}.nii.gz" for value in self.patterns]
patient = dict(
id=patient_id, t1=paths[0], t1ce=paths[1],
t2=paths[2], flair=paths[3], seg=paths[4] if not no_seg else None
)
self.datas.append(patient)
Add this for loop in brats.py https://github.com/himashi92/vizviva_brats_2021/blob/main/dataset/brats.py#L28 and use get_dataset_val method in there.
This test.py is originally created for brats evaluation and according to their requirements. So there's nothing wrong with the code. It should be adjusted according to your requirements and with debugging and properly going through the code you should be able to modify the code.
OK, let me add it. I don't know where to add it
Its a for loop, so you need to add indent.
Refer this, it's the same for loop. https://github.com/himashi92/vizviva_brats_2021/blob/main/dataset/brats_train.py#L26
Traceback (most recent call last):
File "test.py", line 18, in
from dataset.brats import get_datasets_val
File "/media/hkw/hkwdisk/viv-test/vizviva_brats_2021-main (1)/vizviva_brats_2021-main/dataset/brats.py", line 71, in
for patient_dir in patients_dir:
NameError: name 'patients_dir' is not defined
Now add https://github.com/himashi92/vizviva_brats_2021/blob/main/dataset/brats_train.py#L113 this method as get_datasets_val.
This will be a combination of both brats.py and brats_train.py scripts. My advice for you is, please debug and see what's going on in the code. If you understand the code, then it'll be easy for you to modify the code. (Not all authors guide you :) )
ok, thank you very much
Hello, author. I'm sorry to bother you again. After testing, your code has no problem, but each path can only be displayed as/media/hkw/hkwdisk/viv-test/vizviva_brats_2021-main (1)/vizviva_brats_2021-main/BRATS2021/Data/valid/BraTS2021_00046_t1.nii.gz , and several paths cannot be recognized .nii file folders, such as Brats2021_00046, so I can only test one folder at a time, and can't test all the data at the same time. Thank you very much for helping us see where we need to optimize when you're free
There is no problem with your code, but I don't understand why each brats data is not recognized in the path, but directly to the data in the folder NII file, very much looking forward to solving my doubts
Can you send me your test.py and brats.py to my email (himashi.ama92@gmail.com)
No problem. Thank you very much
Hello, I have tried this method before, and it always appears
Working with 1 GPUs
invalid literal for int() with base 10: ''
using default group number
[24, 48, 96, 192]
total number of trainable parameters 4793895
Validation Input Directory /input
Traceback (most recent call last):
File "test.py", line 117, in
main(arguments)
File "test.py", line 104, in main
bench_dataset = get_datasets_val()
File "/media/hkw/hkwdisk/viv-test/vizviva_brats_2021-main (1)/vizviva_brats_2021-main/dataset/brats.py", line 79, in get_datasets_val
bench_dataset = Brats(val_patients_dir, training=False, no_seg=no_seg, benchmarking=True, normalisation=normalisation)
File "/media/hkw/hkwdisk/viv-test/vizviva_brats_2021-main (1)/vizviva_brats_2021-main/dataset/brats.py", line 28, in init
for patient_dir in patients_dir:
TypeError: 'PosixPath' object is not iterable