Skip to content

Scale training images according to area, not longest side#380

Merged
filipstrand merged 1 commit intofilipstrand:mainfrom
waldheinz:training-image-size
Mar 15, 2026
Merged

Scale training images according to area, not longest side#380
filipstrand merged 1 commit intofilipstrand:mainfrom
waldheinz:training-image-size

Conversation

@waldheinz
Copy link
Contributor

When the user limits the max_resolution it's very likely because of resource constaints. But the resource use is strongly correlated to the total number of pixels and not the length of the longer side of an image.

This change modifies the logic to resolve dimensions where the area of the resolved image is ~ max_resoluton ^ 2, which means non-square images get the same "pixel budget" as square images.

@waldheinz waldheinz force-pushed the training-image-size branch from 8010296 to e9d3853 Compare March 11, 2026 08:17
When the user limits the `max_resolution` it's very likely
because of resource constraints. But the resource use is
strongly correlated to the total number of pixels and not
the length of the longer side of an image.

This change modifies the logic to resolve dimensions where
the *area* of the resolved image is ~ `max_resoluton ^ 2`,
which means non-square images get the same "pixel budget"
as square images.
@waldheinz waldheinz force-pushed the training-image-size branch from e9d3853 to fe06de7 Compare March 11, 2026 08:19
@filipstrand
Copy link
Owner

I agree, this makes more sense, thanks for considering this use case!

At first, I thought of updating the name max_resolution to something more suggestive, but it is simple so let's keep it for now :)

I'll go ahead and include it for v0.17 which is due soon.

If you have further suggestions for API related things, they are also very welcome here #357

@filipstrand filipstrand merged commit e37bb23 into filipstrand:main Mar 15, 2026
1 check passed
@waldheinz waldheinz deleted the training-image-size branch March 16, 2026 12:04
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.

2 participants