Skip to content

Saving an mlx array as tiff image without having to convert to numpy first? #1559

Answered by angeloskath
kyrollosyanny asked this question in Q&A
Discussion options

You must be logged in to vote

If I had to guess, I think that you are not evaluating the mlx array which makes it seem like the model takes 0.1 seconds per image but the computation actually happens when casting to numpy. Making a numpy copy should not take a significant amount of time. If there is memory pressure and you want to avoid copying alltogether, you can cast to numpy without copy by doing np.array(x, copy=False).

See https://ml-explore.github.io/mlx/build/html/usage/lazy_evaluation.html regarding the lazy evaluation of MLX that is probably causing the confusion I described above.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kyrollosyanny
Comment options

Answer selected by kyrollosyanny
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants