[Feature] Support SWD and MS-SSIM metrics#82
Open
LeoXing1996 wants to merge 12 commits intoopen-mmlab:mainfrom
Open
[Feature] Support SWD and MS-SSIM metrics#82LeoXing1996 wants to merge 12 commits intoopen-mmlab:mainfrom
LeoXing1996 wants to merge 12 commits intoopen-mmlab:mainfrom
Conversation
7 tasks
C1rN09
reviewed
Feb 13, 2023
C1rN09
reviewed
Feb 21, 2023
6c17aa5 to
dc0e23f
Compare
C1rN09
reviewed
Mar 8, 2023
dc0e23f to
fb3387e
Compare
b84f63f to
cc9d889
Compare
C1rN09
approved these changes
Mar 9, 2023
Collaborator
C1rN09
left a comment
There was a problem hiding this comment.
LGTM with 1 minor comment
zhouzaida
reviewed
Mar 14, 2023
0095367 to
1f4675b
Compare
zhouzaida
reviewed
Mar 14, 2023
zhouzaida
reviewed
Mar 14, 2023
zhouzaida
reviewed
Mar 14, 2023
Collaborator
|
Hi, have you verified the PR in mmediting? |
zhouzaida
reviewed
Mar 15, 2023
Comment on lines
+252
to
+253
| tuple: Pair containing the mean SSIM and contrast sensitivity | ||
| between `img1` and `img2`. |
Collaborator
There was a problem hiding this comment.
Suggested change
| tuple: Pair containing the mean SSIM and contrast sensitivity | |
| between `img1` and `img2`. | |
| tuple: Pair containing the mean SSIM and contrast sensitivity | |
| between `img1` and `img2`. |
zhouzaida
reviewed
Mar 15, 2023
Comment on lines
+10
to
+19
| """SWD (Sliced Wasserstein distance) metric. We calculate the SWD of two | ||
| sets of images in the following way. In every 'feed', we obtain the | ||
| Laplacian pyramids of every images and extract patches from the Laplacian | ||
| pyramids as descriptors. In 'summary', we normalize these descriptors along | ||
| channel, and reshape them so that we can use these descriptors to represent | ||
| the distribution of real/fake images. And we can calculate the sliced | ||
| Wasserstein distance of the real and fake descriptors as the SWD of the | ||
| real and fake images. Note that, as with the official implementation, we | ||
| multiply the result by 10 to prevent the value from being too small and to | ||
| facilitate comparison. |
Collaborator
There was a problem hiding this comment.
Suggested change
| """SWD (Sliced Wasserstein distance) metric. We calculate the SWD of two | |
| sets of images in the following way. In every 'feed', we obtain the | |
| Laplacian pyramids of every images and extract patches from the Laplacian | |
| pyramids as descriptors. In 'summary', we normalize these descriptors along | |
| channel, and reshape them so that we can use these descriptors to represent | |
| the distribution of real/fake images. And we can calculate the sliced | |
| Wasserstein distance of the real and fake descriptors as the SWD of the | |
| real and fake images. Note that, as with the official implementation, we | |
| multiply the result by 10 to prevent the value from being too small and to | |
| facilitate comparison. | |
| """SWD (Sliced Wasserstein distance) metric. | |
| We calculate the SWD of two sets of images in the following way. In every | |
| 'feed', we obtain the Laplacian pyramids of every image and extract patches | |
| from the Laplacian pyramids as descriptors. In 'summary', we normalize | |
| these descriptors along channel, and reshape them so that we can use | |
| these descriptors to represent the distribution of real/fake images. And | |
| we can calculate the sliced Wasserstein distance of the real and fake | |
| descriptors as the SWD of the real and fake images. Note that, as with the | |
| official implementation, we multiply the result by 10 to prevent the value | |
| from being too small and to facilitate comparison. |
zhouzaida
reviewed
Mar 15, 2023
| self.gaussian_k) | ||
|
|
||
| # init list to save fake desp and real desp | ||
| if self._results == []: |
Collaborator
There was a problem hiding this comment.
Suggested change
| if self._results == []: | |
| if not self._results: |
zhouzaida
reviewed
Mar 15, 2023
Comment on lines
+141
to
+142
| del real_descs | ||
| del fake_descs |
Collaborator
There was a problem hiding this comment.
Is it necessary to delete them immediately?
zhouzaida
reviewed
Mar 15, 2023
| self.dir_repeats = 4 # times of sampling directions | ||
| self.dirs_per_repeat = 128 # number of directions per sampling | ||
|
|
||
| self.resolution = resolution |
Collaborator
There was a problem hiding this comment.
This variable is not used.
zhouzaida
reviewed
Mar 15, 2023
Comment on lines
+60
to
+62
| while resolution >= 16 and len(self._resolutions) < 4: | ||
| self._resolutions.append(resolution) | ||
| resolution //= 2 |
Collaborator
There was a problem hiding this comment.
What will happen if resolution is less than 16?
zhouzaida
reviewed
Mar 15, 2023
|
|
||
| Returns: Dict[str, float]: The computed SWD metric. | ||
| """ | ||
| results_fake, results_real = results |
Collaborator
There was a problem hiding this comment.
Suggested change
| results_fake, results_real = results | |
| fake_results, real_results = results |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
Motivation
Support SWD and MS-SSIM.
Modification
As title.
BC-breaking (Optional)
Does the modification introduce changes that break the backward-compatibility of the downstream repos?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.
Use cases (Optional)
If this PR introduces a new feature, it is better to list some use cases here, and update the documentation.
Checklist