Skip to content

Clean up usage of the deprecated mode parameter. #9170

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

drivanov
Copy link

@drivanov drivanov commented Aug 6, 2025

While testing the latest version of the NVIDIA PYG container, we encountered the following issue:

    img = F.adjust_hue(img, hue_factor)
/usr/local/lib/python3.12/dist-packages/torchvision/transforms/functional.py:968: in adjust_hue
    return F_pil.adjust_hue(img, hue_factor)
/usr/local/lib/python3.12/dist-packages/torchvision/transforms/_functional_pil.py:116: in adjust_hue
    h = Image.fromarray(np_h, "L")
/usr/local/lib/python3.12/dist-packages/PIL/Image.py:3314: in fromarray
    deprecate("'mode' parameter", 13)

. . .
.
E       DeprecationWarning: 'mode' parameter is deprecated and will be removed in Pillow 13 (2026-10-15)

/usr/local/lib/python3.12/dist-packages/PIL/_deprecate.py:68: DeprecationWarning

From what I can see here, the fromarray function expects the mode parameter to be None only.

Notes:

  • The line numbers in PIL/Image.py have changed slightly.
  • Line 116 in torchvision/transforms/_functional_pil.py has also been updated:

It used to be:

h = Image.fromarray(np_h, "L")

and is now:

h = _Image_fromarray(np_h, "L")

As a result, we should remove the usage of the mode parameter in line 254 of torchvision/utils.py:

def _Image_fromarray(
    obj: np.ndarray,
    mode: str,
) -> Image.Image:

. . . 
   return Image.fromarray(obj, mode)

Copy link

pytorch-bot bot commented Aug 6, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9170

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

Copy link

meta-cla bot commented Aug 6, 2025

Hi @drivanov!

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!

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