Commit b2a25ff
committed
Fix float truncation in Flux2ImageProcessor._resize_to_target_area
`_resize_to_target_area` scaled the image with `int(side * scale)`. For any
input whose scaled side should be an exact integer (every square image, for
one) `n * sqrt(target / n**2)` evaluates to 1023.999... in floating point for
roughly 16% of sizes, so `int` truncated it to 1023. The Flux2, Flux2 Klein,
Flux2 modular and Z-Image Omni pipelines then floor to a multiple of 16, so the
conditioning image and default output silently became 1008x1008 instead of
1024x1024 (e.g. for a 1039x1039 input).
Use `round` instead. It may exceed `target_area` by at most one pixel per side,
which every caller floors away.1 parent c5469b7 commit b2a25ff
1 file changed
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
113 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
114 | 117 | | |
115 | 118 | | |
116 | 119 | | |
| |||
0 commit comments