KerenLab / CellSighter

28 stars 5 forks source link

Error related to crop_size parameter #4

Closed edward130603 closed 1 year ago

edward130603 commented 1 year ago

Hello, I'm trying to run CellSighter to work on CosMx data and ran into this error:

Load training data...
Load validation data...
1 1
Traceback (most recent call last):
  File "//mnt/k/Run5732/CellSighter/CellSighter/train.py", line 126, in <module>
    train_epoch(model, train_loader, optimizer, criterion, device=device, epoch=i, writer=writer)
  File "//mnt/k/Run5732/20230401_015442/20230401_015442_S2/CellSighter/CellSighter/train.py", line 21, in train_epoch
    for i, batch in enumerate(dataloader):
  File "/home/ezhao/anaconda3/envs/cellsighter-env/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 517, in __next__
    data = self._next_data()
  File "/home/ezhao/anaconda3/envs/cellsighter-env/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1199, in _next_data
    return self._process_data(data)
  File "/home/ezhao/anaconda3/envs/cellsighter-env/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1225, in _process_data
    data.reraise()
  File "/home/ezhao/anaconda3/envs/cellsighter-env/lib/python3.9/site-packages/torch/_utils.py", line 429, in reraise
    raise self.exc_type(msg)
ValueError: Caught ValueError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/ezhao/anaconda3/envs/cellsighter-env/lib/python3.9/site-packages/torch/utils/data/_utils/worker.py", line 202, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/ezhao/anaconda3/envs/cellsighter-env/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/ezhao/anaconda3/envs/cellsighter-env/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/mnt/k/Run5732/20230401_015442/20230401_015442_S2/CellSighter/CellSighter/data/data.py", line 20, in __getitem__
    aug = self._transform(np.dstack(
  File "<__array_function__ internals>", line 5, in dstack
  File "/home/ezhao/anaconda3/envs/cellsighter-env/lib/python3.9/site-packages/numpy/lib/shape_base.py", line 723, in dstack
    return _nx.concatenate(arrs, 2)
  File "<__array_function__ internals>", line 5, in concatenate
ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 0 and the array at index 1 has size 128

The number at the end corresponds to the "crop_size" parameter. Do you have any suggestions on what I can do here? Thanks.

yaelAmitay commented 1 year ago

It seems that the protein's channel didn't load correctly. Can you please explain how you constructed your data folders?

edward130603 commented 1 year ago

It seems like my tiff images weren't being read in correctly (wrong order of hwc). I've converted to .npz format and now preliminary results look pretty promising. thanks!