MCPcopy Create free account
hub / github.com/CompVis/zigma / update

Method update

utils/torchmetric_kid.py:233–245  ·  view source on GitHub ↗

Update the state with extracted features. Args: imgs: tensor with images feed to the feature extractor real: bool indicating if ``imgs`` belong to the real or the fake distribution

(self, imgs: Tensor, real: bool)

Source from the content-addressed store, hash-verified

231 self.add_state("fake_features", [], dist_reduce_fx=None)
232
233 def update(self, imgs: Tensor, real: bool) -> None: # type: ignore
234 """Update the state with extracted features.
235
236 Args:
237 imgs: tensor with images feed to the feature extractor
238 real: bool indicating if ``imgs`` belong to the real or the fake distribution
239 """
240 features = self.inception(imgs)
241
242 if real:
243 self.real_features.append(features)
244 else:
245 self.fake_features.append(features)
246
247 def compute(self) -> Tuple[Tensor, Tensor]:
248 """Calculate KID score based on accumulated extracted features from the two distributions. Returns a tuple

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected