Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fast Image Processors for mobileViT #37112

Closed
wants to merge 0 commits into from

Conversation

MinJu-Ha
Copy link
Contributor

related to #36978
cc: @yonigozlan

I added Fast image processor for mobileViT and I noticed a noticeable difference between the outputs after preprocessing.

Here’s the code I used to compare them:

diff = (encoding_slow.pixel_values - encoding_fast.pixel_values).abs()
print(f"\n📊 Difference statistics:")
print(f"  Max difference: {diff.max().item():.10f}")
print(f"  Mean difference: {diff.mean().item():.10f}")
print(f"  Slow min/max: {encoding_slow.pixel_values.min().item():.10f} ~ {encoding_slow.pixel_values.max().item():.10f}")
print(f"  Fast min/max: {encoding_fast.pixel_values.min().item():.10f} ~ {encoding_fast.pixel_values.max().item():.10f}")
print(f"Slow implementation dtype: {encoding_slow.pixel_values.dtype}")
print(f"Fast implementation dtype: {encoding_fast.pixel_values.dtype}")

results:

📊 Difference statistics: 
  Max difference: 0.3411765397
  Mean difference: 0.1117687449
  Slow min/max: 0.0313725509 ~ 0.9764705896
  Fast min/max: 0.0313725509 ~ 0.9764706492
Slow implementation dtype: torch.float32
Fast implementation dtype: torch.float32

Even though the size configs look the same ({'shortest_edge': 20}), and both use torch.float32, the output difference seems quite significant for a slow/fast equivalence test.

@MinJu-Ha MinJu-Ha closed this Mar 31, 2025
@MinJu-Ha MinJu-Ha deleted the mobileViT branch March 31, 2025 13:43
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.

1 participant