MCPcopy Create free account
hub / github.com/tinygrad/tinygrad / FidInceptionV3

Class FidInceptionV3

extra/models/inception.py:241–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239 return Tensor.cat(*outputs, dim=1)
240
241class FidInceptionV3:
242 m1: Optional[np.ndarray] = None
243 s1: Optional[np.ndarray] = None
244
245 def __init__(self):
246 inception = Inception3(cls_map={
247 "A": FidInceptionA,
248 "C": FidInceptionC,
249 "E1": FidInceptionE1,
250 "E2": FidInceptionE2,
251 })
252
253 self.Conv2d_1a_3x3 = inception.Conv2d_1a_3x3
254 self.Conv2d_2a_3x3 = inception.Conv2d_2a_3x3
255 self.Conv2d_2b_3x3 = inception.Conv2d_2b_3x3
256
257 self.Conv2d_3b_1x1 = inception.Conv2d_3b_1x1
258 self.Conv2d_4a_3x3 = inception.Conv2d_4a_3x3
259
260 self.Mixed_5b = inception.Mixed_5b
261 self.Mixed_5c = inception.Mixed_5c
262 self.Mixed_5d = inception.Mixed_5d
263 self.Mixed_6a = inception.Mixed_6a
264 self.Mixed_6b = inception.Mixed_6b
265 self.Mixed_6c = inception.Mixed_6c
266 self.Mixed_6d = inception.Mixed_6d
267 self.Mixed_6e = inception.Mixed_6e
268
269 self.Mixed_7a = inception.Mixed_7a
270 self.Mixed_7b = inception.Mixed_7b
271 self.Mixed_7c = inception.Mixed_7c
272
273 def load_from_pretrained(self, path=None):
274 if path is None:
275 path = fetch("https://github.com/mseitzer/pytorch-fid/releases/download/fid_weights/pt_inception-2015-12-05-6726825d.pth", "pt_inception-2015-12-05-6726825d.pth")
276 state_dict = torch_load(str(path))
277 for k,v in state_dict.items():
278 if k.endswith(".num_batches_tracked"):
279 state_dict[k] = v.reshape(1)
280 load_state_dict(self, state_dict)
281 return self
282
283 def __call__(self, x:Tensor) -> Tensor:
284 x = x.interpolate((299,299), mode="linear")
285 x = (x * 2) - 1
286 x = x.sequential([
287 self.Conv2d_1a_3x3,
288 self.Conv2d_2a_3x3,
289 self.Conv2d_2b_3x3,
290 lambda x: Tensor.max_pool2d(x, kernel_size=(3,3), stride=2, dilation=1),
291
292 self.Conv2d_3b_1x1,
293 self.Conv2d_4a_3x3,
294 lambda x: Tensor.max_pool2d(x, kernel_size=(3,3), stride=2, dilation=1),
295
296 self.Mixed_5b,
297 self.Mixed_5c,
298 self.Mixed_5d,

Callers 1

eval_stable_diffusionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…