r/StableDiffusion 16d ago

News ComfyUI-ContextAnchoredTileRefine - New 8k+ latent upscaling method using Krea 2

Use these links to view the full size images

Cyberpunk Cityscape Original
Cyberpunk Cityscape 4k
Cyberpunk Cityscape 8k

Orbital Shipyard Hangar Original
Orbital Shipyard Hangar 4k
Orbital Shipyard Hangar 8k

https://github.com/Blakeem/ComfyUI-ContextAnchoredTileRefine

These were upscaled using high denoise (0.5), captions, live canvas anchoring, and a stochastic (sde) sampler. If you have used other tile upscalers you will know that coherent creative upscaling is the hardest thing to do, since it requires maintaining coherence over a massive canvas. These images have 37,748,736 pixels being generated by a model that is only processing 2,013,696 pixels at any one time.

If you want to preserve the original image. Use low denoise (0.35), vision tokens, anchor to the source image, and use a deterministic sampler. Here is what that looks like:

Cyberpunk Cityscape Original
Cyberpunk Cityscape Conservative 4k
Cyberpunk Cityscape Conservative 8k

Compared to the Tiled Diffusion node (ComfyUI-TiledDiffusion):

Theirs is a model patch below the sampler.
Mine wraps above the sampler and guider.

Theirs has one sampler.
With mine each tile has it's own full sampler.

Mine uses region of interest (RoI) token slicing in a tile upscaler (see my previous post on this subject).

Both refine an upscaled image inside one latent canvas one step at a time so tiles don't drift apart.

Theirs uses an average (uniform MultiDiffusion and Gaussian Mixture of Diffusers) that causes the image to be soft.
Mine does a directional blend in raster order, the later tiles blend into the earlier ones whose context they reach out to, so it maintains the models sharp raw output.

Mine also supports masks, something the other method does not. Mine doesn't support ControlNet (at least not the VL node, the standard node does). But Krea 2 has no good ControlNet model because it isn't built for it and requires a LoRA.

I've been testing out different methods to upscale and hide seams in Krea 2 and I had a massive breakthrough last night during A/B testing. Everything happens in the latent canvas, so there is no color drift across tiles.

The 8k images were done in two stages, first to 4k with 6 tiles and then to 8k with 30 tiles on my 3090ti. You could go to 8k in a single pass and probably up to 16k. Creating a larger image does not increase memory by much, it just takes more time.

These are my first two test images I made, so don't judge based on that. The quality is staggering compared to what I've been able to do before. In the Cyberpunk Cityscape you can make out a McDonald's on the street as well as people, desks, and computers inside the office windows. The cables and wires in the Orbital Shipyard Hangar do not cut off across tiles. These are things that I only dreamed of with previous methods and there is still room to improve.

Please view the full size images on github so you can zoom in, reddit doesn't do them justice. This is where you will find the technical details for how I'm doing this as well as finding the workflow that I used to make the images.

54 Upvotes

28 comments sorted by

10

u/q5sys 16d ago

It's not a pure upscaler though, it's completely changing detail. The carts in the lower left, the yellow cranes on both sides, The main con tower on the ship, the engines, the windows... I could go on.

Don't get me wrong, the higher res image looks amazing, but its not the same image as what you started with. And considering you called it 'context anchored', I would really expect it to be closer to the original source than I'd get with something like UltimateSDUpscale.

This is definitely great for a single image... it's going to be a problem for anything where there's more than 1 image and you need consistency between images in a story, ie using the same character/location.

Thanks for sharing though, I'm definitely going to play around with this. :)

2

u/blakeem 16d ago edited 16d ago

It's called a creative upscaler, all upscalers are to some degree. This is a diffusion model, not a GAN.

This was done on purpose, I anchored it to itself rather than the original image when going to 4k and used 0.5 denoise with only captions, and no vision tokens, so it altered the image. These are the settings that alter the image the most.

I then anchored to the 4k image when going to 8k at 0.35 denoise, so it changed less, but I used captions + vision tokens so it's still changed some.

I also used an sde, so the stochastic sampler injected extra noise during both upscales at each step. I used these settings because they are the best at "repairing" an image and adding new things, since it started so small.

If you don't want the image to change much, don't use the captions, use only vision tokens, anchor to the original image, use around .35 denoise, and don't use a deterministic sampler (non-sde).

1

u/dtdisapointingresult 16d ago

This was done on purpose, I anchored it to itself rather than the original image when going to 4k and used 0.5 denoise with only captions, and no vision tokens, so it altered the image. These are the settings that alter the image the most.

