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

Array resize error: cannot reshape array of size 3850108 into shape (2048,2048) #12

Open
ghost opened this issue Jan 7, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Jan 7, 2022

Running train.py and with the code fix for #10, I now get the error: cannot reshape array of size 3850108 into shape (2048,2048)

[...]/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 62, in __getitem__
    images = np.asarray(np.reshape(np.fromfile(self.images[index], dtype='>u2', sep="", ), (header.orig_height, header.orig_width)))
  File "<__array_function__ internals>", line 6, in reshape
  File "/[...]/anaconda3/envs/Oh_et_al_2020/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 301, in reshape
    return _wrapfunc(a, 'reshape', newshape, order=order)
  File "/[...]/anaconda3/envs/Oh_et_al_2020/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 61, in _wrapfunc
    return bound(*args, **kwds)
ValueError: cannot reshape array of size 3850108 into shape (2048,2048)

Some incorrect assumptions about the data set, somehow?

@piyu23srma
Copy link

I am facing same issue.
How it got resolved ?

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