Skip to content

Commit 2e299a1

Browse files
committed
Merge branch 'gabrielrotbart-fix_img2img_m1' into main
This may improve the black image problem when using img2img with some samplers on M1 hardware.
2 parents 3ee82d8 + 0b582a4 commit 2e299a1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ldm/simplet2i.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,14 @@ def process_image(image,seed):
280280
), 'can only work with strength in [0.0, 1.0]'
281281

282282
width, height, _ = self._resolution_check(width, height, log=True)
283-
scope = autocast if self.precision == 'autocast' else nullcontext
283+
284+
# TODO: - Check if this is still necessary to run on M1 devices.
285+
# - Move code into ldm.dream.devices to live alongside other
286+
# special-hardware casing code.
287+
if self.precision == 'autocast' and torch.cuda.is_available():
288+
scope = autocast
289+
else:
290+
scope = nullcontext
284291

285292
if sampler_name and (sampler_name != self.sampler_name):
286293
self.sampler_name = sampler_name

0 commit comments

Comments
 (0)