Skip to content

Conversation

@ammarjmahmood
Copy link

What does this PR do?

Fixes the default interpolation method for EfficientNet image processor from NEAREST to BICUBIC to match the original TensorFlow implementation.

Motivation

As pointed out in #28180 to check the models in the list, the EfficientNet image processor was using NEAREST interpolation , but the original TensorFlow implementation uses BICUBIC by default.

The _resize_image() function in the original code explicitly uses tf.image.resize_bicubic as the default resize method.

Changes

  • Changed default resample parameter from PIL.Image.NEAREST to PILImageResampling.BICUBIC
  • All related docstrings (lines 69, 136, 154)

Fixes #28180 (partial - for EfficientNet model)


Before submitting

cc @yonigozlan @molbap (vision models reviewers)

…ntation in the code

Original method --> Bicubic\
Source: tpu/models/official/efficientnet/preprocessing.py
	Function def _resize_image() Line 88
- Changed default resample from Nearest to BICUBIC
- Original Tensorflow implementation uses resize_bicubic by default in original code
- Fixes Issue huggingface#28180
- Reorder imports in metaclip_2 conversion script to satisfy ruff formatter
- Remove -> None annotation from EfficientNetImageProcessor.__init__ to match docstring checker expectations
@github-actions
Copy link
Contributor

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

run-slow: efficientnet, metaclip_2

Copy link
Member

@yonigozlan yonigozlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to merge this as it is indeed the wrong default, however you also have to change it for the fast image processor!

self.include_top = include_top

# Copied from transformers.models.vit.image_processing_vit.ViTImageProcessor.resize with PILImageResampling.BILINEAR->PILImageResampling.NEAREST
# Method for resize bicubic interpolation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Method for resize bicubic interpolation


# Import MetaCLIP modules
from src.mini_clip.factory import create_model_and_transforms

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be reverted

@@ -0,0 +1,579 @@
# Image Processor Interpolation Method Verification Guide
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To delete!

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.

Verify interpolation of image processors

2 participants