chuchichaestli.metrics.fid
FID evaluation metric, including InceptionV3 for feature mapping.
Classes:
| Name | Description |
|---|---|
FID |
Frechet inception distance. |
FIDInceptionV3 |
InceptionV3 model for calculating FIDs. |
FID
FID(
model: Module | None = None,
feature_dim: int | None = None,
device: torch.device | None = None,
n_images: int = 0,
**kwargs,
)
Bases: EvalMetric
Frechet inception distance.
Constructor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Module | None
|
Model from which to extract features. |
None
|
feature_dim
|
int | None
|
Feature dimension of the model output; if |
None
|
device
|
torch.device | None
|
Tensor allocation/computation device. |
None
|
n_images
|
int
|
Number of images seen by the internal state. |
0
|
kwargs
|
Additional keyword arguments (passed to parent class). |
{}
|
Methods:
| Name | Description |
|---|---|
compute |
Return current metric state total. |
reset |
Reset the current metrics state. |
to |
Perform tensor device conversion for all internal tensors. |
update |
Compute metric on new input and update current state. |
Attributes:
| Name | Type | Description |
|---|---|---|
feature_dim |
Feature dimension of the output. |
Source code in src/chuchichaestli/metrics/fid.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
feature_dim
property
feature_dim
Feature dimension of the output.
compute
compute() -> float
Return current metric state total.
Source code in src/chuchichaestli/metrics/fid.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
reset
reset(**kwargs)
Reset the current metrics state.
Source code in src/chuchichaestli/metrics/fid.py
207 208 209 210 211 212 213 214 215 | |
to
to(device: torch.device = None)
Perform tensor device conversion for all internal tensors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
torch.device
|
Tensor allocation/computation device. |
None
|
Source code in src/chuchichaestli/metrics/fid.py
217 218 219 220 221 222 223 224 | |
update
update(
data: torch.Tensor | None = None,
prediction: torch.Tensor | None = None,
**kwargs,
)
Compute metric on new input and update current state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
torch.Tensor | None
|
Observed (real) data. |
None
|
prediction
|
torch.Tensor | None
|
Predicted (fake) data. |
None
|
kwargs
|
Additional keyword arguments for parent class. |
{}
|
Source code in src/chuchichaestli/metrics/fid.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
FIDInceptionV3
FIDInceptionV3(
weights: tv.Inception_V3_Weights | None = None,
use_default_transforms: bool = True,
mode: str = "bilinear",
antialias: bool = False,
)
Bases: Module
InceptionV3 model for calculating FIDs.
Constructor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights
|
tv.Inception_V3_Weights | None
|
The pretrained weights for the model; for details and possible values see https://docs.pytorch.org/vision/stable/models/generated/torchvision.models.inception_v3.html#torchvision.models.Inception_V3_Weights. |
None
|
use_default_transforms
|
bool
|
If |
True
|
mode
|
str
|
If |
'bilinear'
|
antialias
|
bool
|
If |
False
|
Methods:
| Name | Description |
|---|---|
forward |
Forward method for the FIDInceptionV3 model. |
Source code in src/chuchichaestli/metrics/fid.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
forward
forward(x: torch.Tensor) -> torch.Tensor
Forward method for the FIDInceptionV3 model.
Source code in src/chuchichaestli/metrics/fid.py
66 67 68 69 70 71 72 | |