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

Class LightAdapterResnetBlock

diffusers/src/diffusers/models/adapter.py:559–584  ·  view source on GitHub ↗

A `LightAdapterResnetBlock` is a helper model that implements a ResNet-like block with a slightly different architecture than `AdapterResnetBlock`. Parameters: channels (`int`): Number of channels of LightAdapterResnetBlock's input and output.

Source from the content-addressed store, hash-verified

557
558
559class LightAdapterResnetBlock(nn.Module):
560 """
561 A `LightAdapterResnetBlock` is a helper model that implements a ResNet-like block with a slightly different
562 architecture than `AdapterResnetBlock`.
563
564 Parameters:
565 channels (`int`):
566 Number of channels of LightAdapterResnetBlock's input and output.
567 """
568
569 def __init__(self, channels: int):
570 super().__init__()
571 self.block1 = nn.Conv2d(channels, channels, kernel_size=3, padding=1)
572 self.act = nn.ReLU()
573 self.block2 = nn.Conv2d(channels, channels, kernel_size=3, padding=1)
574
575 def forward(self, x: torch.Tensor) -> torch.Tensor:
576 r"""
577 This function takes input tensor x and processes it through one convolutional layer, ReLU activation, and
578 another convolutional layer and adds it to input tensor.
579 """
580
581 h = self.act(self.block1(x))
582 h = self.block2(h)
583
584 return h + x

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected