We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ab671b9 commit 7883f84Copy full SHA for 7883f84
models/clip/common/src/image.rs
@@ -240,9 +240,9 @@ fn find_best_resize(
240
// 如果允许放大或需要缩小
241
if allow_upscale || w * h > scale_resolution.pow(2) {
242
// 保持宽高比缩放尺寸,使面积等于 `sr²`
243
- let r = (w as fdim / h as fdim).sqrt();
244
- w = (scale_resolution as fdim * r) as _;
245
- h = (scale_resolution as fdim / r) as _;
+ let r = w as fdim / h as fdim;
+ h = (scale_resolution as fdim / r.sqrt()) as _;
+ w = (h as fdim * r) as _;
246
}
247
// 确保宽高整除图块尺寸
248
[w, h].map(|l| div_round(l, patch_size) * patch_size)
0 commit comments