MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / forward

Method forward

diffusers/scripts/convert_consistency_decoder.py:435–480  ·  view source on GitHub ↗
(self, x, t, features)

Source from the content-addressed store, hash-verified

433 self.output = ImageUnembedding()
434
435 def forward(self, x, t, features) -> torch.Tensor:
436 converted = hasattr(self, "converted") and self.converted
437
438 x = torch.cat([x, F.upsample_nearest(features, scale_factor=8)], dim=1)
439
440 if converted:
441 t = self.time_embedding(self.time_proj(t))
442 else:
443 t = self.embed_time(t)
444
445 x = self.embed_image(x)
446
447 skips = [x]
448 for i, down in enumerate(self.down):
449 if converted and i in [0, 1, 2, 3]:
450 x, skips_ = down(x, t)
451 for skip in skips_:
452 skips.append(skip)
453 else:
454 for block in down:
455 x = block(x, t)
456 skips.append(x)
457 print(x.float().abs().sum())
458
459 if converted:
460 x = self.mid(x, t)
461 else:
462 for i in range(2):
463 x = self.mid[i](x, t)
464 print(x.float().abs().sum())
465
466 for i, up in enumerate(self.up[::-1]):
467 if converted and i in [0, 1, 2, 3]:
468 skip_4 = skips.pop()
469 skip_3 = skips.pop()
470 skip_2 = skips.pop()
471 skip_1 = skips.pop()
472 skips_ = (skip_1, skip_2, skip_3, skip_4)
473 x = up(x, skips_, t)
474 else:
475 for block in up:
476 if isinstance(block, ConvResblock):
477 x = torch.concat([x, skips.pop()], dim=1)
478 x = block(x, t)
479
480 return self.output(x)
481
482
483def rename_state_dict_key(k):

Callers

nothing calls this directly

Calls 1

popMethod · 0.45

Tested by

no test coverage detected