ml-explore / mlx-examples

Examples in the MLX framework
MIT License
5.79k stars 823 forks source link

Stable Diffusion image2image.py fails #332

Closed SeitaroSugawara closed 7 months ago

SeitaroSugawara commented 7 months ago

When attempting to run the program, it fails with the following error:

~/repo/mlx-examples/stable_diffusion/image2image.py", line 72, in <module>
    im = Image.fromarray(x.__array__())
                         ^^^^^^^^^^^
AttributeError: 'mlx.core.array' object has no attribute '__array__'

To correct this issue, make the following changes:

# Original code
# im = Image.fromarray(x.__array__())

# Updated code
# im = Image.fromarray(x.__array__())  # Commenting out the original line
im = Image.fromarray(np.array(x))      # Converting the 'mlx.core.array' object to a NumPy array before passing to Image.fromarray
im.save(args.output)
awni commented 7 months ago

Right, somehow we missed that and only fixed it for the text to image script 🤦 . Will update it!