transformers - ✅(Solved) Fix Nonexistant import from image_utils [1 pull requests, 8 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
huggingface/transformers#44933Fetched 2026-04-08 01:16:55
View on GitHub
Comments
8
Participants
3
Timeline
13
Reactions
0
Author
Timeline (top)
commented ×8cross-referenced ×2labeled ×1mentioned ×1

Error Message

I was getting the following error when running the latest version of main you'll get the error

Fix Action

Fixed

PR fix notes

PR #44958: fixed import error with PILImageResampling

Description (problem / solution / changelog)

What does this PR do?

Fixes an import in src/transformers/video_processing_utils.py that was causing the main build to fail

Fixes # 44933

Code Agent Policy

The Transformers repo is currently being overwhelmed by a large number of PRs and issue comments written by code agents. We are currently bottlenecked by our ability to review and respond to them. As a result, we ask that new users do not submit pure code agent PRs at this time. You may use code agents in drafting or to help you diagnose issues. We'd also ask autonomous "OpenClaw"-like agents not to open any PRs or issues for the moment.

PRs that appear to be fully agent-written will probably be closed without review, and we may block users who do this repeatedly or maliciously.

This is a rapidly-evolving situation that's causing significant shockwaves in the open-source community. As a result, this policy is likely to be updated regularly in the near future. For more information, please read CONTRIBUTING.md.

  • I confirm that this is not a pure code agent PR.

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @ If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**. Please tag fewer than 3 people. Models: - text models: @ArthurZucker @Cyrilvallez - vision models: @yonigozlan @molbap - audio models: @eustlb @ebezzam @vasqu - multimodal models: @zucchini-nlp - graph models: @clefourrier Library: - generate: @zucchini-nlp (visual-language models) or @gante (all others) - continuous batching: @remi-or @ArthurZucker @McPatate - pipelines: @Rocketknight1 - tokenizers: @ArthurZucker and @itazap - trainer: @SunMarc - attention: @vasqu @ArthurZucker @CyrilVallez - model loading (from pretrained, etc): @CyrilVallez - distributed: @3outeille @ArthurZucker - CIs: @ydshieh Integrations: - ray/raytune: @richardliaw, @amogkam - Big Model Inference: @SunMarc - quantization: @SunMarc - kernels: @drbh - peft: @BenjaminBossan @githubnemo Devices/Backends: - AMD ROCm: @ivarflakstad - Intel XPU: @IlyasMoutawwakil - Ascend NPU: @ivarflakstad Documentation: @stevhliu Research projects are not maintained and should be taken as is. -->

Changed files

  • src/transformers/video_processing_utils.py (modified, +3/-2)
RAW_BUFFERClick to expand / collapse

System Info

I was getting the following error when running the latest version of main

ImportError: cannot import name 'PILImageResampling' from 'transformers.image_utils' (/Users/josh/Documents/sandbox/.hugging/lib/python3.12/site-packages/transformers/image_utils.py)

I found where it's being imported in src/transformers/video_processing_utils.py and it looks like this package isn't being used in video_processing_utils.py nor is it defined in image_utils.py

commenting out the import in video_processing_utils fixed the issue

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

  1. install tranformers from source uv pip install '.[torch]'
  2. run transformers serve
  3. run chat cli transformers chat Qwen/Qwen3-4B

you'll get the error ImportError: cannot import name 'PILImageResampling' from 'transformers.image_utils'

Expected behavior

  1. install tranformers from source uv pip install '.[torch]'
  2. run transformers serve
  3. run chat cli transformers chat Qwen/Qwen3-4B

the chat runs as expected

extent analysis

Fix Plan

The fix involves removing the unnecessary import statement in video_processing_utils.py.

  • Remove the line from transformers.image_utils import PILImageResampling from src/transformers/video_processing_utils.py
  • If PILImageResampling is used elsewhere in the code, replace it with the correct import statement: from PIL import Image
  • Example:
# Before
from transformers.image_utils import PILImageResampling

# After
from PIL import Image

Alternatively, you can also import ImageResampling directly from PIL:

from PIL import Image
resampling_filter = Image.Resampling.LANCZOS

Verification

To verify the fix, follow the reproduction steps:

  1. Install transformers from source using pip install '.[torch]'
  2. Run transformers serve
  3. Run the chat CLI using transformers chat Qwen/Qwen3-4B

The chat should run as expected without any import errors.

Extra Tips

  • Make sure to update the import statements accordingly if PILImageResampling is used elsewhere in the code.
  • If you're using an older version of the transformers library, consider updating to the latest version to ensure compatibility with the PIL library.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

  1. install tranformers from source uv pip install '.[torch]'
  2. run transformers serve
  3. run chat cli transformers chat Qwen/Qwen3-4B

the chat runs as expected

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING