From 210727d5ca27bf01bbd30f8e7bdca0544b066dab Mon Sep 17 00:00:00 2001 From: ausboss <102309304+ausboss@users.noreply.github.com> Date: Tue, 6 Oct 2026 21:50:26 -0500 Subject: [PATCH] Tiled Upscale: the report says when a picture is made smaller Asking for fewer megapixels than the picture has got the "too close to the picture's own size, ask for more" line, which is wrong for a shrink. The report 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. --- CHANGELOG.md | 10 ++++++++++ js/docs/AUSBOSS_NODES_TiledUpscale.md | 11 ++++++++++- nodes/_tile_helpers.py | 9 +++++++++ tests/test_tile_helpers.py | 12 ++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0534cd0..dcc170f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/js/docs/AUSBOSS_NODES_TiledUpscale.md b/js/docs/AUSBOSS_NODES_TiledUpscale.md index 02a0c0f..d8fa6cc 100644 --- a/js/docs/AUSBOSS_NODES_TiledUpscale.md +++ b/js/docs/AUSBOSS_NODES_TiledUpscale.md @@ -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. diff --git a/nodes/_tile_helpers.py b/nodes/_tile_helpers.py index ea68b64..ae80810 100644 --- a/nodes/_tile_helpers.py +++ b/nodes/_tile_helpers.py @@ -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: " diff --git a/tests/test_tile_helpers.py b/tests/test_tile_helpers.py index 3709133..7ab66f0 100644 --- a/tests/test_tile_helpers.py +++ b/tests/test_tile_helpers.py @@ -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)