ml-explore / mlx-examples

Examples in the MLX framework
MIT License
5.84k stars 831 forks source link

Stable Diffusion txt2image.py fails #259

Closed suchanek closed 8 months ago

suchanek commented 8 months ago

Running the program fails with:

File "/Users/egs/repos/mlx-examples/stable_diffusion/txt2image.py", line 55, in im = Image.fromarray(x.array()) AttributeError: 'mlx.core.array' object has no attribute 'array'

Note that this worked in the prior release of mlx, but fails under version: mlx 0.0.7.dev202418+0b8aedd pypi_0 pypi

suchanek commented 8 months ago

Sorry, I had pasted the wrong statement. The original code that failed was:

# Save them to disc
im = Image.fromarray(x.__array__())
pudepiedj commented 8 months ago

Sorry, I had pasted the wrong statement. The original code that failed was:

# Save them to disc
im = Image.fromarray(x.__array__())

I had the same problem. Workaround using numpy but presumably it shouldn't happen if it worked in an earlier release.

import numpy as np
# this is to avoid the problem with __array__
x_numpy = np.asarray(x) # Convert mlx array to numpy array
im = Image.fromarray(x_numpy)
awni commented 8 months ago

Fix in #266, sorry for breaking that.

suchanek commented 8 months ago

Awesome, Thanks!