Remove some useless code.

This commit is contained in:
comfyanonymous
2024-12-20 17:43:50 -05:00
parent e946667216
commit b5fe39211a
2 changed files with 13 additions and 199 deletions

View File

@@ -12,10 +12,20 @@ from .blocks import (
T2IFinalLayer,
SizeEmbedder,
)
from comfy.ldm.modules.diffusionmodules.mmdit import TimestepEmbedder, PatchEmbed, Mlp
from .pixart import PixArt, get_2d_sincos_pos_embed_torch
from comfy.ldm.modules.diffusionmodules.mmdit import TimestepEmbedder, PatchEmbed, Mlp, get_1d_sincos_pos_embed_from_grid_torch
def get_2d_sincos_pos_embed_torch(embed_dim, w, h, pe_interpolation=1.0, base_size=16, device=None, dtype=torch.float32):
grid_h, grid_w = torch.meshgrid(
torch.arange(h, device=device, dtype=dtype) / (h/base_size) / pe_interpolation,
torch.arange(w, device=device, dtype=dtype) / (w/base_size) / pe_interpolation,
indexing='ij'
)
emb_h = get_1d_sincos_pos_embed_from_grid_torch(embed_dim // 2, grid_h, device=device, dtype=dtype)
emb_w = get_1d_sincos_pos_embed_from_grid_torch(embed_dim // 2, grid_w, device=device, dtype=dtype)
emb = torch.cat([emb_w, emb_h], dim=1) # (H*W, D)
return emb
class PixArtMSBlock(nn.Module):
"""
A PixArt block with adaptive layer norm zero (adaLN-Zero) conditioning.
@@ -53,7 +63,7 @@ class PixArtMSBlock(nn.Module):
### Core PixArt Model ###
class PixArtMS(PixArt):
class PixArtMS(nn.Module):
"""
Diffusion model with a Transformer backbone.
"""