This repository contains examples how to generate images using Z-Image Turbo.
python -m venv venv
. ./venv/Scripts/activate
python -m pip install -r requirements.txtGenerates a single image from a given prompt.
| Argument | Type | Description |
|---|---|---|
| -m, --model | str | Optional. Model to use. Default: Tongyi-MAI/Z-Image-Turbo |
| -w, --width | int | Optional. Width of the image in pixels. Default: 1024 |
| -H, --height | int | Optional. Height of the image in pixels. Default: 768 |
| -n, --negative_prompt | str | Optional. Negative prompt. Default: empty |
| -g, --guidance_scale | float | Optional. Guidance scale. Default: 0.0 |
| -o, --output | str | Optional. Name of the output file. Default: out.png |
| prompt | str | Prompt used to generate image |
- Height must be a multiple of 16.
- When the prompt or negative prompt starts with
@it is treated as a path of a file to load the prompt from. - When a negative prompt is provided, the guidance scale is set to a minimum of 1.0.
(since the negative prompt would be ignored with a guidance scale lesser than 1) - A large guidance scale will lower the image quality.
./genimage.py -w 640 -H 480 @examples/ramen.prompt.txtGenerates an image from an existing image using the provided prompt.
| Argument | Type | Description |
|---|---|---|
| -w, --width | int | Optional. Width of the image in pixels. Default: Width of initial image |
| -H, --height | int | Optional. Height of the image in pixels. Default: Height of initial image |
| -n, --negative_prompt | str | Optional. Negative prompt. Default: empty |
| -g, --guidance_scale | float | Optional. Guidance scale. Default: 0.0 |
| -s, --strength | float | Optional. Strength how much the initial image is changed. Default: 0.6 |
| -o, --output | str | Optional. Name of the output file. Default: out.png |
| image | str | Path of the initial image |
| prompt | str | Prompt used to generate image |
- Height must be a multiple of 16.
- When the prompt or negative prompt starts with
@it is treated as a path of a file to load the prompt from. - When a negative prompt is provided, the guidance scale is set to a minimum of 1.0.
(since the negative prompt would be ignored with a guidance scale lesser than 1) - A large guidance scale will lower the image quality.
- Strength must be between 0 and 1, where 1 means that the original image is not used.
./genimage_fromimage.py -s 0.8 examples/stuffed-1.png @examples/stuffed-2.prompt.txtAn interactive shell to generate images.
- set_promtfile PROMP
Sets the name of the file containing the prompt to generate the image.
Default: prompt.txt - set_height HEIGHT
Sets the height of the image in pixels.
Default: 768
Note: Must be a multiple of 16 - set_width WIDTH
Sets the width of the image in pixels.
Default: 1024 - flip
Switches width and height. - info
Prints general information. - generate
Generates an image. - save FILENAME
Saves the current image and the prompt. - exit
Quits the shell.
./genimage_shell.py
genimage> generateA tool to maintain the model cache. It implements a subset of the hf tool.
- list (default command)
Lists the currently cached models - update
Updates the specified model
Default: Tongyi-MAI/Z-Image-Turbo - remove
Removed the specified model Default: Tongyi-MAI/Z-Image-Turbo
| Argument | Type | Description |
|---|---|---|
| -m, --model | str | Optional. Model to use. Default: Tongyi-MAI/Z-Image-Turbo |
./model_cache.py list
./model_cache.py update
./model_cache.py remove -m "Tongyi-MAI/Z-Image-Turbo"An oil painting of a bowl of ramen.
The bowl is blue with a white pattern.
It stands on a table of dark wood.
It is steaming hot.
On the left side of the bowl is an egg.
On the right side of the bowl are two slices of ham.
A scene in a circus.
On the right side stands the directory holding a buring ring.
The director is a lion in a gentlemans suite.
In the middle is a clown jumping thourgh the ring the director is holding.
On the left is a tiger riding an monowheel. He is juggling three balls with his paws.
There are many children in crown enjoing the show.
A dark and clear night on a clearing in a winter forest.
A pig is sitting on a chair. It is wearing a monocle and a top hat.
It is also wearing a gentlemans suite.
It is holding a glass of champagner in his paw.
There is a small table with a bottle of champanger.
A heavy firework is illuminating the sky.
The firework has many different colors.
There is a golden firework forming the words "Happy new Year 2026".
Three stuffed animals before a white background.
On the left side is a stuffed rabit.
In the middle is a stuffed bear.
On the right side is a stuffed cat.
Three stuffed animals are playing cards on a table.
They are sitting on a table of dark wood.
On the left side is a stuffed rabit.
In the middle is a stuffed bear.
On the right side is a stuffed cat.
Used strength: 0.8
- https://huggingface.co/Tongyi-MAI/Z-Image-Turbo
- https://huggingface.co/docs/diffusers/main/api/pipelines/z_image#diffusers.ZImagePipeline
- https://huggingface.co/docs/huggingface_hub/guides/download
- https://huggingface.co/docs/huggingface_hub/package_reference/cache#huggingface_hub.scan_cache_dir
- https://huggingface.co/docs/huggingface_hub/package_reference/cache#huggingface_hub.HFCacheInfo.delete_revisions
- https://huggingface.co/docs/huggingface_hub/guides/cli




