AI Personal Learning
and practical guidance
Beanbag Marscode1

LanPaint: A ComfyUI Image Restoration Workflow for Any Model

General Introduction

LanPaint is a high quality image restoration tool designed for Stable Diffusion models. Its best features areEnables any Stable Diffusion model to achieve accurate image restoration without additional training. With a simple installation, the user is able to work in the familiar ComfyUI Replace the default sampler in your workflow and get started quickly.LanPaint optimizes the restoration with multiple iterations for a natural and seamless restored image. It is suitable for repairing damaged photos, replacing image elements or improving the quality of your creations. This tool makes it easy to handle image editing tasks for both novice and professional users. It is currently open source on GitHub and has received a lot of attention from AI image processing enthusiasts.

LanPaint: High-quality image restoration tool without training-1


 

Function List

  • Image restoration without training: directly adapts to any Stable Diffusion model, including user-defined models.
  • Simple Replacement Sampler: Replace the default KSampler node in ComfyUI, keeping the original workflow.
  • High-quality restoration results: Generating new content through multiple iterations ensures that the restored area blends naturally with its surroundings.
  • Flexible adjustment of parameters: support the adjustment of inference steps, alignment strength, etc., to adapt to different restoration needs.
  • Supports multiple uses: can be used for content replacement, detail refinement, and even generating consistent roles.

 

Using Help

Installation process

LanPaint is very easy to install and is mainly integrated through ComfyUI. Below are the detailed steps:

  1. Installation via ComfyUI-Manager
    • Open ComfyUI and go to ComfyUI-Manager.
    • Type "LanPaint" in the search bar.
    • Click the Install button and wait for the installation to complete.
  2. manual installation
    • In ComfyUI, click "Install via Git URL".
    • Enter LanPaint's GitHub address:https://github.com/scraed/LanPaint.gitThe
    • Click to confirm the installation.
    • Alternatively, open a terminal and go to ComfyUI's custom_nodes folder, run the command:
      git clone https://github.com/scraed/LanPaint.git
      
    • After the installation is complete, restart ComfyUI.
  3. Checking the installation
    • After restarting, find the "sampling" category in ComfyUI's node menu.
    • If you see LanPaint-related nodes (such as LanPaint KSampler), the installation was successful.

How to use

LanPaint's operation is based on ComfyUI's workflow. Here are the steps:

basic operation

  1. preliminary
    • Ensure that the Stable Diffusion model is installed and loaded into the "Load Checkpoint" node of ComfyUI.
    • Prepare an image to be repaired and upload it to the "Load Image" node.
  2. Creating a Repair Mask
    • In image editing software (e.g. Photoshop), draw a mask for the area to be repaired.
    • Masking requires a binary map (black and white, 0 or 1) with no transparency or blurred edges.
    • Save the mask as a PNG and upload it to the "Load Image (Mask)" node in ComfyUI.
  3. Setting the LanPaint Node
    • In the ComfyUI workflow, add the "LanPaint KSampler" node.
    • Connect it to the Model, Image and Mask nodes, replacing the default KSampler.
    • The default parameters will work, but can be adjusted as needed:
      • LanPaint_stepsize: Controls the iteration step size, default 0.3, range 0-1.
      • LanPaint_lambda: Adjusts the alignment strength of the masked area, default 1.
      • LanPaint_cfg_Big: Enhancements to fix details, with default values depending on the model.
  4. Run Generation
    • Click the "Queue Prompt" button in ComfyUI to start the generation.
    • The generation time varies depending on the hardware and parameters and is usually slightly longer than the default fix.

Featured Function Operation

  • Content replacement
    • EXAMPLE: Replace the white shirt with a blue one.
    • Mark the shirt area in the mask, upload the image and the mask.
    • Run LanPaint by typing "blue shirt" at the prompt.
    • The result produces a blue shirt and blends naturally with its surroundings.
  • Damage Repair
    • Example: repairing scratches on an old photograph.
    • Cover the scratched area with a mask and upload it to ComfyUI.
    • LanPaint automatically generates new content to fill in the damage without prompting for special words.
  • Coherent role generation
    • Example: generating multiple perspectives of the same character.
    • Upload character images, copy multiple copies and adjust the angles to create a mask.
    • Add "multiple views" to the prompt word and run to generate it.

caveat

  • Masking Requirements: It must be a pure black and white binary image, avoiding gray or gradients.
  • hardware requirement: Generating multiple images may take up more GPU memory, it is recommended to adjust the batch size according to the video memory.
  • parameterization: Complex repair tasks can be increased in step size (e.g. 0.5) to improve results.

With these steps, users can easily get started with LanPaint and accomplish a variety of tasks from simple replacements to complex repairs.

 

application scenario

  1. Restoration of old photographs
    Users can use LanPaint to repair scratches, smudges, or missing parts of old photos and bring precious memories back to life.
  2. Creative Image Editing
    Designers can use it to replace objects in an image, such as replacing a chair with a table or changing the color of a dress, to quickly implement creative ideas.
  3. Perfection in artistic creation
    Artists can use LanPaint to modify the details of their paintings, such as adjusting the background or adding new elements to enhance the integrity of their work.
  4. Advertising Image Processing
    Advertising teams can use it to adjust the product display image, such as changing backgrounds or props, to meet different marketing needs.
  5. Video Frame Repair
    Video editors can use LanPaint to repair keyframes, remove distractions or optimize picture details.

QA

  1. What is the difference between LanPaint and the default fix?
    While the default repair usually preserves some of the original pixels, LanPaint generates the new content entirely, with more natural results for complex tasks.
  2. Need to train the model?
    No need, LanPaint adapts directly to any Stable Diffusion model right out of the box.
  3. Why is the generation time slower than the default?
    LanPaint uses multiple iterations to optimize the effect, so it takes a little longer than a single generation, but the quality is higher.
  4. Can it be used on other platforms?
    ComfyUI is currently the main support, other platforms need additional adaptations.
May not be reproduced without permission:Chief AI Sharing Circle " LanPaint: A ComfyUI Image Restoration Workflow for Any Model

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish