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

np.asarray() Errno 21 IsADirectoryError #10

Open
ghost opened this issue Jan 7, 2022 · 0 comments
Open

np.asarray() Errno 21 IsADirectoryError #10

ghost opened this issue Jan 7, 2022 · 0 comments

Comments

@ghost
Copy link

ghost commented Jan 7, 2022

Hi,

I have downloaded the datasets and placed them in to the "data" folder, ensuring the names matched as per segmentation/header.py. However, in attempting to run segmentation/train.py for the JSRT dataset I get the following error:

[...]/segmentation$ python3 train.py

train.py


>> Generate network - v1.1

>> Load data
  >>> Total # of trainset : 7
  >>> Total # of valset : 1

>> Train Network - [1 epoch]
Traceback (most recent call last):
  File "train.py", line 208, in <module>
    main()
  File "train.py", line 111, in main
    for i, data in enumerate(trainloader, 0):
  File "/[...]/anaconda3/envs/Oh_et_al_2020/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 345, in __next__
    data = self._next_data()
  File "/[...]/anaconda3/envs/Oh_et_al_2020/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 385, in _next_data
    data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
  File "/[...]/anaconda3/envs/Oh_et_al_2020/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/[...]/anaconda3/envs/Oh_et_al_2020/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/[...]/Deep-Learning-COVID-19-on-CXR-using-Limited-Training-Data-Sets/segmentation/mydataset.py", line 60, in __getitem__
    images = np.asarray(np.reshape(np.fromfile(self.images[index], dtype='>u2', sep="", ), (header.orig_height, header.orig_width)))
IsADirectoryError: [Errno 21] Is a directory: '../data/JSRT/Clinical_Information'

Clearly, you cannot use np.asarray() on a directory

I found where this issue is and did a rough workaround: MyTrainDataset.__init__() assumes any items returned by glob(image_path + /*) are image files and appends them to the file image list. Will do a pull request for this one.

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

Successfully merging a pull request may close this issue.

0 participants