r/LocalLLaMA · · 2 min read

Deterministic Kittens: fun with Qwen Image 2.1 on an M2 Macbook Pro

Mirrored from r/LocalLLaMA for archival readability. Support the source by reading on the original site.

Deterministic Kittens: fun with Qwen Image 2.1 on an M2 Macbook Pro

Having a blast with Qwen Image 2.1 on my M2 Macbook Pro with 32GB RAM, even though it takes 16 minutes to complete the recommended number of iterations with the resolution reduced to 1024x1024. And those are some hot minutes!

Above are some entertaining outputs. I strongly recommend stepping through the slideshow to see how the deterministic nature of Qwen Image 2.1 reveals a deep structure shared by all of these images with related prompts, even though the prompts and results are quite different. If you look carefully even the first image, the photorealistic one, shares elements with the others. The most obvious being the object at front left which appears in various forms in every image.

The prompts were all variations on "glamping cats." Unfortunately I didn't copy and paste all of them when I had the chance, which would have been better for a post about deterministic results! But some of them were:

  • glamping cats
  • cats on a glamping trip, in a modern cartoon style
  • cats on a glamping trip, in a charming illustrated style.

Notice that one of the images has an odd broken-up appearance with lines across it. This is one of the times I changed num_inference_steps to 10 to try to speed it up. Other, "illustrated-style" attempts worked fine at that setting.

There are apps that make this easier, but for those who want to follow the instructions on Qwen's page literally with a Mac, here are the steps:

* Install homebrew if you haven't (who hasn't?)

* Install python:

brew install python

Now, here is a working install script for Qwen Image 2.1. This is the script they suggest, plus activating the python environment, plus torchvision which was missing from their script:

#!/bin/bash set -e python3 -m venv qwenenv source qwenenv/bin/activate pip install --upgrade pip pip install "torch>=2.4.0" pip install "transformers>=5.17" pip install git+https://github.com/huggingface/diffusers pip install accelerate pillow torchvision 

Then change their test.py to use "mps" rather than "cuda" everywhere.

Finally here are the commands to run the test.py they provide correctly in this virtual python environment:

python3 -m venv qwenenv source qwenenv/bin/activate python test.py 

And here's test.py with one of my prompts and a resolution that takes "only" 16 minutes to finish on my Mac:

import torch from diffusers import QwenImage21Pipeline pipe = QwenImage21Pipeline.from_pretrained( "Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16 ).to("mps") # normally 40 steps, 2048 by 2048 image = pipe( prompt="cats on a glamping trip, in a modern cartoon style", width=1024, height=1024, num_inference_steps=40, generator=torch.Generator("mps").manual_seed(42), ).images[0] image.save("glamping-cats-4b.png") 

Have fun!

submitted by /u/boutell
[link] [comments]

Discussion (0)

Sign in to join the discussion. Free account, 30 seconds — email code or GitHub.

Sign in →

No comments yet. Sign in and be the first to say something.

More from r/LocalLLaMA