Merge pull request #154 from ausboss/fix/tiled-upscale-shrink-report

Tiled Upscale: the report says when a picture is made smaller
This commit is contained in:
ausboss
2026-10-06 21:57:08 -05:00
committed by GitHub
4 changed files with 41 additions and 1 deletions
+10
View File
@@ -2,6 +2,16 @@
All notable changes to ComfyUI-AusBoss are documented here.
## Unreleased
- **Tiled Upscale: the report says when your picture is made smaller.**
Asking for fewer megapixels than the picture has printed "close to the
picture's own size, ask for more", which is wrong when the picture is
being shrunk. It now says the picture is made smaller first. The help
page says when that is the right thing to do: a big photo that is noisy
or soft does better set to 2 megapixels first, then taken up from that
result.
## 2.9.0 - 2026-10-06
- **New: Tiled Upscale 🆎 and Tiled Upscale Stitch 🆎** (Image). Take a
+10 -1
View File
@@ -25,7 +25,12 @@ The `report` output says what was done with your picture, for example
`736 x 1308 px (0.96 MP) to 2112 x 3776 px (7.97 MP): redrawn at 7.97 MP in
4 tiles of 1120 x 1952 px.` Wire it to **Show Text 🆎** to read it. It also
says when the size you asked for is too close to your picture's own size
to show a difference.
to show a difference, and when your picture is made smaller.
A size under your picture's own makes the picture smaller first. That is
the way to restore a big photo that is noisy or soft: set 2, run, then load
the result and set the size you want. Cut at its own size, such a photo's
tiles can come back grainy.
## More
@@ -78,5 +83,9 @@ that keeps what it is given, such as a low denoise.
runs as often as it takes to cover the redraw size, then the picture is
brought to the exact size. The `before` picture never uses the model.
- The plan stops at 144 tiles and says so.
- A big worn photo, seen on one 8 megapixel test picture with noise and
JPEG damage: kept at its size in four tiles the skin came back grainy;
set to 2 megapixels first and then taken to 8 in tiles it came back
clean. A sharp 13.5 megapixel picture kept at its size hardly changed.
- Measured on an RTX 5090 with Qwen Image 2.1 at 8 steps: a 1 megapixel
phone photo to 8 megapixels in four tiles took about 37 seconds.
+9
View File
@@ -30,6 +30,9 @@ MAX_TILE_ASPECT = 2.2
# A picture of a megapixel or more shows little change unless it grows about
# this much per side (measured 2026-10-06 on phone photos).
MIN_VISIBLE_GROWTH = 1.6
# Under this growth per side the picture is being made smaller: the report says
# so, and does not call the size too close.
SHRINK_BELOW = 0.97
MAX_TILES = 144
@@ -149,6 +152,8 @@ def plan_tiles(
result_mp = result_width * result_height / 1e6
growth_per_side = math.sqrt(result_mp / source_mp)
# asked for clearly fewer megapixels than the picture has: it is made smaller, which is a choice, not a size too close
shrunk = (not keep_size) and growth_per_side < SHRINK_BELOW
return {
"source": (width, height),
"source_megapixels": source_mp,
@@ -162,7 +167,9 @@ def plan_tiles(
"boxes": boxes,
"overlap": (max(0, overlap_x), max(0, overlap_y)),
"enlarged": limited,
"shrunk": shrunk,
"too_close": (not keep_size)
and (not shrunk)
and source_mp >= 1.0
and growth_per_side < MIN_VISIBLE_GROWTH,
"suggested_megapixels": math.ceil(source_mp * MIN_VISIBLE_GROWTH**2 * 2) / 2,
@@ -197,6 +204,8 @@ def describe_plan(plan: dict) -> str:
text += ", then enlarged the plain way. A picture this small has no more detail to redraw from."
else:
text += "."
if plan.get("shrunk"):
text += " The picture is larger than the size asked for, so it is made smaller first."
if plan["too_close"]:
text += (
" That is close to the picture's own size, so expect little change: "
+12
View File
@@ -106,6 +106,18 @@ class PlanTests(unittest.TestCase):
# a small picture always changes: no warning
self.assertFalse(tiles.plan_tiles(376, 500, 0.3)["too_close"])
def test_a_smaller_size_than_the_picture_is_a_shrink_not_a_warning(self):
plan = tiles.plan_tiles(2304, 3456, 2.0)
self.assertTrue(plan["shrunk"])
self.assertFalse(plan["too_close"])
self.assertEqual(len(plan["boxes"]), 1)
text = tiles.describe_plan(plan)
self.assertIn("made smaller first", text)
self.assertNotIn("ask for", text)
# the same size, or a little more, still gets the warning
self.assertFalse(tiles.plan_tiles(1080, 1440, 2.0)["shrunk"])
self.assertFalse(tiles.plan_tiles(2304, 3456, 0)["shrunk"])
def test_limits_are_clear_errors(self):
with self.assertRaisesRegex(ValueError, "larger than 0x0"):
tiles.plan_tiles(0, 100, 2.0)