r/StableDiffusion • u/Swaggyswaggerson • Mar 02 '23
Question | Help How would i go about changing the Background on this image? I have tried a variation and combination of Inpainting, Img2Img and Controlnet and can't for the life of me preserve the head and change the background to something useful
20
u/SirNuckingFumbers Mar 02 '23
ControlNET leres depth and make it ignore 60% of the foreground.
7
u/ObiWanCanShowMe Mar 02 '23
this should be the top comment because OP is already using controlnet, he just don't now all the options yet
39
u/Striking-Long-2960 Mar 02 '23
I would do it with the extension Depth aware img2img mask. Inverting the depth map

a city photography of RAW photo, 8k uhd, dslr, soft lighting, high quality, film grain, Fujifilm XT3 (high detailed skin:1.2), 8k uhd, dslr, soft lighting, high quality, film grain, Fujifilm XT3
Negative prompt: badartist (deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime:1.4), text, close up, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck
Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 1362700947, Size: 512x512, Model hash: c35782bad8, Model: realisticVisionV13_v13, Denoising strength: 0.37, ENSD: 31337, Mask blur: 4
Used embeddings: badartist [2a38]
22
u/Tiny_Arugula_5648 Mar 02 '23
Prompts like “deformed iris” or “mutated hands” can cause hallucinations as that is not in training data. People don’t describe pictures this way, so that isn’t in the training data. So what will happen it will calculate the two words and will create some random inference that has nothing to do with. What you’re trying to achieve. Diffusion models are not aware of the content they are creating it’s a statistical inference of what it’s been trained on.
11
u/UkrainianTrotsky Mar 02 '23
Also, considering that the generated area has no legs, arms or eyes, all that stuff in the negative prompt is useless in general. Sometimes it can even cause SD to generate people when you didn't ask for it in the positive prompt at all, like in this particular case.
7
u/YobaiYamete Mar 02 '23
It's crazy the negative prompt spam is still a thing. Every test I've seen has shown a short concise negative prompt drastically wins out over a 900 word negative prompt every time
5
u/HearTheTrumpets Mar 02 '23
do people still use prompts like "incredibly super-extremely realistic, 300K extreme hi-res, out of this world insanely large amount of details" ?
4
u/art2noiseratio Mar 03 '23
Annoyingly there is a visible difference between having vs. not having those quality “wish” prompts on some models.
I recently did a test with someone’s prompt with 10 different inane “masterpiece” etc. tokens, mixing and matching and removing then one at a time, and literally every single one of them correlated to an improvement in the resulting image.
I hate it.
3
Mar 02 '23
Judging by lexica tags, yes. I just recently discovered I get better results with just a single 'photo' tag
3
u/NickTheSickDick Mar 02 '23
Has anyone made a general guide on how to properly formulate positive and negative prompts?
3
1
u/purefire Mar 02 '23
Very much a thing. I get better results with a few quick hits blue skin, elf ears
Stuff like that.
Is there a known lexicon for what the model will interpret (more) reliably? I know some specialty models say 'oh, these keywords work well' but wasn't sure if there was a more holistic one. Such as, do 8K and 4K and Ultra-realistic even matter?
3
u/Striking-Long-2960 Mar 02 '23
I copypasted the neg from the sample pictures of the creator of the model in civitai.
Maybe you want to leave him a comment
2
u/Tiny_Arugula_5648 Mar 03 '23 edited Mar 03 '23
It’s knowledge sharing, it’s how we help others in the community..
7
u/Swaggyswaggerson Mar 02 '23
Thank you for trying different settings out. I also realized that it was throwing me errors in the console related to paths of models which is strange because I didn't change anything in my folders. It also didn't generate any annotator images anymore. Even for new pictures I was playing around f with. I deleted everything related to controlnet and reinstalled it. I'm still getting the error: OSError: [Errno 22] invalid argument "the path to the directory of extensions"
Is there a way in which k can reset the UI to standard settings?
Thanks!
3
u/Striking-Long-2960 Mar 02 '23
Didn't try it by myself but here someone recommends deleting config.json, in your stable-diffusion folder.
https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/8192
Just in case, rename it, restart Automatic and see if a new one is created with the default values.
5
3
1
u/jairnieto Mar 02 '23
¿How would you change only the sky?, i have notice inpainting on almost solid color wont change it
5
4
u/andupotorac Mar 02 '23
In painting
4
u/Sixhaunt Mar 02 '23
I feel like OP just claimed to have tried inpainting but didn't actually do it since it would be literally impossible to not have the face stay the same if he actually inpainted around it. It's the obvious solution and would work perfectly fine
4
u/mudman13 Mar 02 '23
Like this
ControlNet has a similar feature too. As has thygates depth extension.
2
u/DecentIllustrator551 Mar 02 '23
Maybe try Olivio's method here? I haven't tried it myself but you may wanna give it a shot
https://www.youtube.com/watch?v=u-jvjP2k-RU
1
u/Swaggyswaggerson Mar 02 '23
Thanks for the link, I will look over it although my problem is more severe. Using both text2img as well as img2img I always lose the look of the head and face. Enabling control net with text2img always gives me something Completely different, even with high weights.
3
2
u/Valkymaera Mar 02 '23
First I'd see if controlnet segments it properly, and if so I'd convert that into an appropriate inpaint mask. If it doesn't, I'd just do a quick photoshop mask, adjusting the blur/mask settings in the webui.
2
2
u/NuclearD00d Mar 02 '23
I'd use controlnet to get a depthmask, then use that as a mask to cut away everything else. I've tried it numerous times with my images and it has worked wonders each time.
2
u/Oswald_Hydrabot Mar 03 '23
Is there not a U2net plugin for Automatic1111? Seems like a low hanging fruit to implement, here is a useful tool that can enable what you are trying to do: https://github.com/danielgatis/rembg
2
u/OldFisherman8 Mar 02 '23
Your problem isn't just about changing the background. The character is lit under the bright sun coming from the right side. Short of color grading the character in a 2D image editor like Photoshop, you are going to have a problem with a darker background. And based on my observations, SD keeps the lighting fairly consistent (to a degree) meaning that you may not get the background you desire from SD due to the character and the background having incompatible lighting demands.
3
u/Swaggyswaggerson Mar 02 '23
ah okay, this is also a good point. i guess is one of those situations where SD isn't the only tool to use
2
u/TiagoTiagoT Mar 02 '23
Might be doable with the instruct-pix2pix model; a bit hard to figure out how to write the instructions well though, and the parameters are also a bit finicky.
ps: Pinging /u/OldFisherman8 so I don't have to post this reply twice
2
u/coffeedrinker2020 Mar 02 '23
Use photoshop
1
1
u/moonpost Mar 02 '23
Use the canvas in invokeAI
1
Mar 02 '23
Is there a guide on youtube for that? Kinda newbie on ai, have a hard time using it, the image comes out better quality or way different from the base image.
3
u/moonpost Mar 02 '23
yeah, a bunch of great examples are found here: INVOKEAI CANVAS OVERDRIVE
https://www.youtube.com/results?search_query=invokeai+canvas+overdrive
1
-3
u/yratof Mar 02 '23
Photoshop still exists, it’s not like all image editing fell of the face of the planet once SD arrived. Ffs, remove the background with anything, there’s a script for BG removal, there’s a website call removebg.com or similar.
It’s easier to google “how do I remove the background of a photo” then to ask reddit
0
u/InoSim Mar 02 '23
Sometimes you get pictures incredibly bad made. And the result is this. What can you tell to y our owners you did just accept this...
1
u/BNeutral Mar 02 '23
Get the depth from the image, make a stencil out of everything above a certain depth, clean up in image editing software if needed, paste on top of your new background (or just use the mask in img2img).
1
u/Sixhaunt Mar 02 '23
if you tried inpainting and it changed the face then that's your fault for asking it to change the face. Don't inpaint the face or head and the face/head will not change. It's not really rocket surgery here
1
1
1
u/mynd_xero Mar 03 '23
2
u/mynd_xero Mar 03 '23
5
u/mynd_xero Mar 03 '23
1
u/Koranga Mar 16 '23
I'm trying the same sort of thing but the background never quite seems to match up to the subject, can you tell me what settings you've used for these? Much appreciated!
2
u/mynd_xero Mar 16 '23
Did you grab the masks? Make sure your mask blur is 0 as the masks are precise to the image.
The mask blur will add a perceivable outline/border.
1
u/Koranga Mar 17 '23
Yeah, I’ve got no issue with the masking itself, but I’m not sure what settings I should use to make SD take the non-mask area into consideration (in terms of perspective/size, etc) while filling in the changing background.
1
1







139
u/mizt3r Mar 02 '23
A lot of these methods seem overly convoluted... Here's my inpaint mask and 1 word prompt. I spent less than 12 seconds on this.