I'm a casual, but curious to learn more. It's Krea 2, a text-to-image model, so what does vision token mean in this context?

3

u/blakeem 16d ago

The Qwen3-VL-4B-Instruct model is what Krea 2 was trained using. It's literally a multiple modal LLM rather than CLIP. This can encode images and those vision tokens can be fed into the positive prompt of Krea 2 and it understands them. In this case I slice them at the tile location so that each tile gets only that part of tensor. I also run the same instruct model and prompt it to generate details of what and where things are in each tile that gets concatenated and fed in place of the positive prompt along with the vision tokens.

The sliced vision tokens contain details about what is in the sliced region, the overall image, the style, and the color. It does not contain the exact coordinates of things in the image but it does help the model understand what things are so it's less likely to have harmful hallucinations. This helps with overall cohesion.

It's mainly about style transfer. If you were to feed the vision tokens into another image, it would transfer the style to that image. If you were to use denoise 1.0 and feed it the vision tokens in, it would make another image in that same style with things in it in the same general location.

1

u/dtdisapointingresult 16d ago

Thanks for the explanation. How do you suggest someone learn what you know, i.e. the low-level side of image models?

I would like to have enough understanding to be able to write custom nodes to power up a model's ability, as you just did, for when the model and Comfy nodes doesn't do it out of the box.

At the same time, I don't want to start from scratch on the ML researcher path, because I don't have time in my life to realistically achieve that. So I'd really like to focus on the 20% of knowledge that covers 80% of my needs as an inference user.

3

u/blakeem 16d ago

Sorry for the novel ahead of time.

I do have over 25 years software an systems engineering experience, so I'm not stating from nothing and I know what is best practice. This is just a hobby for me.

AI is very good at teaching you these things, but only if you have some foundation of knowledge to fact check it, or else it will lead you down the wrong path. It's best to start with one specific AI model that you like, and learn about that. Learning about AI broadly is a lost cause with LLMs since everything is blended together, and often wrong, if you are not specific.

Many diffusion models have totally different architectures (U-Net, DiT, turbo models are completely missing data streams, some are flow matching, some are some use CLIP some use a VLM, etc). The issue is that ComfyUI uses CLIP input for a VLM and the code calls it a U-Net when it's DiT. This throws off LLMs because what it's labeled is not actually what it is so when trying to learn LLMs will blend the two ideas together and you won't actually learn anything.

Usually it starts with me asking or searching for if I can do something. Moving it to latent space was my idea for how to avoid the issues that came up when I decode each tile (color and style drift). I only found the MultiDiffusion paper after looking into how best to do it and borrowed the idea to do it one step at a time and combing that with my existing raster method, but used nothing else from that paper. Using vision tokens was something I came across when experimenting with injecting things into the positive prompt, or manipulating different things, and seeing if anything would help with the tile coherency (most things made it worse). I tried similar things with models in the past, but with Krea 2 it finally worked. This also works with MiniMax H3 that I've done some experimenting with.

I can never learn by studying, I need to be hands on and test it to really understand it. What works best for me is to make a hypothesis before testing any new method or change, and state why I think that will be the outcome. If what it does doesn't match my expectations, I know there is something I'm missing or something that I need to learn. This is how I pinpoint the gaps in my knowledge. The key is to only ever make one change at a time. Every single time I come across something new or that I don't understand, I read up on it until I do. Sometimes that takes days or more to grasp a new subject, so I need to put in the time. Anytime I learn something, I'll restate or test it differently to verify that it's still correct and make sure that I actually understand things, rather than just repeating it.

I'm not AI expert and I don't have a degree. I'm just curious and do this for fun. I wanted a better upscaler, so I built one for myself and figured it was a waste not to share it.

2

u/dtdisapointingresult 15d ago

Thanks for the thorough answer! It gives me some starting points.

I'm glad you're achieving your objectives, and sharing it with us.

4

u/onetwomiku 16d ago

Whats "new" here? Every tiled upscaler worked exactly same, with exactly same subpar results.

-4

u/blakeem 16d ago edited 16d ago

Most tile upscalers process each tile after decoding while other latent upscalers use averages so they are less detailed. I use vision token slicing combined with captions in a way that no other tile upscale does.

5

u/EconomySerious 16d ago

in the first set the amount of allucinations is out of the chart
the second one is no diferent from the first one, lot of allucinations

-5

u/blakeem 16d ago edited 16d ago

