Skip to content

added image-gradients (#4763) [1/2]#5056

Merged
SkafteNicki merged 25 commits intoLightning-AI:release/1.2-devfrom
pranjaldatta:add-image-gradient
Jan 7, 2021
Merged

added image-gradients (#4763) [1/2]#5056
SkafteNicki merged 25 commits intoLightning-AI:release/1.2-devfrom
pranjaldatta:add-image-gradient

Conversation

@pranjaldatta
Copy link
Copy Markdown
Contributor

@pranjaldatta pranjaldatta commented Dec 10, 2020

What does this PR do?

Fixes #4763

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together? Otherwise, we ask you to create a separate PR for every change.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

PR review

Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified; Bugfixes should be including in bug-fix release milestones (m.f.X) and features should be included in (m.X.b) releases.

Did you have fun?

Make sure you had fun coding 🙃

Comment thread pytorch_lightning/metrics/functional/image_gradients.py Outdated
Comment thread pytorch_lightning/metrics/functional/image_gradients.py Outdated
Comment thread tests/metrics/functional/test_image_gradients.py
Comment thread tests/metrics/functional/test_image_gradients.py
@tchaton tchaton added this to the 1.2 milestone Dec 14, 2020
@Borda Borda changed the base branch from master to release/1.2-dev December 14, 2020 17:31
@SkafteNicki SkafteNicki added the feature Is an improvement or enhancement label Dec 14, 2020
@SkafteNicki
Copy link
Copy Markdown
Collaborator

Hi @pranjaldatta is the image gradient metric not defined as the difference between the image gradient of a ground true image and a predicted image?

@pranjaldatta
Copy link
Copy Markdown
Contributor Author

Hi @pranjaldatta is the image gradient metric not defined as the difference between the image gradient of a ground true image and a predicted image?

Hey @SkafteNicki, image-gradient functions by definition return dy/dx of a single image. (following from sklearn/TF implementations). If you are referring to a class-based (like here), that can be done, but I assumed since image-gradients are usually added as a base to loss functions like depth loss, etc., it would make more sense to have a depth-loss metric implemented separately (class and functional) and functional implementation of image-gradients that is used by these metrics and can be used otherwise also.

I wanted to add depth-loss too, but I read in the guidelines that a single PR should only cater to a single issue, hence I thought adding depth-loss would be violating those. But I'll be happy to make any changes if you could guide me a bit regarding the correct approach.

@SkafteNicki
Copy link
Copy Markdown
Collaborator

@pranjaldatta okay I better understand the purpose of this PR now.
I agree that keeping PRs as focused as possible is better as it is easier to review.
Please rename the PR like "Image gradient metric 1/n" where n should be the number of PRs you intent to do on this topic.

@pranjaldatta pranjaldatta changed the title added image-gradients (#4763) added image-gradients (#4763) [1/2] Dec 19, 2020
@pranjaldatta
Copy link
Copy Markdown
Contributor Author

Please rename the PR like "Image gradient metric 1/n" where n should be the number of PRs you intent to do on this topic.

@SkafteNicki I have changed the name of the PR. I intend on opening another Issue regarding depth-loss that builds on this. Hope this is appropriate.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 19, 2020

Codecov Report

Merging #5056 (579414f) into release/1.2-dev (5f94900) will increase coverage by 0%.
The diff coverage is 100%.

@@               Coverage Diff               @@
##           release/1.2-dev   #5056   +/-   ##
===============================================
  Coverage               93%     93%           
===============================================
  Files                  147     148    +1     
  Lines                10419   10441   +22     
===============================================
+ Hits                  9652    9674   +22     
  Misses                 767     767           

@pranjaldatta
Copy link
Copy Markdown
Contributor Author

I understand that a lot of tests are failing and I see that almost all of them have something to do with "PyTorch compiled without the CUDA version". Is this because I am using the CPU-only version of PyTorch installed via pip? How can I solve this?

Considering I am a bit of a beginner when it comes to OSS contributions, I would be incredibly grateful for a bit of help here.

CC @tchaton @SkafteNicki

@pranjaldatta pranjaldatta marked this pull request as ready for review December 21, 2020 21:09
@pranjaldatta
Copy link
Copy Markdown
Contributor Author

There is a single test failing: related to docker. I cannot understand whether the error is something to do with the code or it's some transient error. Any help is highly appreciated.

@SkafteNicki
Copy link
Copy Markdown
Collaborator

Hi @pranjaldatta, sorry for not getting back to you before now.
Failing tests are unrelated to your PR.

Could you please add a reference to your metric in https://github.com/PyTorchLightning/pytorch-lightning/blob/master/docs/source/metrics.rst
Then I think this PR is ready to be merged.

@pranjaldatta
Copy link
Copy Markdown
Contributor Author

Hey @SkafteNicki, no worries.
Regarding the addition to the doc, just to confirm, is it appropriate for me to add the reference to image gradient here, https://github.com/PyTorchLightning/pytorch-lightning/blob/master/docs/source/metrics.rst#functional-metrics-regression ? i.e. under the heading "Functional Metrics (Regression)".

@SkafteNicki
Copy link
Copy Markdown
Collaborator

Hey @SkafteNicki, no worries.
Regarding the addition to the doc, just to confirm, is it appropriate for me to add the reference to image gradient here, https://github.com/PyTorchLightning/pytorch-lightning/blob/master/docs/source/metrics.rst#functional-metrics-regression ? i.e. under the heading "Functional Metrics (Regression)".

Yes that seems to be the appropriate place. Please, also add a note in the changelog file under the "added" section.

@pranjaldatta
Copy link
Copy Markdown
Contributor Author

Hey @SkafteNicki, I have updated the docs and changelog as asked!

Copy link
Copy Markdown
Collaborator

@SkafteNicki SkafteNicki left a comment

Choose a reason for hiding this comment

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

PR is looking good :]

Comment thread pytorch_lightning/metrics/functional/image_gradients.py
Comment thread CHANGELOG.md Outdated
Comment thread pytorch_lightning/metrics/functional/image_gradients.py Outdated
Comment thread pytorch_lightning/metrics/functional/image_gradients.py Outdated
Comment thread pytorch_lightning/metrics/functional/image_gradients.py Outdated
Comment thread tests/metrics/functional/test_image_gradients.py Outdated
Comment thread tests/metrics/functional/test_image_gradients.py Outdated
Comment thread tests/metrics/functional/test_image_gradients.py Outdated
Comment thread tests/metrics/functional/test_image_gradients.py Outdated
pranjaldatta and others added 4 commits January 1, 2021 19:37
Co-authored-by: Nicki Skafte <skaftenicki@gmail.com>
Co-authored-by: Nicki Skafte <skaftenicki@gmail.com>
Co-authored-by: Nicki Skafte <skaftenicki@gmail.com>
@pranjaldatta
Copy link
Copy Markdown
Contributor Author

@SkafteNicki added a commit making all the recommended changes.

Copy link
Copy Markdown
Collaborator

@SkafteNicki SkafteNicki left a comment

Choose a reason for hiding this comment

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

LGTM

@SkafteNicki SkafteNicki added the ready to be merged PRs ready to be merged label Jan 1, 2021
@Borda
Copy link
Copy Markdown
Collaborator

Borda commented Jan 4, 2021

@pranjaldatta I still see many comments and sure if they are implemented or not, mind chek them and if they are done, pls mark them as resolved...

@pranjaldatta
Copy link
Copy Markdown
Contributor Author

@Borda Sorry about the clutter, all the conversations had been solved with the last commit. Have resolved all of them now!

@Borda Borda requested a review from tchaton January 6, 2021 20:20
Comment thread CHANGELOG.md
Comment thread pytorch_lightning/metrics/functional/image_gradients.py
Comment thread pytorch_lightning/metrics/functional/image_gradients.py
Comment thread pytorch_lightning/metrics/functional/image_gradients.py Outdated
@pranjaldatta
Copy link
Copy Markdown
Contributor Author

@Borda I have made the changes via the last commit!

Comment thread pytorch_lightning/metrics/functional/image_gradients.py
@SkafteNicki SkafteNicki merged commit 06f3609 into Lightning-AI:release/1.2-dev Jan 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Is an improvement or enhancement ready to be merged PRs ready to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Metrics] Add Image Gradient

7 participants