Skip to content

Conversation

@raimbekovm
Copy link
Contributor

Summary

The original Vision Transformer implementation uses BICUBIC interpolation for image preprocessing, but the HuggingFace image processor defaulted to BILINEAR. This PR aligns the default with the original implementation.

Changes

  • Update default resample from BILINEAR to BICUBIC in ViTImageProcessor
  • Update default resample in ViTImageProcessorFast
  • Update docstrings to reflect BICUBIC as the default

Reference

Related Issue

Fixes part of #28180

Testing

The original Vision Transformer implementation uses BICUBIC interpolation
for image preprocessing, but the HuggingFace image processor defaulted to
BILINEAR. This change aligns the default with the original implementation.

Changes:
- Update default resample from BILINEAR to BICUBIC in ViTImageProcessor
- Update default resample in ViTImageProcessorFast
- Update docstrings to reflect BICUBIC

Reference: https://github.com/huggingface/pytorch-image-models
Fixes part of huggingface#28180
These models copy the resize method from ViT, so they need to be updated
to match the new BICUBIC default interpolation.
@github-actions
Copy link
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: efficientnet, imagegpt, layoutlmv2, layoutlmv3, pvt, segformer, vit

@raimbekovm
Copy link
Contributor Author

Quick clarification on the file changes:

The second commit updates 6 additional models because they copy ViT's resize method. After changing ViT from BILINEAR to BICUBIC, these copies needed to stay in sync.

This PR complements the ongoing interpolation fixes (#28180) by @lukepayyapilli for other models.

Let me know if any changes are needed!

@CodersAcademy006
Copy link

This makes sense and aligns ViT preprocessing with expected defaults (e.g. TIMM). Since this changes a default behavior, it might be worth explicitly calling it out as a breaking change for users relying on the previous interpolation. A small regression test asserting the default resampling value could also help prevent accidental future changes.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants