[REFACT]Refactor diffusion outputs to payload metadata (#4922)

Signed-off-by: bjf-frz <frz123db@gmail.com>
This commit is contained in:
bjf-frz authored and GitHub committed 2026-07-14 17:24:03 +08:00
1 parent 4b9d09cb87
commit 1a4a042a83
44 files changed
+1373 -478

No files matched your search

@@ -836,8 +836,10 @@ class LancePipeline(BagelPipeline):
frames = [Image.fromarray(f) for f in frames_np]
logger.info("Lance t2v: decoded %d frames at %dx%d", len(frames), frames[0].width, frames[0].height)
return DiffusionOutput(
output=frames[0],
custom_output={"video_frames": frames, "video_shape": video_shape},
output={
"payload": {"video": frames},
"metadata": {"video": {"shape": video_shape}},
},
stage_durations=self.stage_durations if hasattr(self, "stage_durations") else None,
)
@@ -1069,13 +1071,11 @@ class LancePipeline(BagelPipeline):
)
img = self._decode_image_from_latent(self.bagel, self.vae, latents[0], image_shape)
# Put the PIL image into ``custom_output`` too — the orchestrator
# serializes ``custom_output`` across the IPC boundary but strips
# the bare ``output`` field, so consumers that only see
# ``outputs[0].output`` (e.g. gradio_demo) get ``None`` otherwise.
return DiffusionOutput(
output=img,
custom_output={"image": img, "image_shape": image_shape},
output={
"payload": {"image": img},
"metadata": {"image": {"shape": image_shape}},
},
stage_durations=self.stage_durations if hasattr(self, "stage_durations") else None,
)
@@ -1361,8 +1361,10 @@ class LancePipeline(BagelPipeline):
frames_np = self._decode_video_from_latent(self.bagel, self.vae, latents[0], out_shape)
frames = [Image.fromarray(f) for f in frames_np]
return DiffusionOutput(
output=frames[0],
custom_output={"video_frames": frames, "video_shape": out_shape},
output={
"payload": {"video": frames},
"metadata": {"video": {"shape": out_shape}},
},
stage_durations=self.stage_durations if hasattr(self, "stage_durations") else None,
)
@@ -1622,8 +1624,10 @@ class LancePipeline(BagelPipeline):
frames_np = self._decode_video_from_latent(self.bagel, self.vae, latents[0], video_shape)
frames = [Image.fromarray(f) for f in frames_np]
return DiffusionOutput(
output=frames[0],
custom_output={"video_frames": frames, "video_shape": video_shape},
output={
"payload": {"video": frames},
"metadata": {"video": {"shape": video_shape}},
},
stage_durations=self.stage_durations if hasattr(self, "stage_durations") else None,
)
@@ -1705,8 +1709,10 @@ class LancePipeline(BagelPipeline):
text_output = text_output.lstrip("\n")
logger.info("Lance x2t_video: generated %d tokens", token_ids.shape[0])
return DiffusionOutput(
output=text_output,
custom_output={"text_output": text_output},
output={
"payload": {"text": text_output},
"metadata": {"text": {"text_output": text_output}},
},
stage_durations=self.stage_durations if hasattr(self, "stage_durations") else None,
)
@@ -1801,8 +1807,10 @@ class LancePipeline(BagelPipeline):
text_output = text_output.lstrip("\n")
logger.info("Lance x2t_image: generated %d tokens", token_ids.shape[0])
return DiffusionOutput(
output=text_output,
custom_output={"text_output": text_output},
output={
"payload": {"text": text_output},
"metadata": {"text": {"text_output": text_output}},
},
stage_durations=self.stage_durations if hasattr(self, "stage_durations") else None,
)