Skip to content

Preserve empty shapes when extracting image patches - #145

Open
satiricalguru wants to merge 1 commit into
google-deepmind:masterfrom
satiricalguru:contrib/empty-image-patches
Open

satiricalguru wants to merge 1 commit into
google-deepmind:masterfrom
satiricalguru:contrib/empty-image-patches

Conversation

@satiricalguru

Copy link
Copy Markdown

extract_patches raises ZeroDivisionError for an empty image batch or a VALID convolution with no patch positions. Both reshapes infer a dimension using -1, which is ambiguous when a known dimension is zero.

Use explicit dimensions for the channel reorder and reuse the convolution output shape. The regression compares both empty cases against tf.image.extract_patches, including under JIT.

Verified with pytest -q dm_pix/_src/patch_test.py (108 passed, 27 skipped) and the complete dm_pix/_src suite (1,959 passed, 152 skipped).

Codex assisted with implementation, tests, and review.

Use explicit reshape dimensions so empty image batches and empty spatial outputs match TensorFlow patch extraction.

Assisted-by: Codex <noreply@openai.com>
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