-
Notifications
You must be signed in to change notification settings - Fork 27.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supporting for SDXL-Inpaint Model #14390
Conversation
You are a legend. |
when? |
I've committed the code. you can check commits here 9feb034. |
THANK YOU |
I've been trying this out and it seems to work. The inpainting model isn't great, but it's better than nothing, and maybe now people will train some better ones. |
If you're using a different SDXL model than SDXL 1.0, you can create a custom inpainting model using the guide from here (https://huggingface.co/benjamin-paine/sd-xl-alternative-bases). This works perfectly, especially with soft inpainting. |
@wangqyqq thank you so much for doing this! It's been months of people asking me to bring support to Automatic and me having to disappoint them saying I didn't know how and didn't have the time to learn, so thank you again. I wanted to just volunteer that ENFUGUE has slightly changed how XL inpainting is implemented since the initial code, and my findings may be useful to port to Auto or just be aware of. First I have to highlight the Cropped inpainting is enabled, so a You can probably spot many issues with the The second thing I wanted to call attention to is outpainting. These models can do pretty well at outpainting, but because of the issue above, the result will be poor if you initialize the empty space to black. To address this, ENFUGUE will fill the empty space with noise; I found the best results from Perlin noise clamped in the range Hope this is useful information, cheers for this! |
@painebenjamin Thanks a lot for your detailed reply and information provided! I read it carefully and made some tests. Here are my findings: When the param is_strength_max is True, the latents will be totally noise; otherwise, the latents will be a combination of image_latents and noise. So it behaves differently when stength is 1.0 and not. By code analysis and doing some tests, we can find that stength is 1.0 prone to worse results. So I think what you did is totally right to automatically apply reduce it to 0.99 if the user passes strength=1.0. WebUI: In webui, the inference code is not the same as diffusers. There is no code behaves like strength=1.0 in diffusers and it all behaves like strength!=1.0 in diffusers. Coincidentally, when user passes denoising_strength=1.0, it will automatically reduce it to 0.999. 2. outpainting Thank you again for your informations, cheers~ |
so for me works SDXL in main branch can you prepare the 4 fiels for the DEV - branch this is related to torch i think, my idea is to have an onnx model. i tryed with your 4 files but there the inpaint model fails to load |
@kalle07 I tested on dev branch and it works. Can you show the error log? |
ok with the original model its works in DEV but not with the one i merged... in Master branch all runnign fine with my model ... the error in DEV is more or less depend on that the sd_xl_inpaint.yaml is not called if i choose my model, its only called if i choose the original model. (but in Master the yaml file is called and all work also with my model) i note that the original "processing.py" in DEV is 1000bytes bigger than yours |
@kalle07 The files are made from master branch. If you are working on dev branch, do not just replace the 4 files. You need to merge the different codes to files in dev branch. |
Works well even with merges. To install you need to download patch of this pr: https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/14390.diff Then open command line in your webui directory. And run: |
the merge worked THX !!! NAN error: To create a public link, set Recommended settings: Sampling Steps: 80-100, Sampler: Euler a, Denoising strength: 0.8 ', 128, 8, ['left', 'right', 'up', 'down'], 1, 0.05, 128, 4, 0, ['left', 'right', 'up', 'down'], False, False, 'positive', 'comma', 0, False, False, 'start', '', 'Will upscale the image by the selected scale factor; use width and height sliders to set tile size ', 64, 0, 2, 1, '', [], 0, '', [], 0, '', [], True, False, False, False, 0, False) {}Traceback (most recent call last): File "D:\stable-A1111-DEV\stable-diffusion-webui\modules\call_queue.py", line 57, in f res = list(func(*args, **kwargs)) File "D:\stable-A1111-DEV\stable-diffusion-webui\modules\call_queue.py", line 36, in f res = func(*args, **kwargs) File "D:\stable-A1111-DEV\stable-diffusion-webui\modules\img2img.py", line 238, in img2img processed = process_images(p) File "D:\stable-A1111-DEV\stable-diffusion-webui\modules\processing.py", line 768, in process_images res = process_images_inner(p) File "D:\stable-A1111-DEV\stable-diffusion-webui\modules\processing.py", line 902, in process_images_inner samples_ddim = p.sample(conditioning=p.c, unconditional_conditioning=p.uc, seeds=p.seeds, subseeds=p.subseeds, subseed_strength=p.subseed_strength, prompts=p.prompts) File "D:\stable-A1111-DEV\stable-diffusion-webui\modules\processing.py", line 1589, in sample samples = self.sampler.sample_img2img(self, self.init_latent, x, conditioning, unconditional_conditioning, image_conditioning=self.image_conditioning) File "D:\stable-A1111-DEV\stable-diffusion-webui\modules\sd_samplers_kdiffusion.py", line 188, in sample_img2img samples = self.launch_sampling(t_enc + 1, lambda: self.func(self.model_wrap_cfg, xi, extra_args=self.sampler_extra_args, disable=False, callback=self.callback_state, **extra_params_kwargs)) File "D:\stable-A1111-DEV\stable-diffusion-webui\modules\sd_samplers_common.py", line 261, in launch_sampling return func() File "D:\stable-A1111-DEV\stable-diffusion-webui\modules\sd_samplers_kdiffusion.py", line 188, in samples = self.launch_sampling(t_enc + 1, lambda: self.func(self.model_wrap_cfg, xi, extra_args=self.sampler_extra_args, disable=False, callback=self.callback_state, **extra_params_kwargs)) File "C:\ProgramData\anaconda3\envs\stable-diffusion-webui\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "D:\stable-A1111-DEV\stable-diffusion-webui\repositories\k-diffusion\k_diffusion\sampling.py", line 145, in sample_euler_ancestral denoised = model(x, sigmas[i] * s_in, **extra_args) File "C:\ProgramData\anaconda3\envs\stable-diffusion-webui\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "C:\ProgramData\anaconda3\envs\stable-diffusion-webui\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(*args, **kwargs) File "D:\stable-A1111-DEV\stable-diffusion-webui\modules\sd_samplers_cfg_denoiser.py", line 217, in forward devices.test_for_nans(x_out, "unet") File "D:\stable-A1111-DEV\stable-diffusion-webui\modules\devices.py", line 206, in test_for_nans raise NansException(message) modules.devices.NansException: A tensor with all NaNs was produced in Unet. This could be either because there's not enough precision to represent the picture, or because your video card does not support half type. Try setting the "Upcast cross attention layer to float32" option in Settings > Stable Diffusion or using the --no-half commandline argument to fix this. Use --disable-nan-check commandline argument to disable this check. |
@kalle07 you can try --no-half-vae or --no-half param. |
@wangqyqq nop allways out of mem and i have 16GB Vram, but maybe DEV is different... and my goal is to calculate an tensor onnx file from the inpaint so even faster ... but thats the next step ... maybe all works allready in main ? (i only get the tensor running only in DEV one month ago) |
Folks, this is important. Before this instruction, i was not able to load the inpainting model to A1111. Just do what is instructed here, and it works!! Thank youuu |
I found the solution, it's needed to download fp16-fix sdxl vae, and use/bake it instead of original: https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/blob/main/sdxl_vae.safetensors! |
So there is a complete recipe: A: sd_xl_base_1.0_inpainting_0.1.safetensors Works for realVisXL 3.0 too for me |
@light-and-ray You can use the checkpoints I have prepared and avoid having to bake in another VAE, they are the ones mentioned by @wangqyqq in the initial issue and then referenced by @gel-crabs a little after. https://huggingface.co/benjamin-paine/sd-xl-alternative-bases Interpolation Method = Add difference |
hey Jugger was also my first try and i go same steps like you, with fp16 and VAE ... I thought that was normal ^^ |
I am gonna test this now i wonder will there be any difference |
@FurkanGozukara i have upload a juggerXL inpaint-model on civitai ... someone suggested FooocusControl, which I mentioned in my description there |
thanks |
@wangqyqq former in sd15 it was the instruct-pix2pix.yaml that provide the right stuff |
It is not pix2pix, it's random fine tuning or even merge, which the author called pix2pix just for bite. There are a lot of similar sd checkpoints with midjourney/dall-e/nai3 in the names |
@wangqyqq i mean is it not similar to SD15? and again these SDXL checkpoint dont work in automatic1111 i think a new instruct-pix2pix.yaml must be generated, what do you think ? |
Does this method apply to Turbo models as well? |
I would be interested as well, whether you can create Turbo Inpainting models! |
you can use |
Description
Screenshots/videos:
Checklist: