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

Class AdapterResnetBlock

diffusers/src/diffusers/models/adapter.py:439–463  ·  view source on GitHub ↗

r""" An `AdapterResnetBlock` is a helper model that implements a ResNet-like block. Parameters: channels (`int`): Number of channels of AdapterResnetBlock's input and output.

Source from the content-addressed store, hash-verified

437
438
439class AdapterResnetBlock(nn.Module):
440 r"""
441 An `AdapterResnetBlock` is a helper model that implements a ResNet-like block.
442
443 Parameters:
444 channels (`int`):
445 Number of channels of AdapterResnetBlock's input and output.
446 """
447
448 def __init__(self, channels: int):
449 super().__init__()
450 self.block1 = nn.Conv2d(channels, channels, kernel_size=3, padding=1)
451 self.act = nn.ReLU()
452 self.block2 = nn.Conv2d(channels, channels, kernel_size=1)
453
454 def forward(self, x: torch.Tensor) -> torch.Tensor:
455 r"""
456 This method takes input tensor x and applies a convolutional layer, ReLU activation, and another convolutional
457 layer on the input tensor. It returns addition with the input tensor.
458 """
459
460 h = self.act(self.block1(x))
461 h = self.block2(h)
462
463 return h + x
464
465
466# light adapter

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected