ml-explore / mlx-examples

Examples in the MLX framework
MIT License
5.57k stars 798 forks source link

Issue with Image2Image [Stable Diffusion] #575

Closed yzimmermann closed 4 months ago

yzimmermann commented 4 months ago

When I run image2image.py from stable_diffusion with the strength parameter set to < 0.5 I get the following error:

Warning: image shape is not divisible by 64, downsampling to 448x448 0it [00:00, ?it/s] 0%| | 0/4 [00:00<?, ?it/s] Traceback (most recent call last): File "/Users/mlx-examples/stable_diffusion/image2image.py", line 93, in decoded.append(sd.decode(x_t[i : i + args.decoding_batch_size])) ^^^ NameError: name 'x_t' is not defined

When I run it with strength >= 0.5, everything works fine.

angeloskath commented 4 months ago

Very good point. Since the default steps for SDXL are 2 then running with strength 0.1 ends up with 0 steps int(strength * steps). I will make a fix shortly but in the mean time you can pass a larger number of steps.