Skip to content

Commit af1eb58

Browse files
Fix black images on some flux models in fp16. (comfyanonymous#8495)
1 parent 373a938 commit af1eb58

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

comfy/ldm/flux/model.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ def block_wrap(args):
187187
if add is not None:
188188
img[:, txt.shape[1] :, ...] += add
189189

190+
if img.dtype == torch.float16:
191+
img = torch.nan_to_num(img, nan=0.0, posinf=65504, neginf=-65504)
192+
190193
img = img[:, txt.shape[1] :, ...]
191194

192195
img = self.final_layer(img, vec) # (N, T, patch_size ** 2 * out_channels)

0 commit comments

Comments
 (0)