fdsgsfjsfg commited on
Commit
d54626d
·
verified ·
1 Parent(s): fa6eb3b

fix: use bucket system for inference resolution to prevent content cropping, then resize back to original

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -386,9 +386,9 @@ def prepare_images_before_pipe(
386
 
387
  base_w, base_h = pil_images[0].size
388
 
389
- # 保持原始尺寸,只对齐到 divisible_by(对齐 Rebels.json divisible_by=2)
390
- target_w = max(divisible_by, (base_w // divisible_by) * divisible_by)
391
- target_h = max(divisible_by, (base_h // divisible_by) * divisible_by)
392
 
393
  processed = []
394
  for img in pil_images:
 
386
 
387
  base_w, base_h = pil_images[0].size
388
 
389
+ # 用 bucket 系统选择最佳推理分辨率(~1MP),匹配模型训练分辨率
390
+ # 避免原图分辨率过大/过小导致内容偏移或裁剪
391
+ target_w, target_h = pick_best_bucket(base_w, base_h, SAFE_BUCKETS, allow_upscale)
392
 
393
  processed = []
394
  for img in pil_images: