-
Notifications
You must be signed in to change notification settings - Fork 314
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
support Inpaint models #511
Conversation
this is great, thank u so much, please add outpainting while u r at it, i think they are the same |
@Amin456789 You can set it up to outpaint already, you just need to manually prepare the image and mask (I recommend pre-filling parts to inpaint with 50% grey, since it's based on img2img)
|
greaat. thank u |
If the pr is merged, i will add to it. This is already in my to-do 🥳 |
bool is_xl = false; | ||
bool is_flux = false; | ||
|
||
#define found_family (is_xl || is_flux) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
found_family
seems to impact the detecting of sd3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate? In my testing, sd3 seems to be detected reliably...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm, with the recommended safetensors loading, it works with sd3. however, if text_encoders.clip_g.*
is converted to cond_stage_model.1.*
(gguf mode), the following processing will be judged as sdxl, and sd3 will not be recognized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thxCode what about now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great
if (is_xl) { | ||
if (is_inpaint) { | ||
return VERSION_SDXL_INPAINT; | ||
} | ||
return VERSION_SDXL; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sdxl takes priority over flux.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a problem? In theory it should be impossible for a model to be deteted as SDXL and Flux at the same time, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, this should only be encountered after merging all FLUX components into one gguf file following cond_stage_model.*
/ first_stage_model.*
/ model.diffusion_model.*
format.
stable-diffusion.cpp
Outdated
|
||
struct ggml_tensor* concat = is_inpaint ? ggml_new_tensor_4d(work_ctx, GGML_TYPE_F32, 8, 8, 5, 1) : NULL; | ||
ggml_set_f32(timesteps, 0); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here seems to impact sd2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of impact?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, this might be a false positive from my testing(i remember testing on 4090 resulting in sd2 using v-prediction mode
instead, but I can't reproduce it on my mac m1 max.).
btw, it looks strange here. timesteps
changed from 999 to 0 without any judgment? or do you mean setting concat
to 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, it looks strange here. timesteps changed from 999 to 0 without any judgment? or do you mean setting concat to 0?
Oh right, that's exactly what I meant to do.
Thank you for your contribution. |
Adds support for sd1.x inpaint, sd2.x inpaint, sdxl inpaint, and Flux Fill models, as well as "inpainting" (masked img2img) with normal diffusion models.
How to use
img2img
mode with the--mask
argument to specify the path to the masking imagestrength
to1
Examples:
Using Inpaint model:
sd.exe -M img2img --model ..\models\sd-v1-5-inpainting.safetensors -p "a lovely dog" --cfg-scale 16 --sampling-method euler -t 24 --color --steps 30 --vae-tiling --strength 1 -i '.\inpaint-base.png' --mask '.\inpaint-mask.png'
Using normal model (not as consistent):
sd.exe -M img2img --model ..\models\unet\sd3.5_medium-q6_k.gguf --clip_g ..\models\clip\clip_g.q8_0.gguf --clip_l ..\models\clip\clip_l.q8_0.gguf --t5xxl ..\models\clip\t5xxl_q4_k.gguf -p 'a lovely dog sitting patiently on a park bench' --cfg-scale 4.5 --sampling-method euler --steps 30 -t 24 -W 512 -H 512 --seed 0 --color --vae-tiling --strength 1 -i '.\New folder\inpaint-base.png' --mask '.\New folder\inpaint-mask.png'
Caveats
Fixes #105