{"id":2449,"date":"2023-05-21T22:18:02","date_gmt":"2023-05-22T05:18:02","guid":{"rendered":"https:\/\/xyzcreativeworks.com\/?p=2449"},"modified":"2023-05-23T18:48:33","modified_gmt":"2023-05-24T01:48:33","slug":"is-stable-diffusion-inpaint-obsolete-versus-instructpix2pix-add-glasses-to-face","status":"publish","type":"post","link":"https:\/\/xyzcreativeworks.com\/is-stable-diffusion-inpaint-obsolete-versus-instructpix2pix-add-glasses-to-face\/","title":{"rendered":"Is Stable Diffusion Inpaint Obsolete Versus InstructPix2Pix? (Add Glasses to Face)"},"content":{"rendered":"\n

New tech and methods are always exciting, but I have started to think old methods that endure are still the best.<\/p>\n\n\n\n

I recently received a request to find out how to put sunglasses on an image.<\/p>\n\n\n\n

I tried two methods: Inpaint and InstructPix2Pix.<\/p>\n\n\n\n

The goal is to put sunglasses on the portrait. Black sunglasses with minimal reflections. Like these images of Jason Statham:<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n

Base Image<\/h2>\n\n\n

When doing something experimental, I like using the least complicated images.<\/p>\n\n\n\n

In the case of sunglasses, we don’t want long hair making it difficult for the AI. <\/p>\n\n\n\n

Having hair would mean the AI has to find a way to hide the frame behind the hair. That makes it a bit more difficult.<\/p>\n\n\n\n

And when you make things difficult for AI, you’ll need to do more Photoshopping.<\/p>\n\n\n\n

Anyway, here’s the base image: a bald guy.<\/p>\n\n\n

\n
\"bald<\/figure><\/div>\n\n

Inpainting In Stable Diffusion<\/h2>\n\n\n

Inpainting in Stable Diffusion refers to a powerful technique used in image editing to restore missing parts of pictures or create entirely new elements within an existing image. \\<\/p>\n\n\n\n

It’s the basis of how you can do a face swap in Stable Diffusion<\/a>.<\/p>\n\n\n\n

In this case, the guy isn’t wearing sunglasses, but we want him to.<\/p>\n\n\n\n

\"putting<\/figure>\n\n\n\n

It’s pretty simple. Just mask the areas where a sunglasses will go.<\/p>\n\n\n\n

I am using Realistic Vision 2.0 as a model and a simple prompt “sunglasses on face”. I tried adding “black” but I still got multi-coloured sunglasses.<\/p>\n\n\n\n

One thing I like to do is to create a CFG-Denoising plot. I’ve got a guide on how to set it up here<\/a>.<\/p>\n\n\n\n

You’ll know why:<\/p>\n\n\n\n

\"sunglasses<\/a>
Click to enlarge<\/figcaption><\/figure>\n\n\n\n

In fact, setting a X\/Y plot up is so important that I’ve already set it up so it appears by default<\/a>.<\/p>\n\n\n\n

As you can see, the middle CFG and middle denoising produces the best images.<\/p>\n\n\n\n

Too little denoising and nothing happens. Too much and it becomes a face in a face.<\/p>\n\n\n\n