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

transformers.image_transforms.normalize documents and checks for the wrong type for std and mean arguments #35772

Closed
1 of 4 tasks
CalOmnie opened this issue Jan 19, 2025 · 2 comments · Fixed by #35773
Closed
1 of 4 tasks
Labels

Comments

@CalOmnie
Copy link
Contributor

System Info

  • transformers version: 4.49.0.dev0
  • Platform: Linux-6.8.0-51-generic-x86_64-with-glibc2.39
  • Python version: 3.11.11
  • Huggingface_hub version: 0.27.1
  • Safetensors version: 0.5.1
  • Accelerate version: 1.2.1
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.5.1+cu124 (True)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using distributed or parallel set-up in script?: Neither
  • Using GPU in script?: No
  • GPU type: NVIDIA GeForce GTX 1060 6GB

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

import numpy as np
from transformers.image_transforms import normalize

mock_img = np.random.rand(3, 10, 10)

# Simulating getting the std and mean from text
std = map(float, "1.5 0. 2.".split())
mean = map(float, "1.5 0. 2.".split())
# According to the doc, this setup should work, but it does not since "map" does not implement `len`

normalize(mock_img, std, mean)

Expected behavior

Use the Sequence type instead of Iterable to let users know that len needs to be implemented.

@CalOmnie
Copy link
Contributor Author

CalOmnie commented Jan 19, 2025

Question: Am I following the right process to submit very small fix that do not impact the runtime (e.g. typing and documentations)? I noticed a few other mistypes while reading the code and I'd like to do it properly going forward.

@Rocketknight1
Copy link
Member

Hi @CalOmnie, yes, this was good! For small fixes when the issue is clear, like bugs or obviously incorrect types, you can just submit a PR. We recommend opening an issue first when the change might be controversial or need discussion (for example, adding a whole new model class, or changing the behaviour of existing tools)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants