MCPcopy Create free account
hub / github.com/Kosinkadink/ComfyUI-Advanced-ControlNet / LLLiteModule

Class LLLiteModule

adv_control/control_lllite.py:123–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121 #logger.error(f"set control for LLLitePatch: {id(self)}, cn: {id(control)}")
122
123 def clone_with_control(self, control: AdvancedControlBase):
124 #logger.error(f"clone-set control for LLLitePatch: {id(self)},{id(control)}")
125 return LLLitePatch(self.modules, self.patch_type, control)
126
127 def cleanup(self):
128 for module in self.modules.values():
129 module.cleanup()
130
131
132# TODO: use comfy.ops to support fp8 properly
133class LLLiteModule(torch.nn.Module):
134 def __init__(
135 self,
136 name: str,
137 is_conv2d: bool,
138 in_dim: int,
139 depth: int,
140 cond_emb_dim: int,
141 mlp_dim: int,
142 ):
143 super().__init__()
144 self.name = name
145 self.is_conv2d = is_conv2d
146 self.is_first = False
147
148 modules = []
149 modules.append(torch.nn.Conv2d(3, cond_emb_dim // 2, kernel_size=4, stride=4, padding=0)) # to latent (from VAE) size*2
150 if depth == 1:
151 modules.append(torch.nn.ReLU(inplace=True))
152 modules.append(torch.nn.Conv2d(cond_emb_dim // 2, cond_emb_dim, kernel_size=2, stride=2, padding=0))
153 elif depth == 2:
154 modules.append(torch.nn.ReLU(inplace=True))
155 modules.append(torch.nn.Conv2d(cond_emb_dim // 2, cond_emb_dim, kernel_size=4, stride=4, padding=0))
156 elif depth == 3:
157 # kernel size 8 is too large, so set it to 4
158 modules.append(torch.nn.ReLU(inplace=True))
159 modules.append(torch.nn.Conv2d(cond_emb_dim // 2, cond_emb_dim // 2, kernel_size=4, stride=4, padding=0))
160 modules.append(torch.nn.ReLU(inplace=True))
161 modules.append(torch.nn.Conv2d(cond_emb_dim // 2, cond_emb_dim, kernel_size=2, stride=2, padding=0))
162
163 self.conditioning1 = torch.nn.Sequential(*modules)
164
165 if self.is_conv2d:
166 self.down = torch.nn.Sequential(
167 torch.nn.Conv2d(in_dim, mlp_dim, kernel_size=1, stride=1, padding=0),
168 torch.nn.ReLU(inplace=True),
169 )
170 self.mid = torch.nn.Sequential(
171 torch.nn.Conv2d(mlp_dim + cond_emb_dim, mlp_dim, kernel_size=1, stride=1, padding=0),
172 torch.nn.ReLU(inplace=True),
173 )
174 self.up = torch.nn.Sequential(
175 torch.nn.Conv2d(mlp_dim, in_dim, kernel_size=1, stride=1, padding=0),
176 )
177 else:
178 self.down = torch.nn.Sequential(
179 torch.nn.Linear(in_dim, mlp_dim),
180 torch.nn.ReLU(inplace=True),

Callers 1

load_controlllliteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected