Skip to content

Commit fc6ff67

Browse files
committed
go back to using np.cov for fid score calculation
1 parent 2a2fc83 commit fc6ff67

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

denoising_diffusion_pytorch/denoising_diffusion_pytorch.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
from accelerate import Accelerator
2626

27+
import numpy as np
2728
from pytorch_fid.inception import InceptionV3
2829
from pytorch_fid.fid_score import calculate_frechet_distance
2930

@@ -950,10 +951,10 @@ def calculate_activation_statistics(self, samples):
950951
assert exists(self.inception_v3)
951952

952953
features = self.inception_v3(samples)[0]
953-
features = rearrange(features, '... 1 1 -> ...')
954+
features = rearrange(features, '... 1 1 -> ...').cpu().numpy()
954955

955-
mu = torch.mean(features, dim = 0).cpu()
956-
sigma = torch.cov(rearrange(features, '... i j -> ... j i')).cpu()
956+
mu = np.mean(features, axis = 0)
957+
sigma = np.cov(features, rowvar = False)
957958
return mu, sigma
958959

959960
def fid_score(self, real_samples, fake_samples):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.5.7'
1+
__version__ = '1.5.8'

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
'accelerate',
2121
'einops',
2222
'ema-pytorch',
23+
'numpy',
2324
'pillow',
2425
'pytorch-fid',
2526
'torch',

0 commit comments

Comments
 (0)