Skip to content

Conversation

@Lightet
Copy link

@Lightet Lightet commented Aug 15, 2025

Summary

Introduce a boolean flag preserve_border in vjepa2_preprocessor (default: False).
When set to True, the eval resize step uses short_side_size = crop_size instead of the ImageNet-style crop_size * 256/224, which otherwise guarantees extra border pixels are trimmed by the subsequent CenterCrop.

Default behavior is unchanged.

Motivation

The current eval transform:

short_side_size = int(crop_size * 256 / 224)
Resize(short_side_size) → CenterCrop(crop_size) → ClipToTensor → Normalize

always resizes the short side to a size larger than the crop_size(e.g., 256→292) and then center-crops back to crop_size, discarding border pixels.
Some downstream video tasks are sensitive to peripheral content. preserve_border=True avoids this fixed extra trimming while keeping the output shape the same.

Change

  • Add preserve_border: bool = False to vjepa2_preprocessor.
  • If preserve_border is True, set short_side_size = crop_size; otherwise keep the existing *256/224 rule.

Minimal diff
The key change is in evals/video_classification_frozen/utils.py:

-    short_side_size = int(crop_size * 256 / 224)
+    short_side_size = int(crop_size * 256 / 224) if not preserve_border else crop_size

Usage

# Old behavior (default, for strict reproduction of prior results)
aug = vjepa2_preprocessor(crop_size=256)

# Preserve borders on the short side (avoid the extra upscaling/crop)
aug = vjepa2_preprocessor(crop_size=256, preserve_border=True)

Impact

  • Backward compatible by default: leaving preserve_border=False keeps identical results.
  • Opt-in (True) may slightly shift metrics due to less trimming; final tensor shapes remain [C, T, crop_size, crop_size].

@meta-cla
Copy link

meta-cla bot commented Aug 15, 2025

Hi @Lightet!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 15, 2025
@meta-cla
Copy link

meta-cla bot commented Aug 15, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

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

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant