Skip to content

[Fix] Support ndarray inputs in inpainting inferencer - #2165

Open
tandede wants to merge 16 commits into
open-mmlab:mainfrom
tandede:fix/inpainting-ndarray-inputs
Open

tandede wants to merge 16 commits into
open-mmlab:mainfrom
tandede:fix/inpainting-ndarray-inputs

Conversation

@tandede

@tandede tandede commented Aug 19, 2026

Copy link
Copy Markdown

Motivation

InpaintingInferencer declares np.ndarray as a supported input type, but its preprocessing pipeline always applies LoadImageFromFile and LoadMask. Arrays are therefore converted to strings and treated as file paths, which raises OSError: File name too long.

This fixes #1945.

Modification

  • Build the image and mask loading stages independently according to each input type, so path/array combinations are all supported.
  • Prepare array metadata consistently with file-loaded images, copy non-contiguous image views before tensor conversion, and normalize array masks with the same first-channel and binary semantics as LoadMask.
  • Reject unsupported image and mask array shapes with clear errors.
  • Add regression coverage for full AOT-GAN inference with ndarray inputs, mixed path/array inputs, negative-stride BGR views, mask normalization, source-array immutability, and invalid shapes.

BC-breaking

No. Existing path-based inputs keep the same loading pipeline and output.

Test plan

  • pytest -q tests/test_apis/test_inferencers/test_inpainting_inferencer.py (9 passed)
  • Relevant loading, masked-image, packing, and data-preprocessor tests (19 passed)
  • Target source coverage: 100%
  • Pre-commit checks on both changed files: passed

Checklist

  • I have read and followed the contribution workflow.
  • Pre-commit checks pass.
  • The bug is covered by unit and end-to-end inference tests.
  • The existing public input type already documents ndarray support; no separate documentation change is required.

@CLAassistant

CLAassistant commented Aug 19, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

[Bug] MMagic Inpainting not working with np.ndarray input type for img and mask

3 participants