Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Grid transforms #38

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

Grid transforms #38

wants to merge 22 commits into from

Conversation

mibaumgartner
Copy link
Member

@mibaumgartner mibaumgartner commented Feb 23, 2020

Short Description

Introduce Grid Transformations including:

  • GridTransform Class (generalisation of affine transforms)
  • Grid Crop
  • Elastic Deformation
  • Random Deformation
  • Radial Deformation

Current limitation: Affine Transforms need to be performed before GridTransforms

This should be merged after #31

PR Checklist

PR Implementer

This is a small checklist for the implementation details of this PR.
If you submit a PR, please look at these points (don't worry about the RisingTeam
and Reviewer workflows, the only purpose of those is to have a compact view of
the steps)

If there are any questions regarding code style or other conventions check out our
summary.

  • Implementation
  • Docstrings & Typing
  • Check __all__ sections and __init__
  • Unittests (look at the line coverage of your tests, the goal is 100%!)
  • Update notebooks & documentation if necessary
  • Pass all tests
  • Add the checksum of the last implementation commit to the Changelog

RisingTeam

RisingTeam workflow
  • Add pull request to project (optionally delete corresponding project note)
  • Assign correct label (if you don't have permission to do this, someone will do it for you.
    Please make sure to communicate the current status of the pr.)
  • Does this PR close an Issue? (add closes #IssueNumber at the bottom if
    not already in description)

Reviewer

Reviewer workflow
  • Do all tests pass? (Unittests, NotebookTests, Documentation)
  • Does the implementation follow rising design conventions?
  • Are the tests useful? (!!!) Are additional tests needed?
    Can you think of critical points which should be covered in an additional test?
  • Optional: Check coverage locally / Check tests locally if GPU is necessary to execute

@codecov
Copy link

codecov bot commented Feb 23, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@2cb2d2d). Click here to learn what that means.
The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #38   +/-   ##
=========================================
  Coverage          ?   94.58%           
=========================================
  Files             ?       36           
  Lines             ?     1423           
  Branches          ?        0           
=========================================
  Hits              ?     1346           
  Misses            ?       77           
  Partials          ?        0
Flag Coverage Δ
#unittests 94.58% <80%> (?)
Impacted Files Coverage Δ
rising/utils/affine.py 100% <100%> (ø)
rising/transforms/functional/__init__.py 100% <100%> (ø)
rising/transforms/kernel.py 100% <100%> (ø)
rising/transforms/__init__.py 100% <100%> (ø)
rising/transforms/functional/affine.py 100% <100%> (ø)
rising/transforms/grid.py 47.11% <47.11%> (ø)
rising/transforms/functional/crop.py 92.3% <82.35%> (ø)
rising/transforms/functional/kernel.py 95% <95%> (ø)
rising/transforms/affine.py 96.33% <97.61%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2cb2d2d...464e992. Read the comment docs.

Copy link
Member

@justusschock justusschock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got several questions but so far this seems to be promising.

One general question: I just realised that we often have the case that we need to check if something was already computed and if not we call a function to do the actual computation. Should we maybe think of something like a "lazy property"?

return data

@abstractmethod
def augment_grid(self, grid: Dict[Tuple, Tensor]) -> Dict[Tuple, Tensor]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this function for?
Maybe it would be better to have this return the grid per default (as done in the affines).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function gets a grid and applies its augmentation to it. It returns a grid for every spatial size which was found inside the keys

return grid

def __add__(self, other):
if not isinstance(other, GridTransform):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we also add the case, where there is just the grid provided and not wrapped with an transform?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can add that

__all__ = ["GridTransform", "StackedGridTransform"]


class GridTransform(AbstractTransform):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if I somehow get my grid from somewhere else and just want to use it? can we have an optional argument in here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it

Copy link
Member Author

@mibaumgartner mibaumgartner Feb 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, thought the upper comment was at the same position. ^^
Yeah, we can add that. I think I would prefer an extra Transform for that.

rising/transforms/grid.py Show resolved Hide resolved
if isinstance(transforms, (tuple, list)):
if isinstance(transforms[0], (tuple, list)):
transforms = transforms[0]
self.transforms = transforms
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also include a type check here which checks, that each item is a valid GridTransform?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
WIP Work in proress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FeatureRequest] Generalize affine and grid transforms to support keys with different spatial size
2 participants