Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
f40a554
1
Parent(s):
652ea2c
modified: src/flux/modules/layers.py
Browse files- src/flux/__pycache__/__init__.cpython-310.pyc +0 -0
- src/flux/__pycache__/_version.cpython-310.pyc +0 -0
- src/flux/__pycache__/math.cpython-310.pyc +0 -0
- src/flux/__pycache__/model.cpython-310.pyc +0 -0
- src/flux/__pycache__/sampling.cpython-310.pyc +0 -0
- src/flux/__pycache__/util.cpython-310.pyc +0 -0
- src/flux/modules/__pycache__/autoencoder.cpython-310.pyc +0 -0
- src/flux/modules/__pycache__/conditioner.cpython-310.pyc +0 -0
- src/flux/modules/__pycache__/layers.cpython-310.pyc +0 -0
- src/flux/modules/layers.py +12 -4
src/flux/__pycache__/__init__.cpython-310.pyc
CHANGED
|
Binary files a/src/flux/__pycache__/__init__.cpython-310.pyc and b/src/flux/__pycache__/__init__.cpython-310.pyc differ
|
|
|
src/flux/__pycache__/_version.cpython-310.pyc
CHANGED
|
Binary files a/src/flux/__pycache__/_version.cpython-310.pyc and b/src/flux/__pycache__/_version.cpython-310.pyc differ
|
|
|
src/flux/__pycache__/math.cpython-310.pyc
CHANGED
|
Binary files a/src/flux/__pycache__/math.cpython-310.pyc and b/src/flux/__pycache__/math.cpython-310.pyc differ
|
|
|
src/flux/__pycache__/model.cpython-310.pyc
CHANGED
|
Binary files a/src/flux/__pycache__/model.cpython-310.pyc and b/src/flux/__pycache__/model.cpython-310.pyc differ
|
|
|
src/flux/__pycache__/sampling.cpython-310.pyc
CHANGED
|
Binary files a/src/flux/__pycache__/sampling.cpython-310.pyc and b/src/flux/__pycache__/sampling.cpython-310.pyc differ
|
|
|
src/flux/__pycache__/util.cpython-310.pyc
CHANGED
|
Binary files a/src/flux/__pycache__/util.cpython-310.pyc and b/src/flux/__pycache__/util.cpython-310.pyc differ
|
|
|
src/flux/modules/__pycache__/autoencoder.cpython-310.pyc
CHANGED
|
Binary files a/src/flux/modules/__pycache__/autoencoder.cpython-310.pyc and b/src/flux/modules/__pycache__/autoencoder.cpython-310.pyc differ
|
|
|
src/flux/modules/__pycache__/conditioner.cpython-310.pyc
CHANGED
|
Binary files a/src/flux/modules/__pycache__/conditioner.cpython-310.pyc and b/src/flux/modules/__pycache__/conditioner.cpython-310.pyc differ
|
|
|
src/flux/modules/__pycache__/layers.cpython-310.pyc
CHANGED
|
Binary files a/src/flux/modules/__pycache__/layers.cpython-310.pyc and b/src/flux/modules/__pycache__/layers.cpython-310.pyc differ
|
|
|
src/flux/modules/layers.py
CHANGED
|
@@ -159,6 +159,11 @@ class DoubleStreamBlock(nn.Module):
|
|
| 159 |
|
| 160 |
def forward(self, img: Tensor, txt: Tensor, vec: Tensor, pe: Tensor, cur_step: int, info) -> tuple[Tensor, Tensor]:
|
| 161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
img_mod1, img_mod2 = self.img_mod(vec)
|
| 163 |
txt_mod1, txt_mod2 = self.txt_mod(vec)
|
| 164 |
|
|
@@ -170,21 +175,24 @@ class DoubleStreamBlock(nn.Module):
|
|
| 170 |
|
| 171 |
img_q, img_k = self.img_attn.norm(img_q, img_k, img_v)
|
| 172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
# prepare txt for attention
|
| 174 |
txt_modulated = self.txt_norm1(txt)
|
| 175 |
txt_modulated = (1 + txt_mod1.scale) * txt_modulated + txt_mod1.shift
|
| 176 |
txt_qkv = self.txt_attn.qkv(txt_modulated)
|
| 177 |
txt_q, txt_k, txt_v = rearrange(txt_qkv, "B L (K H D) -> K B H L D", K=3, H=self.num_heads)
|
| 178 |
txt_q, txt_k = self.txt_attn.norm(txt_q, txt_k, txt_v)
|
| 179 |
-
|
|
|
|
| 180 |
# run actual attention
|
| 181 |
q = torch.cat((txt_q, img_q), dim=2) #[8, 24, 512, 128] + [8, 24, 900, 128] -> [8, 24, 1412, 128]
|
| 182 |
k = torch.cat((txt_k, img_k), dim=2)
|
| 183 |
v = torch.cat((txt_v, img_v), dim=2)
|
| 184 |
# import pdb;pdb.set_trace()
|
| 185 |
-
|
| 186 |
-
print(f"k_{cur_step}:{k}")
|
| 187 |
-
print(f"v_{cur_step}:{v}")
|
| 188 |
|
| 189 |
# if using adaptive attention guidance during samping
|
| 190 |
if not info['inverse'] and 'attn_guidance' in info['editing_strategy']:
|
|
|
|
| 159 |
|
| 160 |
def forward(self, img: Tensor, txt: Tensor, vec: Tensor, pe: Tensor, cur_step: int, info) -> tuple[Tensor, Tensor]:
|
| 161 |
|
| 162 |
+
print(f"img_{cur_step}:{img}")
|
| 163 |
+
print(f"txt_{cur_step}:{txt}")
|
| 164 |
+
print(f"vec_{cur_step}:{vec}")
|
| 165 |
+
print(f"pe_{cur_step}:{pe}")
|
| 166 |
+
|
| 167 |
img_mod1, img_mod2 = self.img_mod(vec)
|
| 168 |
txt_mod1, txt_mod2 = self.txt_mod(vec)
|
| 169 |
|
|
|
|
| 175 |
|
| 176 |
img_q, img_k = self.img_attn.norm(img_q, img_k, img_v)
|
| 177 |
|
| 178 |
+
print(f"img_modulated_{cur_step}:{img_modulated}")
|
| 179 |
+
print(f"img_qkv_{cur_step}:{img_qkv}")
|
| 180 |
+
print(f"img_q_{cur_step}:{img_q}")
|
| 181 |
+
print(f"img_k_{cur_step}:{img_k}")
|
| 182 |
# prepare txt for attention
|
| 183 |
txt_modulated = self.txt_norm1(txt)
|
| 184 |
txt_modulated = (1 + txt_mod1.scale) * txt_modulated + txt_mod1.shift
|
| 185 |
txt_qkv = self.txt_attn.qkv(txt_modulated)
|
| 186 |
txt_q, txt_k, txt_v = rearrange(txt_qkv, "B L (K H D) -> K B H L D", K=3, H=self.num_heads)
|
| 187 |
txt_q, txt_k = self.txt_attn.norm(txt_q, txt_k, txt_v)
|
| 188 |
+
print(f"txt_q_{cur_step}:{txt_q}")
|
| 189 |
+
print(f"txt_k_{cur_step}:{txt_k}")
|
| 190 |
# run actual attention
|
| 191 |
q = torch.cat((txt_q, img_q), dim=2) #[8, 24, 512, 128] + [8, 24, 900, 128] -> [8, 24, 1412, 128]
|
| 192 |
k = torch.cat((txt_k, img_k), dim=2)
|
| 193 |
v = torch.cat((txt_v, img_v), dim=2)
|
| 194 |
# import pdb;pdb.set_trace()
|
| 195 |
+
|
|
|
|
|
|
|
| 196 |
|
| 197 |
# if using adaptive attention guidance during samping
|
| 198 |
if not info['inverse'] and 'attn_guidance' in info['editing_strategy']:
|