Skip to content

update z-image#1191

Merged
helloyongyang merged 2 commits into
mainfrom
z
Jun 26, 2026
Merged

update z-image#1191
helloyongyang merged 2 commits into
mainfrom
z

Conversation

@helloyongyang

Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for image-to-image (i2i) tasks in the Z-Image model, adding a new configuration, an execution script, and updating the runner and scheduler to handle single-image inputs, denoise strength, and shape calculations. The review comments identify two critical issues: first, the scheduler calls a non-existent scale_noise method on FlowMatchEulerDiscreteScheduler, which will raise an AttributeError and should be replaced with add_noise; second, unpacking self.input_info.original_size directly can cause a TypeError if it is formatted as a tuple rather than a list, requiring more defensive type checking.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +484 to +486
latent_timestep = self.timesteps[:1]
noise = self.latents
self.latents = self.scheduler.scale_noise(image_latents, latent_timestep, noise)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The FlowMatchEulerDiscreteScheduler from the diffusers library does not have a scale_noise method. Calling it will raise an AttributeError at runtime. Instead, you should use the standard add_noise method of the scheduler, which takes (original_samples, noise, timesteps). Note that the arguments are also in a different order: add_noise(image_latents, noise, latent_timestep).

Suggested change
latent_timestep = self.timesteps[:1]
noise = self.latents
self.latents = self.scheduler.scale_noise(image_latents, latent_timestep, noise)
latent_timestep = self.timesteps[:1]
noise = self.latents
self.latents = self.scheduler.add_noise(image_latents, noise, latent_timestep)

Comment on lines +311 to +314
if self.config["task"] == "i2i" and self.input_info.original_size:
width, height = self.input_info.original_size[-1]
logger.info(f"Z Image Runner got i2i source image shape: {width}x{height}")
return (width, height)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In DefaultRunner, self.input_info.original_size is assigned as a tuple (width, height) (see default_runner.py line 295), whereas in ZImageRunner it is appended to as a list. If original_size is a tuple, accessing self.input_info.original_size[-1] will return an integer (the height), and attempting to unpack it with width, height = ... will raise a TypeError: cannot unpack non-iterable int object. Additionally, original_size might be None or missing. We should defensively check the type of original_size before unpacking.

Suggested change
if self.config["task"] == "i2i" and self.input_info.original_size:
width, height = self.input_info.original_size[-1]
logger.info(f"Z Image Runner got i2i source image shape: {width}x{height}")
return (width, height)
orig_size = getattr(self.input_info, "original_size", None)
if self.config["task"] == "i2i" and orig_size:
if isinstance(orig_size, list) and len(orig_size) > 0:
width, height = orig_size[-1]
elif isinstance(orig_size, tuple) and len(orig_size) == 2:
width, height = orig_size
else:
raise ValueError(f"Unexpected original_size format: {orig_size}")
logger.info(f"Z Image Runner got i2i source image shape: {width}x{height}")
return (width, height)

@helloyongyang helloyongyang merged commit 701914d into main Jun 26, 2026
2 checks passed
@helloyongyang helloyongyang deleted the z branch June 26, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants