[Bugfix][Diffusion] Make Cosmos3 transfer image arrays writable (#6915)

Signed-off-by: Rahul Steiger <rsteiger@nvl72d179-T17.cm.cluster>
Co-authored-by: Rahul Steiger <rsteiger@nvl72d179-T17.cm.cluster>
Co-authored-by: Rahul Steiger <rsteiger@aws-cmh-slurm-1-vscode-04.cm.cluster>
This commit is contained in:
authored and GitHub committed 2026-09-07 01:06:16 -07:00
1 parent 91dfafcaab
commit 677265b64b
2 files changed
+17 -2

No files matched your search

@@ -1180,6 +1180,21 @@ def test_transfer_fps_matches_resolved_frame_rate_precedence() -> None:
assert cfg.fps == sp.resolved_frame_rate == 12.0
@pytest.mark.parametrize("use_path", [False, True], ids=["image", "path"])
def test_transfer_pil_conversion_returns_writable_array(tmp_path, use_path: bool) -> None:
from vllm_omni.diffusion.models.cosmos3 import transfer
image = Image.new("RGB", (5, 4), "red")
value = image
if use_path:
value = tmp_path / "control.png"
image.save(value)
array = transfer._pil_to_uint8_rgb(value)
assert array.flags.writeable
def test_transfer_vae_executor_requires_distributed_vae() -> None:
from vllm_omni.diffusion.models.cosmos3.pipeline_cosmos3 import Cosmos3OmniDiffusersPipeline
@@ -439,9 +439,9 @@ def uint8_cthw_to_normalized_5d(frames: torch.Tensor, *, dtype: torch.dtype) ->
def _pil_to_uint8_rgb(value: Any) -> np.ndarray:
if isinstance(value, PIL.Image.Image):
return np.asarray(value.convert("RGB"), dtype=np.uint8)
return np.array(value.convert("RGB"), dtype=np.uint8, copy=True)
if isinstance(value, str | Path):
return np.asarray(PIL.Image.open(value).convert("RGB"), dtype=np.uint8)
return np.array(PIL.Image.open(value).convert("RGB"), dtype=np.uint8, copy=True)
if isinstance(value, torch.Tensor):
tensor = value.detach().cpu()
if tensor.ndim == 3 and tensor.shape[0] in (3, 4):