jchomarat/img-generator

A tiny interactive console app for generating and editing images with [Mage-Flow](https://github.com/microsoft/Mage), Microsoft's 4B native-resolution image model, running locally on Apple Silicon (MPS).

2

stars

0

commits

Python

primary language

Jul 27, 2026

updated

README

img-generator

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.

What it does

  • New image — text-to-image with microsoft/Mage-Flow-Turbo (4 steps, cfg 1.0)
  • Edit an existing image — instruction-based editing with microsoft/Mage-Flow-Edit (30 steps, cfg 5.0)
  • Saves the result to outputs/<unix-timestamp>.png
  • Writes the questions and a progress spinner to stderr, and the final path to stdout

Requirements

  • macOS on Apple Silicon (the device is hard-coded to mps)
  • Python 3.10+
  • ~35 GB of free disk space for the model weights

Install

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_flow must be installed with --no-deps so it does not pull flash-attn, which is CUDA-only. The app works around this by forcing the sdpa attention backend before the model is loaded.

Usage

python main.py

You will be asked four questions:

QuestionDefaultNotes
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]:1024512–2048, multiple of 16
Width [1024]:1024512–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.

Example

1. Generate — leave the first question empty, prompt a cute pixel art cat sitting on a fence:

Generated pixel art cat

2. Edit — paste the path printed above, prompt make the cat bright blue:

The same cat, edited to be blue

The edit model keeps the composition, style and background intact and only applies the requested change.

Model weights and cache

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.

Project layout

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

License

MIT. The Mage-Flow models are distributed separately by Microsoft under their own MIT license.

jchomarat/img-generator

A tiny interactive console app for generating and editing images with [Mage-Flow](https://github.com/microsoft/Mage), Microsoft's 4B native-resolution image model, running locally on Apple Silicon (MPS).

2

stars

0

commits

Python

primary language

Jul 27, 2026

updated

README

img-generator

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.

What it does

  • New image — text-to-image with microsoft/Mage-Flow-Turbo (4 steps, cfg 1.0)
  • Edit an existing image — instruction-based editing with microsoft/Mage-Flow-Edit (30 steps, cfg 5.0)
  • Saves the result to outputs/<unix-timestamp>.png
  • Writes the questions and a progress spinner to stderr, and the final path to stdout

Requirements

  • macOS on Apple Silicon (the device is hard-coded to mps)
  • Python 3.10+
  • ~35 GB of free disk space for the model weights

Install

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_flow must be installed with --no-deps so it does not pull flash-attn, which is CUDA-only. The app works around this by forcing the sdpa attention backend before the model is loaded.

Usage

python main.py

You will be asked four questions:

QuestionDefaultNotes
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]:1024512–2048, multiple of 16
Width [1024]:1024512–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.

Example

1. Generate — leave the first question empty, prompt a cute pixel art cat sitting on a fence:

Generated pixel art cat

2. Edit — paste the path printed above, prompt make the cat bright blue:

The same cat, edited to be blue

The edit model keeps the composition, style and background intact and only applies the requested change.

Model weights and cache

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.

Project layout

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

License

MIT. The Mage-Flow models are distributed separately by Microsoft under their own MIT license.

Languages

Python

100.0%