-
-
Notifications
You must be signed in to change notification settings - Fork 650
Fid Metric #2029
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
Fid Metric #2029
Conversation
Mypy error is cause scipy and torchvision do not exist in typeshed |
nvm.... found the fix. Updated mypy.ini file. |
ignite/metrics/gan/fid.py
Outdated
|
||
class InceptionExtractor: | ||
def __init__(self) -> None: | ||
from torchvision import models |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should tnink better how to handle this dependency without making it as a hard requirement.
) -> float: | ||
|
||
diff = mu1 - mu2 | ||
import scipy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very unfriendly way to do things. This method is called after 1 epoch done and user get ImportError after some computational time. We should avoid this way of coding things!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just means that we have updated the mean and covariance based on all the training example given by user so far. Even if compute gives error as soon as user imports scipy they can rerun it and no computation done previously is lost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case where fid_score function is independently invoked, there is no extra computation so all cases are covered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use exception and a user friendly message whether scipy
is missing.
from sklearn.metrics import cohen_kappa_score # noqa: F401 |
ignite/metrics/gan/fid.py
Outdated
from ignite.metric.GAN import FID | ||
import torch | ||
|
||
train, test = torch.rand(10,2048), torch.rand(10,2048) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it relevant as shape for the standard FID metric ?
Namings as train, test seem to be unconventional, we can put either put y_pred
/y
or fake
/real
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FID is not just for image generation but also augmentation, style and feature transfer. In such cases real or fake is not appropriate. I will use y_pred
/y
instead.
ignite/metrics/gan/fid.py
Outdated
self.model.eval() | ||
|
||
def __call__(self, data: torch.Tensor) -> torch.Tensor: | ||
if data.shape[1:] != (3, 299, 299): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If inception model is headless (no fully-connected layer), can't we use any size input. In the metric code we just have to ensure that we always have the same size...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
299x299 is minimum size of image needed and what is used for standard Inception model while calculating fid and IS. I can change it to >= 299 if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If inception model is headless (no fully-connected layer), can't we use any size input.
That's right !
In the metric code we just have to ensure that we always have the same size...
The user gives the feature size, so there is a test on shapes during iteration.
requirements-dev.txt
Outdated
pynvml | ||
clearml | ||
scikit-image | ||
py-rouge | ||
nltk | ||
pytorch_fid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have it twice. See above.
Friendly advice:
For more info about running tests and running distributed tests: https://github.com/pytorch/ignite/blob/master/CONTRIBUTING.md#run-tests
Hope my advice helps you. |
Description:
First implementation and tests for the FID metric.
Check list: