3. Usage examples: inpainting and outpainting - minsky91/krita-ai-diffusion-hires GitHub Wiki
A test case comparing Hires against the standard plugin version
For inpainting and outpainting examples here, I am using an old SD 1.5-generated image which was subsequently upscaled and enhanced to the 4 K x 4 K size. By today’s (April-May 2025) standards, however, it looks like it could use more improvements. Here’s the version I start from:
I begin with the forefront woman’s head where a few things need to be improved: the face skin that looks plasticky and lacking detail, the badly pulled down ear and the unnaturally wrinkled neck. Also, the right-side part of the dress looks strange and needs trimming. While the entire image’s resolution is rather high for the standard version of Krita AI to handle, these are all relatively small features and can be dealt with and enhanced just fine by the standard plugin version through regular inpainting, so for this part engaging Hires functionality won’t be needed.
To keep the long story short, I skip details on inpainting of individual elements (you can find intermediate results and the Krita .kra document, with all the selections and layers, in the google drive folder here). I will just mention that for the inpainting part, the icbinpXL_v6 checkpoint in harness with the LCM sampler (through the lcm-lora-sdxl LoRa) was used, a combination capable of generating some of the finest detail I’ve seen.
Next step is to inpaint the painting the woman is standing in front of. In it, I’d like to change the background to something richer in both depth and detail, and also alter the portrayed character’s appearance, hopefully turning her gaze to something more meaningful. In this case, because of the much bigger pixel area to process, the standard version of Krita AI is no longer doing a good job: I get washed out textures and blurred areas, and it’s also slower when inpainting than I’d like it to be. Here’s a fragment illustrating that:
In contrast, the Hires version produces much more detailed output, in many appealing variations difficult to choose from, and significantly faster too (35s vs 63s, for the featured image)(*), mainly thanks to Tiled Diffusion it uses. The regular version, on the other hand, is able to render a more interesting gaze for the portrayed character, which I decide is worth keeping.
The resulting image (a blend composition of the best inpainted bits) is shown below. Some finishing manual touches for minor details were added to the background area of the painting.
The image still looks incomplete though. I feel it could benefit from changing the aspect ratio from the square (which makes it look too constrained) to a horizontal one, acquiring some perspective along the way. Also, the corner of a painting to the left of the woman needs to be removed, it makes the picture look overly busy. Such modifications are done usually via outpainting.
To do that in Krita AI (following the routine I use for a long time already), one has to select all of the main layer, expand the canvas to the desired dimensions, substantially shrink and feather the selection to have a wide enough border for the checkpoint to latch on, and then invert it. Additionally for this particular case, the selection needs to be manually expanded, with one of Krita’s selection tools, to cover the corner of the painting on the upper left that we want to remove. At this point, the canvas in Krita looks as follows:
Outpainting is performed at 100% Strength (1.0 denoise). The plugin’s functions that can be used for this purpose are, in the order of success rate: Generate (Custom) with the Seamless checkbox checked, Expand, Add Content or Fill. Success also depends often on the chosen checkpoint, sampler and prompt. For the outpainting example here, I use dreamshaperXL_lightningDPMSDE with the Hyper sampler (Euler a at 10 steps), since I found it working better than LCM for extra large pixel content like we have here. The target image dimensions I choose are 5800 x 4350 pixels.
Again, the standard version of Krita AI struggles with the task, producing heavily blurred output (see sample fragments below) and taking very long generation time:
Krita AI Hires proves much more robust in generating desired (although not always geometrically continuous across the interior) output with lots of meaningful detail, and in a much shorter time (73s vs 1180s for the featured image, roughly a minute+ against 20). Out of many generated variations, I pick the one that looks most realistic. Except for the area where the inpainted painting got expanded to the right by the operation, the outpainted output requires very little work to be completed and incorporated into the canvas. Here’s the final result:
Normally, I would try to further improve the picture by running an additional Refine (img2img) pass to make it look slightly more uniform in texture, but for this exercise it should suffice.
(*) The examples were produced and the benchmark tests were carried out on a Windows 11 PC equipped with 2.50 GHz Intel Core 9 185H chip and 32 GB RAM, using SSD storage. The GPU was an NVIDIA GeForce RTX 4070 Ti SUPER with 16 GB VRAM, operated by the Comfy server v0.3.19. No TeaCache or any other accelerator extension has been used.