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

Convert all index transforms to Kornia #999

Merged
merged 12 commits into from
Jan 23, 2023
Merged

Convert all index transforms to Kornia #999

merged 12 commits into from
Jan 23, 2023

Conversation

adamjstewart
Copy link
Collaborator

@adamjstewart adamjstewart commented Jan 4, 2023

This PR converts all of our index transforms to be valid Kornia augmentations. These transforms can now be used with AugmentationSequential just like all of the other transforms we use.

@adamjstewart adamjstewart added this to the 0.4.0 milestone Jan 4, 2023
@github-actions github-actions bot added testing Continuous integration testing transforms Data augmentation transforms documentation Improvements or additions to documentation labels Jan 4, 2023
@adamjstewart adamjstewart added the backwards-incompatible Changes that are not backwards compatible label Jan 4, 2023
@adamjstewart adamjstewart marked this pull request as ready for review January 4, 2023 22:17
@adamjstewart
Copy link
Collaborator Author

Can't get the dimensions to work in the transforms tutorial, please help.

@nilsleh
Copy link
Collaborator

nilsleh commented Jan 8, 2023

Can't get the dimensions to work in the transforms tutorial, please help.

The only thing I can get to work is to match the size dimension of the input.

class MinMaxNormalize(K.IntensityAugmentationBase2D):
    """Normalize channels to the range [0, 1] using min/max values."""

    def __init__(self, mins: Tensor, maxs: Tensor) -> None:
        super().__init__(p=1)
        self.flags = {
            "mins": mins.view(1, mins.shape[0], 1, 1), 
            "maxs": maxs.view(1, maxs.shape[0], 1, 1)
        }

    def apply_transform(
        self,
        input: Tensor,
        params: Dict[str, Tensor],
        flags: Dict[str, int],
        transform: Optional[Tensor] = None,
) -> Tensor:
        return (input - flags["mins"]) / (flags["maxs"] - flags["mins"] + 1e-10)

@adamjstewart
Copy link
Collaborator Author

Well, all the dims work now, but the plotted image is all black. Not sure what changed to cause that.

@github-actions github-actions bot added the datasets Geospatial or benchmark datasets label Jan 13, 2023
@calebrob6
Copy link
Member

calebrob6 commented Jan 22, 2023

Heads up that running transforms.ipynb breaks because the SSL cert for the EuroSat dataset expired. I'm wondering whether we want to add a UserWarning or something about this?

calebrob6
calebrob6 previously approved these changes Jan 22, 2023
@calebrob6 calebrob6 merged commit 6cd3267 into main Jan 23, 2023
@calebrob6 calebrob6 deleted the transforms/indices branch January 23, 2023 05:05
yichiac pushed a commit to yichiac/torchgeo that referenced this pull request Apr 29, 2023
* Convert all index transforms to Kornia

* Fix tests too

* Fix docs build

* Update tutorial

* Update transforms tutorial

* Kornia augs add new batch dimension

* Expand dims

* Fix one more set of transforms

* Escape quotes

* Remove unneeded transform

* Kornia transforms require float images

* Fix device problems

Co-authored-by: Caleb Robinson <calebrob6@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backwards-incompatible Changes that are not backwards compatible datasets Geospatial or benchmark datasets documentation Improvements or additions to documentation testing Continuous integration testing transforms Data augmentation transforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants