-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into groups-conv2d
- Loading branch information
Showing
13 changed files
with
790 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Tutorial 5: How to compute FID and KID for measruing the difference between the distribution of real data and restored-data | ||
|
||
<!-- TOC --> | ||
|
||
- [Tutorial 5: How to compute FID and KID for measruing the difference between the distribution of real data and restored-data](#tutorial-5-how-to-compute-fid-and-kid-for-measruing-the-difference-between-the-distribution-of-real-data-and-restored-data) | ||
- [Why FID and KID for image restoration tasks?](#why-fid-and-kid-for-image-restoration-tasks) | ||
- [Set Config File](#set-config-file) | ||
|
||
<!-- TOC --> | ||
|
||
## Why FID and KID for image restoration tasks? | ||
|
||
Commonly used metrics for image/video resoration are PSNR, SSIM or LPIPS which directly compare high-quality original data and restored data. | ||
While these are good metrics to order the restoration performance of different models, they have the requirement that undegraded images should be given. | ||
|
||
Recently, some unpaired restoration methods have been proposed to restore real-world images in the condition where only degraded images are accessible. | ||
In this condition, it is difficult to compare the various proposed models with common metrics such as PSNR, SSIM since there is no corresponding ground-truth data. | ||
|
||
An alternative way to evaluate these models in real-world settings is to compare the distributions of real data and restored-data, rather than directly comparing corresponding images. | ||
|
||
To this end, MMEditing provides functions to compute *Fréchet inception distance* (FID) and *Kernel Inception Distance* (KID), which are commonly used in image generation tasks to check fidelity of generated images, metrics that measure the difference between the two distributions. | ||
Currently, computing FID and KID is only available for restoration tasks. | ||
|
||
## Set Config File | ||
|
||
FID and KID can be meausred after images from two distributions are extractes as feature vectors with the InceptionV3 model. | ||
|
||
To compute the distance between extracted feature vectors, we can add `FID` and `KID` metric in `test_cfg` as follow: | ||
|
||
```python3 | ||
test_cfg = dict( | ||
metrics=[ | ||
'PSNR', 'SSIM', 'FID', | ||
dict(type='KID', num_repeats=100, sample_size=1000) | ||
], | ||
inception_style='StyleGAN', # or pytorch | ||
crop_border=0) | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
from .evaluation import (DistEvalIterHook, EvalIterHook, L1Evaluation, mae, | ||
mse, psnr, reorder_image, sad, ssim) | ||
from .evaluation import (FID, KID, DistEvalIterHook, EvalIterHook, InceptionV3, | ||
L1Evaluation, mae, mse, psnr, reorder_image, sad, | ||
ssim) | ||
from .hooks import MMEditVisualizationHook, VisualizationHook | ||
from .misc import tensor2img | ||
from .optimizer import build_optimizers | ||
from .registry import build_metric | ||
from .scheduler import LinearLrUpdaterHook, ReduceLrUpdaterHook | ||
|
||
__all__ = [ | ||
'build_optimizers', 'tensor2img', 'EvalIterHook', 'DistEvalIterHook', | ||
'mse', 'psnr', 'reorder_image', 'sad', 'ssim', 'LinearLrUpdaterHook', | ||
'VisualizationHook', 'MMEditVisualizationHook', 'L1Evaluation', | ||
'ReduceLrUpdaterHook', 'mae' | ||
'VisualizationHook', 'MMEditVisualizationHook', 'L1Evaluation', 'FID', | ||
'KID', 'InceptionV3', 'build_metric', 'ReduceLrUpdaterHook', 'mae' | ||
] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
from .eval_hooks import DistEvalIterHook, EvalIterHook | ||
from .inceptions import FID, KID, InceptionV3 | ||
from .metrics import (L1Evaluation, connectivity, gradient_error, mae, mse, | ||
niqe, psnr, reorder_image, sad, ssim) | ||
|
||
__all__ = [ | ||
'mse', 'sad', 'psnr', 'reorder_image', 'ssim', 'EvalIterHook', | ||
'DistEvalIterHook', 'L1Evaluation', 'gradient_error', 'connectivity', | ||
'niqe', 'mae' | ||
'niqe', 'mae', 'FID', 'KID', 'InceptionV3' | ||
] |
This file contains 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
Oops, something went wrong.