-
Notifications
You must be signed in to change notification settings - Fork 34
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
collate_fn is not handled properly in TorchNonGeoDataModule #325
Comments
The root cause might be that in init() of TorchNonGeoDataModule, terratorch/terratorch/datamodules/torchgeo_data_module.py Lines 80 to 81 in 4a0afc2
terratorch/terratorch/datamodules/torchgeo_data_module.py Lines 87 to 89 in 4a0afc2
|
My tentative solution is to make an instance of
|
@paolofraccaro suggested an idea that instead of instantiating
This does not work because overwriting to terratorch/terratorch/datamodules/torchgeo_data_module.py Lines 87 to 89 in 4a0afc2
|
Another idea is to swap two lines as follows.
and also modifying the setter function as follows to avoid reference to undefined variable
The latter method is employed in commit d51af02. |
Describe the issue
When terratorch.datamodules.TorchNonGeoDataModule creates an instance of given Torchgeo datamodule which specifies it's collation function to
collate_fn
parameter, the specified parameter is ignored and initialized with NonGeoDataModule's default collation functiondefault_collate()
defined in torch.utils.data (https://github.com/microsoft/torchgeo/blob/801e94746f9fe9d1b84b4220c3eb2fc8248a59a8/torchgeo/datamodules/geo.py#L387).
For example,
torchgeo.datamodules.VHR10DataModule
wants to use it's owncollate_fn_detection()
(see https://github.com/microsoft/torchgeo/blob/main/torchgeo/datamodules/vhr10.py#L53) to handle unequal sized sample data.To Reproduce (optional, but appreciated)
Screenshots or log output (optional)
You may see in the first line of the output that
collate_fn
is initialized withdefault_collate()
function.In this case, the error is occurring with batch['image'] data, and we may avoid this by resizing all image data to same size. However, because VHR10 dataset is for object detection task, and all label data might be in different sizes (according to the number of found objects).
The text was updated successfully, but these errors were encountered: