mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-05 18:07:03 +08:00
fix by ruff check
This commit is contained in:
parent
3a59a6e28b
commit
7a7a5ea323
@ -250,14 +250,14 @@ class VaceWanAttentionBlock(WanAttentionBlock):
|
|||||||
class WanCamAdapter(nn.Module):
|
class WanCamAdapter(nn.Module):
|
||||||
def __init__(self, in_dim, out_dim, kernel_size, stride, num_residual_blocks=1, operation_settings={}):
|
def __init__(self, in_dim, out_dim, kernel_size, stride, num_residual_blocks=1, operation_settings={}):
|
||||||
super(WanCamAdapter, self).__init__()
|
super(WanCamAdapter, self).__init__()
|
||||||
|
|
||||||
# Pixel Unshuffle: reduce spatial dimensions by a factor of 8
|
# Pixel Unshuffle: reduce spatial dimensions by a factor of 8
|
||||||
self.pixel_unshuffle = nn.PixelUnshuffle(downscale_factor=8)
|
self.pixel_unshuffle = nn.PixelUnshuffle(downscale_factor=8)
|
||||||
|
|
||||||
# Convolution: reduce spatial dimensions by a factor
|
# Convolution: reduce spatial dimensions by a factor
|
||||||
# of 2 (without overlap)
|
# of 2 (without overlap)
|
||||||
self.conv = operation_settings.get("operations").Conv2d(in_dim * 64, out_dim, kernel_size=kernel_size, stride=stride, padding=0, device=operation_settings.get("device"), dtype=operation_settings.get("dtype"))
|
self.conv = operation_settings.get("operations").Conv2d(in_dim * 64, out_dim, kernel_size=kernel_size, stride=stride, padding=0, device=operation_settings.get("device"), dtype=operation_settings.get("dtype"))
|
||||||
|
|
||||||
# Residual blocks for feature extraction
|
# Residual blocks for feature extraction
|
||||||
self.residual_blocks = nn.Sequential(
|
self.residual_blocks = nn.Sequential(
|
||||||
*[WanCamResidualBlock(out_dim, operation_settings = operation_settings) for _ in range(num_residual_blocks)]
|
*[WanCamResidualBlock(out_dim, operation_settings = operation_settings) for _ in range(num_residual_blocks)]
|
||||||
@ -267,19 +267,19 @@ class WanCamAdapter(nn.Module):
|
|||||||
# Reshape to merge the frame dimension into batch
|
# Reshape to merge the frame dimension into batch
|
||||||
bs, c, f, h, w = x.size()
|
bs, c, f, h, w = x.size()
|
||||||
x = x.permute(0, 2, 1, 3, 4).contiguous().view(bs * f, c, h, w)
|
x = x.permute(0, 2, 1, 3, 4).contiguous().view(bs * f, c, h, w)
|
||||||
|
|
||||||
# Pixel Unshuffle operation
|
# Pixel Unshuffle operation
|
||||||
x_unshuffled = self.pixel_unshuffle(x)
|
x_unshuffled = self.pixel_unshuffle(x)
|
||||||
|
|
||||||
# Convolution operation
|
# Convolution operation
|
||||||
x_conv = self.conv(x_unshuffled)
|
x_conv = self.conv(x_unshuffled)
|
||||||
|
|
||||||
# Feature extraction with residual blocks
|
# Feature extraction with residual blocks
|
||||||
out = self.residual_blocks(x_conv)
|
out = self.residual_blocks(x_conv)
|
||||||
|
|
||||||
# Reshape to restore original bf dimension
|
# Reshape to restore original bf dimension
|
||||||
out = out.view(bs, f, out.size(1), out.size(2), out.size(3))
|
out = out.view(bs, f, out.size(1), out.size(2), out.size(3))
|
||||||
|
|
||||||
# Permute dimensions to reorder (if needed), e.g., swap channels and feature frames
|
# Permute dimensions to reorder (if needed), e.g., swap channels and feature frames
|
||||||
out = out.permute(0, 2, 1, 3, 4)
|
out = out.permute(0, 2, 1, 3, 4)
|
||||||
|
|
||||||
@ -779,4 +779,4 @@ class CameraWanModel(WanModel):
|
|||||||
|
|
||||||
# unpatchify
|
# unpatchify
|
||||||
x = self.unpatchify(x, grid_sizes)
|
x = self.unpatchify(x, grid_sizes)
|
||||||
return x
|
return x
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user