Skip to content

Allow Crop with fewer crop/corner values than array dims - #541

Open
arashmparsa wants to merge 1 commit into
DeepTrackAI:developfrom
arashmparsa:fix-crop-short-tuple
Open

arashmparsa wants to merge 1 commit into
DeepTrackAI:developfrom
arashmparsa:fix-crop-short-tuple

Conversation

@arashmparsa

Copy link
Copy Markdown

Crop(crop=(10, 12)) on an (H, W, C) image raised ValueError: operands could not be broadcast together with shapes (3,) (2,), in both "retain" and "remove" mode. This handles the second point of #27: axes not covered by crop are now left uncropped, and axes not covered by corner start at 0. Behavior when crop/corner have one value per axis is unchanged, and the docstrings now describe the shorter form. I added test_Crop_fewer_values_than_ndim, which fails before the change and passes after it. python -m unittest tests.test_augmentations tests.test_features tests.test_elementwise passes (134 tests, NumPy backend).

Part of #27 (the first point there, drawing random fractions instead of relying on seeding, is not changed here).

Passing a crop tuple shorter than the array's number of dimensions,
e.g. Crop(crop=(10, 12)) on an (H, W, C) image, raised
"operands could not be broadcast together". Axes not covered by
`crop` are now left uncropped, and axes not covered by `corner`
start at 0. Adds a regression test.

This branch has not been deployed

No deployments
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