Skip to content

Add conditional frame control to Cosmos2 Video2World - #14908

Open
BeyondBirthday07 wants to merge 1 commit into
huggingface:mainfrom
BeyondBirthday07:fix-cosmos2-video-conditioning
Open

BeyondBirthday07 wants to merge 1 commit into
huggingface:mainfrom
BeyondBirthday07:fix-cosmos2-video-conditioning

Conversation

@BeyondBirthday07

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #14892

Cosmos2VideoToWorldPipeline currently uses the whole input video as conditioning. If a full-length video is passed, all latent frames can become conditioning frames and the pipeline ends up reconstructing the input instead of continuing it.

This adds num_latent_conditional_frames to control how much of the input video is used for conditioning.

  • 1 (default): use the last 1 input frame
  • 2: use the last 5 input frames

This follows the conditioning behavior used by the Cosmos Predict2 reference implementation and the Cosmos 2.5 pipeline.

Added tests for both conditioning modes and for invalid values.

No new dependencies.

Tests

python -m pytest tests/pipelines/cosmos/test_cosmos2_video2world.py -q
python -m ruff check src/diffusers/pipelines/cosmos/pipeline_cosmos2_video2world.py tests/pipelines/cosmos/test_cosmos2_video2world.py
python -m ruff format src/diffusers/pipelines/cosmos/pipeline_cosmos2_video2world.py tests/pipelines/cosmos/test_cosmos2_video2world.py

Result: 20 passed, 19 skipped

Before submitting

  • Did you use an AI agent (Claude Code, Codex, Cursor, etc.) to help with this PR? If so:
    • Did you read the Coding with AI agents guide?
    • Did you run the self-review skill on the diff?
    • Did you share the final self-review notes in the PR description or a comment?
  • Did you read the contributor guideline?
  • Did you read our philosophy doc? (important for complex PRs)
  • Was this discussed/approved via a GitHub issue or the forum? Please add a link to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?
  • Are you the author (or part of the team) of the model/pipeline (only applicable for model/pipeline related PRs)?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@a-r-r-o-w, @DN6

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cosmos2VideoToWorldPipeline conditions on the entire input video — no num_conditional_frames, so a full clip is reconstructed instead of continued

1 participant