Relationship between Real Image size and Crop Size parameter?
YamacTan opened this issue · comments
Hi all,
Can somebody briefly explain what should be the mathematical relation between the image sizes in our dataset and the "image_size" parameter in training process? I experienced some issues that I cannot define a related crop size per resolution.
For example, with 640x400 image, I can use the crop size as 632x368 but cannot use 632x376; it either throws an error from PyTorch dataloader or the randint() function from Numpy. Therefore I can only determine suitable crop sizes by trial and error.
Thanks in advance,
Y.
Update: I realized that whenever I increase the lower crop limit above 368, it throws different errors about tensor shapes, dataloaders and the numpy.randint error that I mentioned.
Example:
Just an example for PyTorch dataloader when I try to use 640x480 images. If I give the image size here as 368x632, it works. But I cannot address the relation between the parameters and occured problem.
Parameter Count: 5257536
Training with 52200 image pairs
Traceback (most recent call last):
File "train.py", line 247, in <module>
train(args)
File "train.py", line 163, in train
for i_batch, data_blob in enumerate(train_loader):
File "C:\Users\Superuser\anaconda3\envs\raft\lib\site-packages\torch\utils\data\dataloader.py", line 630, in __next__
data = self._next_data()
File "C:\Users\Superuser\anaconda3\envs\raft\lib\site-packages\torch\utils\data\dataloader.py", line 1345, in _next_data
return self._process_data(data)
File "C:\Users\Superuser\anaconda3\envs\raft\lib\site-packages\torch\utils\data\dataloader.py", line 1371, in _process_data
data.reraise()
File "C:\Users\Superuser\anaconda3\envs\raft\lib\site-packages\torch\_utils.py", line 694, in reraise
raise exception
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "C:\Users\Superuser\anaconda3\envs\raft\lib\site-packages\torch\utils\data\_utils\worker.py", line 308, in _worker_loop
data = fetcher.fetch(index)
File "C:\Users\Superuser\anaconda3\envs\raft\lib\site-packages\torch\utils\data\_utils\fetch.py", line 54, in fetch
return self.collate_fn(data)
File "C:\Users\Superuser\anaconda3\envs\raft\lib\site-packages\torch\utils\data\_utils\collate.py", line 265, in default_collate
return collate(batch, collate_fn_map=default_collate_fn_map)
File "C:\Users\Superuser\anaconda3\envs\raft\lib\site-packages\torch\utils\data\_utils\collate.py", line 142, in collate
return [collate(samples, collate_fn_map=collate_fn_map) for samples in transposed] # Backwards compatibility.
File "C:\Users\Superuser\anaconda3\envs\raft\lib\site-packages\torch\utils\data\_utils\collate.py", line 142, in <listcomp>
return [collate(samples, collate_fn_map=collate_fn_map) for samples in transposed] # Backwards compatibility.
File "C:\Users\Superuser\anaconda3\envs\raft\lib\site-packages\torch\utils\data\_utils\collate.py", line 119, in collate
return collate_fn_map[elem_type](batch, collate_fn_map=collate_fn_map)
File "C:\Users\Superuser\anaconda3\envs\raft\lib\site-packages\torch\utils\data\_utils\collate.py", line 161, in collate_tensor_fn
out = elem.new(storage).resize_(len(batch), *list(elem.size()))
RuntimeError: Trying to resize storage that is not resizable