jdit.assessment¶
FID¶
-
jdit.assessment.
FID_score
(source, target, sample_prop=1.0, gpu_ids=(), dim=2048, batchsize=128, verbose=True)[source]¶ Compute FID score from
Tensor
,DataLoader
or a directory``path``.Parameters: - source – source data.
- target – target data.
- sample_prop – If passing a
Tensor
source, set this rate to sample a part of data from source. - gpu_ids – gpu ids.
- dim –
The number of features. Three options available.
- 64: The first max pooling features of Inception.
- 192: The Second max pooling features of Inception.
- 768: The Pre-aux classifier features of Inception.
- 2048: The Final average pooling features of Inception.
Default: 2048.
- batchsize – Only using for passing paths of source and target.
- verbose – If show processing log.
Returns: fid score
Attention
If you are passing
Tensor
as source and target. Make sure you have enough memory to load these data in _InceptionV3. Otherwise, please passingpath
ofDataLoader
to compute them step by step.Example:
>>> from jdit.dataset import Cifar10 >>> loader = Cifar10(root=r"../../datasets/cifar10", batch_shape=(32, 3, 32, 32)) >>> target_tensor = loader.samples_train[0] >>> source_tensor = loader.samples_valid[0] >>> # using Tensor to compute FID score >>> fid_value = FID_score(source_tensor, target_tensor, sample_prop=0.01, depth=768) >>> print('FID: ', fid_value) >>> # using DataLoader to compute FID score >>> fid_value = FID_score(loader.loader_test, loader.loader_valid, depth=768) >>> print('FID: ', fid_value)