Closed mansum6 closed 3 years ago
Hello! It's not forcing the image to a scale of 4, it's making sure the image has dimensions that are multiples of 4. That's a safe measure for any step that requires scaling internally, but this should only happen on it's own under specific circumstances.
What crop size (HR_size) are you using?
I think I know what the solution is. Try adding this:
preprocess: crop
Under this line in the options file: https://github.com/victorca25/BasicSR/blob/326b7062fb32464e6ce89388bec5b86c3943c7fb/codes/options/train/train_template.yml#L34
So it would look something like:
virtual_batch_size: 8
HR_size: 128
image_channels: 3
preprocess: crop
The new commits include this change, you should also be able to just pull the latest version and test if everything works as expected!
- The first error is that it is forcing the image size to mutiple of 4 when the scale is 1.
- Secondly, even thought it has cropped/expanded the image it still gives this error as it does not scale the corresponding lr image
LOGS: The image size needs to be a multiple of 4. The loaded image size was (817, 398), so it was adjusted to (816, 400). This adjustment will be done to all images whose sizes are not multiples of 4. The image size needs to be a multiple of 4. The loaded image size was (476, 485), so it was adjusted to (476, 484). This adjustment will be done to all images whose sizes are not multiples of 4. Traceback (most recent call last): File "train.py", line 417, in main() File "train.py", line 413, in main fit(model, opt, dataloaders, steps_states, data_params, loggers) File "train.py", line 215, in fit for n, train_data in enumerate(dataloaders['train'], start=1): File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 517, in next data = self._next_data() File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1199, in _next_data return self._process_data(data) File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1225, in _process_data data.reraise() File "/usr/local/lib/python3.7/dist-packages/torch/_utils.py", line 429, in reraise raise self.exc_type(msg) RuntimeError: Caught RuntimeError in DataLoader worker process 0. Original Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/worker.py", line 202, in _worker_loop data = fetcher.fetch(index) File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 47, in fetch return self.collate_fn(data) File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/collate.py", line 73, in default_collate return {key: default_collate([d[key] for d in batch]) for key in elem} File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/collate.py", line 73, in return {key: default_collate([d[key] for d in batch]) for key in elem} File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/collate.py", line 55, in default_collate return torch.stack(batch, 0, out=out) RuntimeError: stack expects each tensor to be equal size, but got [3, 400, 816] at entry 0 and [3, 560, 464] at entry 1
I've ran the same dataset on the previous commits without raising this error on scale of 1(for denoising/deblurring). My Hr_size is 256. I will try preprocess flag next time i encounter the issue.
Thanks.
The first error is that it is forcing the image size to mutiple of 4 when the scale is 1.
Secondly, even thought it has cropped/expanded the image it still gives this error as it does not scale the corresponding lr image
LOGS: The image size needs to be a multiple of 4. The loaded image size was (817, 398), so it was adjusted to (816, 400). This adjustment will be done to all images whose sizes are not multiples of 4. The image size needs to be a multiple of 4. The loaded image size was (476, 485), so it was adjusted to (476, 484). This adjustment will be done to all images whose sizes are not multiples of 4. Traceback (most recent call last): File "train.py", line 417, in
main()
File "train.py", line 413, in main
fit(model, opt, dataloaders, steps_states, data_params, loggers)
File "train.py", line 215, in fit
for n, train_data in enumerate(dataloaders['train'], start=1):
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 517, in next
data = self._next_data()
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1199, in _next_data
return self._process_data(data)
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1225, in _process_data
data.reraise()
File "/usr/local/lib/python3.7/dist-packages/torch/_utils.py", line 429, in reraise
raise self.exc_type(msg)
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/worker.py", line 202, in _worker_loop
data = fetcher.fetch(index)
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 47, in fetch
return self.collate_fn(data)
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/collate.py", line 73, in default_collate
return {key: default_collate([d[key] for d in batch]) for key in elem}
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/collate.py", line 73, in
return {key: default_collate([d[key] for d in batch]) for key in elem}
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/collate.py", line 55, in default_collate
return torch.stack(batch, 0, out=out)
RuntimeError: stack expects each tensor to be equal size, but got [3, 400, 816] at entry 0 and [3, 560, 464] at entry 1