A tiny interactive console app for generating and editing images with Mage-Flow, Microsoft's 4B native-resolution image model, running locally on Apple Silicon (MPS).
It asks four questions, hides every library log and progress bar, and prints only the path of the produced image on stdout — so it composes cleanly with other commands.
microsoft/Mage-Flow-Turbo (4 steps, cfg 1.0)microsoft/Mage-Flow-Edit
(30 steps, cfg 5.0)outputs/<unix-timestamp>.pngmps)python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install --no-deps "mage_flow @ git+https://github.com/microsoft/Mage.git@72afb404e5bbd9769a383a37926a26438e23e16f#subdirectory=mage_flow"
mage_flowmust be installed with--no-depsso it does not pullflash-attn, which is CUDA-only. The app works around this by forcing thesdpaattention backend before the model is loaded.
python main.py
You will be asked four questions:
| Question | Default | Notes |
|---|---|---|
Image to edit (leave empty to create a new image): | (empty) | Empty → generate a new image. Otherwise paste or drag-and-drop the path of the image to edit. |
Prompt: | — | Required. The description (new image) or the instruction (edit). |
Height [1024]: | 1024 | 512–2048, multiple of 16 |
Width [1024]: | 1024 | 512–2048, multiple of 16 |
The last line printed is the path of the new image:
$ python main.py
Image to edit (leave empty to create a new image):
Prompt: a cute pixel art cat sitting on a fence
Height [1024]:
Width [1024]:
/Users/you/img-generator/outputs/1785146469.png
Because the path is the only thing on stdout, you can pipe it straight into other tools:
open "$(python main.py)"
python main.py > last-image.txt
Exit codes: 0 on success, 1 on failure, 130 on Ctrl-C.
1. Generate — leave the first question empty, prompt
a cute pixel art cat sitting on a fence:
2. Edit — paste the path printed above, prompt make the cat bright blue:
The edit model keeps the composition, style and background intact and only applies the requested change.
Weights are not stored in this repository. On first use they are downloaded from the Hugging Face Hub into the standard cache:
~/.cache/huggingface/hub/
├── models--microsoft--Mage-Flow-Turbo # text-to-image
└── models--microsoft--Mage-Flow-Edit # image editing
Together they take roughly 33 GB. The first run of each mode downloads its model and is
therefore much slower; later runs load straight from the cache. Set HF_HOME to move the
cache elsewhere, and delete the directories above to free the space.
main.py the app
snippet.py minimal standalone generation sample
requirements.txt pinned dependencies
outputs/ generated images (git-ignored)
docs/images/ images used by this README
MIT. The Mage-Flow models are distributed separately by Microsoft under their own MIT license.
Python
100.0%
A tiny interactive console app for generating and editing images with Mage-Flow, Microsoft's 4B native-resolution image model, running locally on Apple Silicon (MPS).
It asks four questions, hides every library log and progress bar, and prints only the path of the produced image on stdout — so it composes cleanly with other commands.
microsoft/Mage-Flow-Turbo (4 steps, cfg 1.0)microsoft/Mage-Flow-Edit
(30 steps, cfg 5.0)outputs/<unix-timestamp>.pngmps)python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install --no-deps "mage_flow @ git+https://github.com/microsoft/Mage.git@72afb404e5bbd9769a383a37926a26438e23e16f#subdirectory=mage_flow"
mage_flowmust be installed with--no-depsso it does not pullflash-attn, which is CUDA-only. The app works around this by forcing thesdpaattention backend before the model is loaded.
python main.py
You will be asked four questions:
| Question | Default | Notes |
|---|---|---|
Image to edit (leave empty to create a new image): | (empty) | Empty → generate a new image. Otherwise paste or drag-and-drop the path of the image to edit. |
Prompt: | — | Required. The description (new image) or the instruction (edit). |
Height [1024]: | 1024 | 512–2048, multiple of 16 |
Width [1024]: | 1024 | 512–2048, multiple of 16 |
The last line printed is the path of the new image:
$ python main.py
Image to edit (leave empty to create a new image):
Prompt: a cute pixel art cat sitting on a fence
Height [1024]:
Width [1024]:
/Users/you/img-generator/outputs/1785146469.png
Because the path is the only thing on stdout, you can pipe it straight into other tools:
open "$(python main.py)"
python main.py > last-image.txt
Exit codes: 0 on success, 1 on failure, 130 on Ctrl-C.
1. Generate — leave the first question empty, prompt
a cute pixel art cat sitting on a fence:
2. Edit — paste the path printed above, prompt make the cat bright blue:
The edit model keeps the composition, style and background intact and only applies the requested change.
Weights are not stored in this repository. On first use they are downloaded from the Hugging Face Hub into the standard cache:
~/.cache/huggingface/hub/
├── models--microsoft--Mage-Flow-Turbo # text-to-image
└── models--microsoft--Mage-Flow-Edit # image editing
Together they take roughly 33 GB. The first run of each mode downloads its model and is
therefore much slower; later runs load straight from the cache. Set HF_HOME to move the
cache elsewhere, and delete the directories above to free the space.
main.py the app
snippet.py minimal standalone generation sample
requirements.txt pinned dependencies
outputs/ generated images (git-ignored)
docs/images/ images used by this README
MIT. The Mage-Flow models are distributed separately by Microsoft under their own MIT license.
Python
100.0%