update z-image#1191
Conversation
There was a problem hiding this comment.
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.
| latent_timestep = self.timesteps[:1] | ||
| noise = self.latents | ||
| self.latents = self.scheduler.scale_noise(image_latents, latent_timestep, noise) |
There was a problem hiding this comment.
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).
| 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) |
| 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) |
There was a problem hiding this comment.
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.
| 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) |
No description provided.