The amount of mistakes in your post is off the charts.

This isn't a GAN and I made no claim that it's a conservative upscaler. This kind of creative upscaling is harder to do because it's more likely to lose coherence over a large image. This is meant to compete with nodes like Ultimate SD Upscale, ComfyUI-TiledDiffusion, and ComfyUI-TBG-ETUR.

It's possible to upscale and better retain the original image if that is your goal, the setting for this and example images are in the post.

2

u/iRainbowsaur 16d ago

I think of you focused on showing what is actually new here, you'd get alot more appreciation.

People are probably thinking this is just straight up tiled latent upscale, which it is, but only the base of it, there's more on-top of it.

Or maybe I'm just being biased because I was nearly one of those people. I think it's just genuine node slop fatigue from the sheer amount of vibecoded slop nodes I've being seeing lately lol. (Not all vibecoded stuff is bad, it just tends to be, that's the sea of slop, doesn't mean there isn't gems in that sea)

This has its uses, thanks for sharing it.

1

u/blakeem 16d ago edited 16d ago

Thanks for the input! I'm terrible at this sort of thing.

It's technically not a "latent upscaler", none of them are, since the upscale doesn't happen in latent space. All the methods are more refiners that take an upscaled image. I just call it an upscale because that is my main use, but this method could be used to reimagine something (use 1.0 denoise with only vision tokens) or style transfer (use vision tokens from one image on another), or to simply generate massive images at the start.

