Skip to content

falk-werner/genimage

Repository files navigation

genimage

This repository contains examples how to generate images using Z-Image Turbo.

ramen

Setup

python -m venv venv
. ./venv/Scripts/activate
python -m pip install -r requirements.txt

Usage

genimage.py

Generates a single image from a given prompt.

Arguments

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

Notes

  • 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.

Example

./genimage.py -w 640 -H 480 @examples/ramen.prompt.txt

genimage_fromimage.py

Generates an image from an existing image using the provided prompt.

Arguments

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

Notes

  • 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.

Example

./genimage_fromimage.py -s 0.8 examples/stuffed-1.png @examples/stuffed-2.prompt.txt

genimage_shell.py

An interactive shell to generate images.

Comamnds

  • 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.

Example

./genimage_shell.py
genimage> generate

model_cache.py

A tool to maintain the model cache. It implements a subset of the hf tool.

Subcommands

  • 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

Arguments

Argument Type Description
-m, --model str Optional. Model to use. Default: Tongyi-MAI/Z-Image-Turbo

Examples

./model_cache.py list
./model_cache.py update
./model_cache.py remove -m "Tongyi-MAI/Z-Image-Turbo"

Examples

Bowl of Ramen

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.

Bowl of Ramen

Scene in a Circus

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.

Scene in a Circus

Happy new Year

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".

Happy new Year

Stuffed Animals

Initial Image (genimage.py)

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.

Stuffed Animals

Altered Image (genimage_fromimage.py)

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

Stuffed Animals playing Cards

References

Releases

No releases published

Packages

No packages published

Languages