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

Errors while sampling with custom dataset #199

Closed
pedropesserl opened this issue Oct 22, 2024 · 0 comments
Closed

Errors while sampling with custom dataset #199

pedropesserl opened this issue Oct 22, 2024 · 0 comments

Comments

@pedropesserl
Copy link
Contributor

pedropesserl commented Oct 22, 2024

Logging to ../sample/sample_corsican_test
[rank0]: Traceback (most recent call last):
[rank0]:   File "/lustre07/scratch/pesserl/medsegdiff/MedSegDiff/scripts/segmentation_sample.py", line 191, in <module>
[rank0]:     main()
[rank0]:   File "/lustre07/scratch/pesserl/medsegdiff/MedSegDiff/scripts/segmentation_sample.py", line 62, in main
[rank0]:     ds,
[rank0]:     ^^
[rank0]: UnboundLocalError: cannot access local variable 'ds' where it is not associated with a value

Reason: in scripts/segmentation_sample.py it is not defined what should happen in case args.data_name is not ISIC or BRATS.

Suggested fix: in scripts/segmentation_sample.py, import CustomDataset from guided_diffusion and assign ds as necessary.

Also:

loading data from the directory : data/CorsicanFire_test
creating model and diffusion...
[rank0]: Traceback (most recent call last):
[rank0]:   File "/lustre07/scratch/pesserl/medsegdiff/MedSegDiff/scripts/segmentation_sample.py", line 199, in <module>
[rank0]:     main()
[rank0]:   File "/lustre07/scratch/pesserl/medsegdiff/MedSegDiff/scripts/segmentation_sample.py", line 101, in main
[rank0]:     b, m, path = next(data)  #should return an image from the dataloader "data"
[rank0]:                  ^^^^^^^^^^
[rank0]:   File "/home/pesserl/.local/lib/python3.11/site-packages/torch/utils/data/dataloader.py", line 631, in __next__
[rank0]:     data = self._next_data()
[rank0]:            ^^^^^^^^^^^^^^^^^
[rank0]:   File "/home/pesserl/.local/lib/python3.11/site-packages/torch/utils/data/dataloader.py", line 675, in _next_data
[rank0]:     data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/home/pesserl/.local/lib/python3.11/site-packages/torch/utils/data/_utils/fetch.py", line 51, in fetch
[rank0]:     data = [self.dataset[idx] for idx in possibly_batched_index]
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/home/pesserl/.local/lib/python3.11/site-packages/torch/utils/data/_utils/fetch.py", line 51, in <listcomp>
[rank0]:     data = [self.dataset[idx] for idx in possibly_batched_index]
[rank0]:             ~~~~~~~~~~~~^^^^^
[rank0]:   File "/lustre07/scratch/pesserl/medsegdiff/MedSegDiff/guided_diffusion/custom_dataset_loader.py", line 50, in __getitem__
[rank0]:     label = int(self.label_list[index])
[rank0]:             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]: ValueError: invalid literal for int() with base 10: 'data/CorsicanFire_test/masks/007_gt.png'

These happen because of some unnecessary lines in guided_diffusion/custom_dataset_loader.py.

Suggested fix: comment out lines 47-50 and the last comparison in the file since it's not accomplishing anything.

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

1 participant