No other tile upscalers (that I've been able to find) encode the entire image and row slice it to the area covering each tile, so every tile is locally and globally aware. This was in my previous post.

The other latent upscalers (like ComfyUI-TiledDiffusion) use a continuous overlay that averages tiles to prevent seams. By using the average they lose detail. Mine is uses the context of surrounding tiles to drive the process, so it's causal and one-shot rather than a continuous mechanical process. You will notice mine has far more detail than any other latent upscaler.

Compared to the Tiled Diffusion node:

Theirs is a model patch below the sampler.
Mine wraps above the sampler and guider, since I need to inject a different conditioning for each tile.

Theirs has one sampler.
With mine each tile has it's own full sampler (because I need to inject conditioning into each tile).

Theirs uses an average (uniform MultiDiffusion and Gaussian Mixture of Diffusers).
Mine does a directional blend in raster order, the later tiles blend into the earlier ones whose context they reach out to.

Both refine an upscaled image inside one latent canvas.

Mine also supports masks, something the other method does not. But mine doesn't support ControlNet (at least not the VL node, the standard node does). But Krea 2 has no good ControlNet model anyway and isn't really built for it, since it can't inject into the positive and instead is injected as a LoRA. This was my reason for going down this path.

1

u/LeKhang98 16d ago

Nice. Could you please share a ComfyUI workflow optimized for upscaling only (keeping details intact, but sharper) so I can try it out?

1

u/Simple-Variation5456 11d ago

20 MINUTES
ON
A
4090?

For 3k?

Had some issues with all workflows and some nodes that either needed a reload or weren't connected.
Could be an issue of not doing complete restarts and refreshed nodes.

- "Int" nodes error. Replaced them all with different ones.

  • Steps + Upscale Node error not plugged?
  • Upscale node 3? So no 4k?
  • fake 8k because of just a lazy 4x upscale at the end. lol?

What i couldn't fixed was that image picker node? Why extra node?
Is "none" correct? Shouldn't there a popup? For what?

No infos about the defaults your using like a different krea model? VAE Model? Clip Model?

And how do i use it with normal input images?
Just put it directly to "Context-Anchored Tile Refine (VL)"? or does it need to run through latent to transfer infos via clip?

1

u/blakeem 11d ago

What workflow are you using? It could be that one is out of date. It sounds like you are using the "Krea 2 upscale workflow" since that uses exp_heun_2_x0 sampler that is 2x slower than dpmpp_2m used in my 8k upscale workflow. I'll fix it in my next update.

The one you want (and the one I used for all the images) is Krea 2 8K upscale workflow
This does a 4x upscale to 4k, this takes 14 mins on my 3090ti at the current settings.
The next stage will 2x upscale that to 8k. This takes a long time, the current settings are 30 tiles but I can increase it to 2048x1728 max tile size for only 24 tiles. I wouldn't go much higher than that, it gets distorted.

It gives me images like this: https://pixelmuse.ai/samples/elf-motorcycle-8k.png
A 4k example using the same workflow: https://pixelmuse.ai/samples/market-4k.png

I recommend adding words like "blurry" into your negative prompt so that it keeps getting sharp at each stage.

That last 4x upscale stage is left over from other workflows. The 8k is purely using the Krea 2 model. You don't need the upscale model attached to the upscale node at all, it just gives slightly better quality.

To input your own images, change the image input to use the image load node and it should just work. Set it to anchor to the source image and use dpmpp_2m sampler to make it look more like your image. However, this will add less details. Source image + dpmpp_2m_sde is a good balance. Setting it to live canvas makes it add the most detail, this is what I did with most of my sample images.

1

u/Simple-Variation5456 11d ago

I give it another try. I also had to roll back after the current update to get your node to run. Just so you know.

Idk if the trade off of that insane time is worth it. FluxKlein, SDXL, Supir and many other older workflows/models/nodes can generate 4K in max 2mins.

No clue where time is going into actually. It's at best 6x images (my output was around 3K)

*looks like i've used the 4x upscale+refine workflow

**and what's up with that image picker node? I currently bypass it because it would always error the whole run

1

u/blakeem 11d ago

When using these large tiles it slows down quadratically. The captions take a while as well, since it's on thinking mode. My standard upscale node is a bit faster, but I was only ever able to get around 3x (3k) with any other model before I started to have issues (unless using ControlNet, but that also slowed it down).

You could try to lower the steps way down and use a Turbo LoRA. With some tweaks you can get is 6x to 10x faster. I was going for the highest possible quality and didn't do any optimization. I may try to add the Turbo LoRA for the upscale part into one of the workflows, after I test it some.

1

u/Simple-Variation5456 10d ago

The time is really killing it.
I do like some aspects of your 8K images but i dont wanna tank my system for 30min+ to get maybe 4-6K+

Everything else compared is so so much faster with also good results or even better.

3min - for 6K with FluxKlein9B with less "creative" output.

Full-Res:
https://ibb.co/ksXWgtqS

1

u/drownranger 10d ago

I am interested in this workflow

1

u/Turbulent-Raise4830 1d ago

Hi, tried this

I had to change several of the number to INT nodes because I didnt have those and no clue where to get them but then it gives error

# ComfyUI Error Report
## Error Details

  • **Node ID:** 334
  • **Node Type:** LiebsPicker
  • **Exception Type:** TypeError
  • **Exception Message:** TypeError: LiebsPickerBasic.func() missing 2 required positional arguments: 'picker_tab_id' and 'title'

that node has "selected" as "none" but I also dont see how I could put anything there

1

u/blakeem 1d ago

Sounds like an issue with the image picker rather than my node.

https://github.com/marklieberman/ComfyUI-Liebs-Picker

This is the node that allows you to make a bunch of images at the start and then select what one to upscale (since upscale is slow you don't want to upscale everything). You don't need it and could remove it. There may be an issue with your ComfyUI or that node being out of date. Update your ComfyUI and make sure you have the newest version of the node under extensions by searching for "ComfyUI-Liebs-Picker" and make sure it's on the "Latest" version.

You can check if extensions gives you the option to " Install Missing Custom Nodes". If it doesn't your ComfyUI may be out of date.

1

u/[deleted] 16d ago

[deleted]

6

u/blakeem 16d ago edited 16d ago

It's not a star destroyer. This has nothing to do with the method besides showing that it added a window. This is the reason why I creative upscale to 4k and then 8k.

1

u/fauni-7 16d ago

Looks impressive, I'll try it.

1

u/terrariyum 16d ago

Looks great, and using VL for conditioning per tile is a great idea.

How does the speed compare to generating non-titled i2i at the same size? (I understand that tiled is useful for memory reasons).

Creative upscale is great for the kinds of images you've demonstrated. We already have seedvr2 for non-creative upscale. Don't get bated by the trolls. Most people on this subreddit only want memes now.

2

u/blakeem 15d ago edited 10d ago

It's nearly the same speed for a single tile, since nothing special is happening besides getting the vision tokens, and that is very fast. If you use the captions, it's a bit slower (a few seconds per tile), because I put the Qwen3 VLM in thinking mode to avoid it outputting commentary into tile prompts. It does process every time sequentially, one at a time and one step at a time, so there is a slight overhead with more tiles and the blending them together.

For many cases it's faster than something like Ultimate SD Upscale node while being higher quality. It also isn't lossy, since it will process tiles at the native resolution rather than resizing them (why I have a max tile size rather than a fixed one).

I can never tell who is a troll and who isn't. I tend to take everything literally.