Skip to content

Commit 255db64

Browse files
dougbtvclaude
andcommitted
[Bugfix] Fix negative_prompt usage in z_image_examples.py
Move negative_prompt from OmniDiffusionSamplingParams to prompt dict. OmniDiffusionSamplingParams does not have a negative_prompt field, so passing it there causes TypeError at runtime. The correct pattern is to pass negative_prompt in the prompt dict, matching text_to_image.py usage. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 6cbeea9 commit 255db64

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

examples/offline_inference/text_to_image/z_image_examples.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ def z_image_base_example():
3232
omni_base = Omni(model="Tongyi-MAI/Z-Image")
3333

3434
outputs_base = omni_base.generate(
35-
"a majestic mountain landscape at sunset, detailed, photorealistic",
35+
{
36+
"prompt": "a majestic mountain landscape at sunset, detailed, photorealistic",
37+
"negative_prompt": "blurry, low quality, distorted, oversaturated",
38+
},
3639
OmniDiffusionSamplingParams(
3740
height=1280,
3841
width=720,
3942
num_inference_steps=50,
4043
guidance_scale=4.0,
41-
negative_prompt="blurry, low quality, distorted, oversaturated",
4244
seed=42,
4345
),
4446
)
@@ -93,9 +95,9 @@ def batch_inference_example():
9395
omni = Omni(model="Tongyi-MAI/Z-Image")
9496

9597
prompts = [
96-
"a cup of coffee on a wooden table",
97-
"a cat sleeping on a cozy blanket",
98-
"a futuristic city skyline at night",
98+
{"prompt": "a cup of coffee on a wooden table", "negative_prompt": "blurry, low quality"},
99+
{"prompt": "a cat sleeping on a cozy blanket", "negative_prompt": "blurry, low quality"},
100+
{"prompt": "a futuristic city skyline at night", "negative_prompt": "blurry, low quality"},
99101
]
100102

101103
# Note: These will be processed sequentially unless max_batch_size > 1
@@ -106,7 +108,6 @@ def batch_inference_example():
106108
width=1024,
107109
num_inference_steps=40,
108110
guidance_scale=4.0,
109-
negative_prompt="blurry, low quality",
110111
seed=42,
111112
),
112113
)

0 commit comments

Comments
 (0)