Inpainting cleanup: misc fixes following PR #2309 review#2321
Merged
Conversation
- sdxl_train: drop leftover .reshape(batch["images"].shape) no-op in masked-image VAE encode (dead since the ff7945d batched-mask fix). - model_util.expand_unet_to_inpainting: use unet.register_to_config(in_channels=9) so the diffusers FrozenDict stays in sync (the previous isinstance(..., dict) guard either silently skipped or raised, depending on diffusers version). - sample_image_inference: round resolution to mod-32 for SDXL (2 downsamples, latent /4) and mod-64 for SD1.5/2.x (3 downsamples, latent /8); fix the inaccurate "SDXL requires latents divisible by 8" comment. - inpainting_minimal_inference: remove unused denoise() — the actual loop is inlined in main(). - BaseDataset.random_mask: drop unused ratio / mask_full_image parameters and the dead cloud_mask import. - Rename per-prompt --img directive to --i for consistency with Musubi Tuner (which already uses --i alongside the shared w/h/l/d/s directives). - When --train_inpainting is set but the prompt has no --i, warn and skip the sample instead of falling through to the standard pipeline (which would crash the 9-channel UNet on 4-channel input). Matches the existing missing-file skip behaviour. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
3 tasks
kohya-ss
added a commit
that referenced
this pull request
May 6, 2026
…tional PR #2321 changed sample_image_inference to return early when --train_inpainting is set and a prompt line has no --i directive. The doc still described the previous behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Final cleanup PR for the inpainting feature merged in #2309 (#2319, #2320 covered earlier follow-ups). Bundles six small, independent items:
.reshape(batch[\"images\"].shape)no-op in the masked-image VAE encode path. Dead since the ff7945d batched-mask fix.isinstance(unet.config, dict)guard withunet.register_to_config(in_channels=9)so the diffusersFrozenDictactually gets updated. No functional impact (downstream readsunet.in_channels), but the config attribute is now consistent.denoise()function (actual loop is inlined inmain()).ratio/mask_full_imageparameters and the now-deadcloud_maskimport; update the single caller.--img→--i— rename the per-prompt directive for consistency with Musubi Tuner, which already uses--ialongside the shared w/h/l/d/s directives. Updates docs (EN/JA), the parser, the warning string, and the comment.--train_inpaintingis set but the prompt has no--i, the code previously warned and fell through to the standard pipeline, which crashes the 9-channel UNet on 4-channel input. Now warns and skips the sample, matching the existing missing-file skip behaviour.Items #10 and #11 from the original review notes were dropped: #10's described problem doesn't actually exist (the script already splits
vae_dtype/weight_dtypecorrectly), and the gen_img.py--iprecedent referenced in the original #11 came from a sibling repo (Musubi Tuner) — the rename is still useful for cross-repo consistency.Test plan
inpainting_minimal_inference.pystill runs end-to-end--train_inpaintingruns (caller path exercised)--iworks;--imgis silently ignored; missing--inow warns + skips instead of crashing the 9ch UNet🤖 Generated with Claude Code