Skip to content

fix(datasets): weight streaming video stats by frame count - #5371

Closed
zhangyue19921010 wants to merge 2 commits into
huggingface:mainfrom
zhangyue19921010:fix/dataset-contracts-20261114
Closed

zhangyue19921010 wants to merge 2 commits into
huggingface:mainfrom
zhangyue19921010:fix/dataset-contracts-20261114

Conversation

@zhangyue19921010

@zhangyue19921010 zhangyue19921010 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary / Motivation

For newly recorded data, switching streaming_encoding between recording sessions currently weights streamed video statistics by sampled pixels while ordinary encoding uses frames. A 3-frame black episode followed by 5 white frames can produce mean 0.99961 instead of 0.625. Set the streaming episode count to its encoded frame count so RGB and depth statistics use the same aggregation weights.

Related issues

Closes #5370

Related: #4949 established frame-count weighting for the file-based image/video statistics path.

What changed

  • Override only the returned streaming statistics count after pixel moments and quantiles are computed.
  • Cover both encoding-mode transitions and same-mode controls through real create/resume recording, persisted episode counts, global mean/std and unchanged numeric statistics.
  • Force a queue-full rejection and verify statistics count only accepted encoded frames; preserve the existing no-statistics result for zero or one encoded frame.

How was this tested

  • New regression on unchanged main: 3 cases fail, the ordinary-encoding control passes. All 4 pass with the fix.
  • Focused streaming encoder, statistics, metadata and writer tests: 103 passed; 6 cancellation/clear tests deselected. The 4 regressions plus 3 additional queue-full/short-stream checks also passed.
  • The standalone Issue example reproduces the old values and verifies the corrected values.
  • Applicable pre-commit hooks passed, including configured mypy, using the existing local Node 22 hook configuration.
  • Tests used a preservation harness suppressing temporary-file deletion. Real encoding, Parquet writes and statistics ran normally; cleanup, GPU training and the full repository suite were not tested.

Checklist

  • Linting/formatting run on changed files
  • All tests pass locally (pytest; full suite not run)
  • Documentation updated (existing frame-count contract restored)
  • CI is green
  • Community Review: I have reviewed another contributor's open PR.

Copilot AI balanced review requested due to automatic review settings November 14, 2026 17:32

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions github-actions Bot added dataset Issues regarding data inputs, processing, or datasets tests Problems with test coverage, failures, or improvements to testing labels Nov 14, 2026
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@zhangyue19921010

Copy link
Copy Markdown
Contributor Author

Closing: datasets already recorded with streaming encoding store pixel-based counts, so resuming them after this change would give new episodes almost no weight in the image stats, and fixing that would need a migration across resume, merge and edit.

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

Labels

dataset Issues regarding data inputs, processing, or datasets tests Problems with test coverage, failures, or improvements to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(datasets): mixed recording modes corrupt video statistics

3 participants