Compare commits

...
12 Commits
Author SHA1 Message Date
scraed 75a91710f2 Update pyproject.toml 2025-04-16 23:50:17 +08:00
scraed f8eea61264 Update README.md 2025-04-16 23:48:58 +08:00
scraed e42d3b0426 Update README.md 2025-04-16 23:32:46 +08:00
scraed ee567b14e8 Update Example for Hidream 2025-04-16 23:21:55 +08:00
scraed 10a790974c Merge branch 'master' of https://github.com/scraed/LanPaint 2025-04-16 23:12:18 +08:00
scraed 00d2eb9885 Update hidream example 2025-04-16 23:12:13 +08:00
scraed b1139f285a Update Citationn 2025-04-16 22:58:40 +08:00
scraed eb69a21cf2 Update README.md for hidream support 2025-04-16 22:26:05 +08:00
scraed c863ade839 update version 2025-04-16 22:25:05 +08:00
scraed b07ed256c7 Primary support for Hidream 2025-04-16 22:24:18 +08:00
scraed 612cfb51f2 Merge pull request #19 from ComfyNodePRs/update-publish-yaml
Update Github Action for Publishing to Comfy Registry
2025-04-11 20:42:47 +08:00
snomiao 34d36e3c93 chore(publish): update workflow for node publishing
- Add permissions for issue writing in the workflow
- Set condition to run job only for 'scraed' repository owner
- Update action version from 'main' to 'v1' for stability and consistency
2025-03-04 04:12:56 +00:00
8 changed files with 44 additions and 7 deletions
+5 -1
View File
@@ -7,14 +7,18 @@ on:
paths:
- "pyproject.toml"
permissions:
issues: write
jobs:
publish-node:
name: Publish Custom Node to registry
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'scraed' }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Publish Custom Node
uses: Comfy-Org/publish-node-action@main
uses: Comfy-Org/publish-node-action@v1
with:
personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }} ## Add your own personal access token to your Github Repository secrets and reference it here.
+32 -1
View File
@@ -21,6 +21,8 @@ LanPaint introduces **two-way alignment** between masked and unmasked areas. It
Based on this evaluation, LanPaint iteratively updates the noise in both the masked and unmasked regions.
## Updates
- 2025/04/16
- Added Primary HiDream support
- 2025/03/22
- Added Primary Flux support
- Added Tease Mode
@@ -30,6 +32,19 @@ Based on this evaluation, LanPaint iteratively updates the noise in both the mas
## Example Results
All examples use a random seed 0 to generate batch of 4 images for fair comparison. (Warning: Generating 4 images may exceed your GPU memory; adjust batch size as needed.)
### Example HiDream: InPaint(LanPaint K Sampler, 5 steps of thinking)
![Inpainting Result 8](https://github.com/scraed/LanPaint/blob/master/examples/InpaintChara_11.jpg)
[View Workflow & Masks](https://github.com/scraed/LanPaint/tree/master/examples/Example_8)
You need to install [ComfyUI GGUF](https://github.com/city96/ComfyUI-GGUF) in order to load the models. Make sure you have the latest (nightly at 2025/04/16) comfyui installed. The following models are needed for Hidream:
- [clip_g_hidream.safetensors](https://huggingface.co/Comfy-Org/HiDream-I1_ComfyUI/blob/main/split_files/text_encoders/clip_g_hidream.safetensors)
- [clip_l_hidream.safetensors](https://huggingface.co/Comfy-Org/HiDream-I1_ComfyUI/blob/main/split_files/text_encoders/clip_l_hidream.safetensors)
- [T5 GGUF](https://huggingface.co/city96/t5-v1_1-xxl-encoder-gguf/tree/main)
- [Llama 3.1](https://huggingface.co/bartowski/Meta-Llama-3.1-8B-Instruct-GGUF/tree/main)
- [Flux VAE](https://huggingface.co/StableDiffusionVN/Flux/blob/main/Vae/flux_vae.safetensors)
### Example 1: Basket to Basket Ball (LanPaint K Sampler, 2 steps of thinking).
![Inpainting Result 1](https://github.com/scraed/LanPaint/blob/master/examples/InpaintChara_04.jpg)
[View Workflow & Masks](https://github.com/scraed/LanPaint/tree/master/examples/Example_1)
@@ -67,7 +82,10 @@ All examples use a random seed 0 to generate batch of 4 images for fair comparis
[Model Used in This Example](https://huggingface.co/Comfy-Org/flux1-dev/blob/main/flux1-dev-fp8.safetensors)
(Note: Use CFG scale 1.0 for Flux as it don't use CFG. LanPaint_cfg_BIG is also disabled on Flux)
**How to Use These Examples:**
## **How to Use These Examples:**
1. Navigate to the **example** folder (i.e example_1) by clicking **View Workflow & Masks**, download all pictures.
2. Drag **InPainted_Drag_Me_to_ComfyUI.png** into ComfyUI to load the workflow.
3. Download the required model from Civitai by clicking **Model Used in This Example**.
@@ -166,6 +184,19 @@ For challenging inpainting tasks:
Help us improve LanPaint! 🚀 **Report bugs**, share **example cases**, or contribute your **personal parameter settings** to benefit the community.
## Citation
```
@misc{zheng2025lanpainttrainingfreediffusioninpainting,
title={Lanpaint: Training-Free Diffusion Inpainting with Exact and Fast Conditional Inference},
author={Candi Zheng and Yuan Lan and Yang Wang},
year={2025},
eprint={2502.03491},
archivePrefix={arXiv},
primaryClass={eess.IV},
url={https://arxiv.org/abs/2502.03491},
}
```
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 KiB

+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "LanPaint"
version = "0.2.0"
version = "0.2.2"
description = "Achieve seamless inpainting results without needing a specialized inpainting model."
authors = [
{name = "LanPaint", email = "czhengac@connect.ust.hk"}
+6 -4
View File
@@ -85,9 +85,10 @@ class KSamplerX0Inpaint:
# x is rectified flow x_t = sigma * noise + (1.0 - sigma) * x_0
IS_FLUX = self.inner_model.inner_model.model_type == ModelType.FLUX
IS_FLOW = self.inner_model.inner_model.model_type == ModelType.FLOW
# unify the notations into variance exploding diffusion model
if IS_FLUX:
if IS_FLUX or IS_FLOW:
LanPaint_Sigma = sigma / ( torch.maximum( 1 - sigma , sigma*0 + 5e-2 ))
self.LanPaint_Sigmas = self.sigmas / ( torch.maximum( 1 - self.sigmas , self.sigmas*0 + 5e-2 ))
else:
@@ -130,7 +131,7 @@ class KSamplerX0Inpaint:
# self.inner_model.inner_model.scale_latent_inpaint returns variance exploding x_t values
x = x * (1 - latent_mask) + self.inner_model.inner_model.scale_latent_inpaint(x=x, sigma=sigma, noise=self.noise, latent_image=self.latent_image)* latent_mask
if IS_FLUX:
if IS_FLUX or IS_FLOW:
x_t = x * ( 1 + LanPaint_Sigma[:, None,None,None])
else:
x_t = x #/ ( 1+sigma**2 )**0.5 # switch to variance perserving x_t values
@@ -149,7 +150,7 @@ class KSamplerX0Inpaint:
else:
step_size_i = step_size
x_t, args = self.langevin_dynamics(x_t, score_func , latent_mask, step_size_i , current_times, sigma_x = self.sigma_x(abt)[:, None,None,None], sigma_y = self.sigma_y(abt)[:, None,None,None], args = args)
if IS_FLUX:
if IS_FLUX or IS_FLOW:
x = x_t / ( 1 + LanPaint_Sigma[:, None,None,None] )
else:
x = x_t #/ ( 1+sigma**2 )**0.5 # switch to variance perserving x_t values
@@ -190,7 +191,8 @@ class KSamplerX0Inpaint:
beta = self.chara_beta * (1-abt)**0.5
IS_FLUX = self.inner_model.inner_model.model_type == ModelType.FLUX
if IS_FLUX:
IS_FLOW = self.inner_model.inner_model.model_type == ModelType.FLOW
if IS_FLUX or IS_FLOW:
x_0, x_0_BIG = self.inner_model(x_t / ( 1 + sigma ), sigma[:, 0,0,0] / ( 1 + sigma[:, 0,0,0] ), model_options=model_options, seed=seed)
else:
x_0, x_0_BIG = self.inner_model(x_t, sigma[:, 0,0,0], model_options=model_options, seed=seed)