InpaintProcessor crashes when padding_mask_crop is set and a dimension is omitted

Open Beginner friendly
#15,433 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@QTSHI is already working on this.

Since Dec 1, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, pytorch

Research direction

Start by reading InpaintProcessor.preprocess() in src/diffusers/image_processor.py and follow how it infers image dimensions when height or width is omitted. Reproduce the failure with the issue's CPU example, then check nearby image processor tests for where to add a regression case. Done when preprocessing with padding_mask_crop succeeds with either dimension omitted and the regression test passes.

Written by the indexing model from the issue text.

Description

InpaintProcessor.preprocess() works without height and width until I set padding_mask_crop. With cropping enabled, omitting either dimension raises a TypeError.

from PIL import Image
from diffusers.image_processor import InpaintProcessor

image = Image.new("RGB", (64, 48))
mask = Image.new("L", image.size)
mask.paste(255, (24, 16, 40, 32))

InpaintProcessor().preprocess(image, mask=mask, padding_mask_crop=8)
TypeError: unsupported operand type(s) for /: 'NoneType' and 'NoneType'

Passing both dimensions works. The crop calculation divides width by height before the processor has inferred the missing dimensions. I expected the omitted dimensions to be inferred from the input image, as they are without cropping.

Reproduced on main at 08d5de30 (Diffusers 0.44.0.dev0) on CPU. No model weights are needed.

Would it make sense to reuse the image processor's existing size inference before computing the crop? I can send a small PR with a regression test if that approach looks right.

Dominant language
Python
Stars
35k
Forks
7.5k
Avg merge
2d 22h
Merged PRs (30d)
58

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from huggingface/diffusers

All issues in huggingface/diffusers

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.