Hello, nice to meet you. This time, I will explain the function of InPaint in Image2Image. InPaint is really easy to use at first You may think, but the more you use it, the more confusing it is. Even those who do advanced processing One of the things that are difficult I think it's this InPaint function. So when you first encounter this function You have to practice a lot If the result doesn't come out as you want, it's a failure. So it's my own know-how One of the most important functions I think it's InPaint. So today, I'm going to introduce the basics of InPaint. Now, let's explain how to use the InPaint function. Go to the Image2Image tab first There are tabs like Image2Image, Sketch, InPaint. Click the InPaint tab in this tab You can drag any image you want to change the image. Pictures on the market Or the image I made through this stable diffusion It doesn't matter if it's an image made by another Dali or Midzeni. Any image can be InPaint. I'll take the image I made before I'll do the InPaint work. Click and I'll do the InPaint work with this woman's picture. InPaint work is to modify this image. So in this image I've brought It's okay now, but for example, I want to put on glasses or sunglasses. But no matter how much you turn it in the Image2Image Even if you turn it in the Image2Image, the sunglasses don't fit. In this case, InPaint work is done. Only a specific area is masked InPaint work is to change only that area. As I just said I'm not wearing glasses in this woman's image. I'll try to put on glasses. To proceed with the InPaint work in earnest Let me give you a brief explanation. If you look down differently from Image2Image The functions are almost the same, but there are some additions. If you look at the Image2Image Select method, mode, size Denoising strength is just this much If you go back to the InPaint tab Mask blur, mask mode, mask content, InPaint area These things are added. Depending on how you give this value The result of InPaint changes a lot. So you have to pick this function well You can create the InPaint result you want. Now, let's quickly go from this resize mode to the denoising strength below. How does it affect InPaint mode? Let's go over it. In the case of resize mode, I explained it several times in Image2Image. I'll put a link to this. If you don't know about Image2Image yet, I recommend you to look at it and come back here. In the case of mask blur, It's better to just leave this value as it is. It's good to try it later and adjust it little by little. The higher this number goes, the more likely this mask will be applied. You can think of it as decreasing. The closer it is, the more likely the mask will be applied. So first of all, you can use this default value 4 as it is. Now, there's a second mask mode. This mask mode is really important. InPaint Masked is... I painted it like this to put on my glasses. You can think of this painted part as a masked part. So after painting like this, If you go to mask mode and check InPaint Masked, It means that I will only change the part I painted. So if you check InPaint Not Masked, What image will it look like? Except for this part, the rest of the background changes. So how do you use this when you make an image? It's very important for you to check it in advance. I just made an example of this woman's image. I'm going to put on my sunglasses, I'll check InPaint Masked and proceed. And thirdly, there's a masked content. Now, this part is really confusing and difficult. But if you're just using it for the first time, I recommend checking the original and using it. Everyone has a different way of using this. It's hard for me to explain what this is, what this is. I think it's better to explain one by one while running the image. In the case of fill, when I make something out of this image, So when you fill in something, When you fill in something that doesn't have to do with the surrounding objects, This fill function can help a little. Second, the original is my favorite function that I use a lot. This original is based on this image now. It helps you apply this mask as similarly as possible to this image. So I usually don't get out of the original. If the original doesn't work, Then step on the order of going to fill. And latent noise has latent noise and latent nothing. Latent noise fills the masked area with noise that has nothing to do with this image. So based on that noise, I combine it with my prompt and denoising intensity to create a new image. Honestly, I rarely use this. And the fourth, latent nothing, is similar. This is basically erasing the masked area with nothing. In that state, I combine it with denoising intensity to create a new image. So if you try to change something as similar to your image as possible, I don't think it's a function that I use much. Of course, what I understood may be wrong. If you know more about this part, please leave a comment or leave a comment. So the function I'm going to check this time is this original. I'm checking the original so that I can make sunglasses that look as similar to this image as possible. Next, I recommend that you keep the only masked padding pixel as the default value, just like the mask blur. The new part of the area where I masked and the area where I masked is filled. It seems to express the distance between the contents. But you don't have to touch this. So I've never touched this. But if you don't like it while using it, you can change it at any time. But from the perspective of the first user, I recommend that you follow it as it is. So I'm going to leave this default value as it is because it's set to 32. Now, there's an in-paint area. In-paint area has a whole picture and only masked. There's only one thing I felt while using this. If you create an image with a whole picture, you will be affected by the size of the image. So, for example, if you click on the size of this image, you'll see. I clicked on it, and it's 576 x 1024. But in this state, I'm going to leave it at 512 x 512, and I'm going to leave the in-paint area as a whole picture. If you create it, this image will be crushed. It's affecting the black of the image. Now, let's leave it as it is. I'm going to explain this again, but if you look at it, 576 x 1024 image is just resized to 512 x 512. You can see it crushed. So if you're going to set this whole picture as an in-paint area, you have to make it the same size as the original image. But I'm using this, and it's not working well, so I usually use it. Check only masked and use this function. If you check only masked, you can change the horizontal and vertical sizes to the size you want. In only masked, the size is determined in this way as a result of my use. If this size is 576 x 1024, but I want to leave it at 512 x 512, Then how does it work? Based on this masked area, this part is affected by 512 x 512 size. So it doesn't affect the final size of the image, I think it only affects 512 x 512 pixels in the middle of this masked area. So let's take a look at the process of work. Now, the image has been created after the expansion has been made in the masked area. Unlike the whole picture, it does not affect the overall image size, It is only affected by 512 x 512 based on the masked area. So when I do in-paint work, especially when I modify only certain parts, I don't use the whole picture, I mostly use only masked, and I just set the size to 512 x 512 as the default value. I think this is the best value. Of course, there are many people who do it in other ways. But when I used it, this method was a little better, I think beginners can use this method as it is. If there is a better way than this, I would appreciate it if you could let me know. I would appreciate it if you could come to the comments or cafe and share information. And I explained the sampling step in the image-to-image. It affects the image quality. I'll just leave this as the default value this time. Now, let's just leave the CFG scale as the default value. Now, denoising strength. This is really important. This is what I explain every time I go into image-to-image, I always explain that denoising strength is the most important. Especially in InPaint, you can think of it as taking up about 80% of the denoising strength. Now, I said I'd put on sunglasses in this image. To put on sunglasses, I colored only the areas with eyes like this. Now, through the denoising intensity, we are now combining it with the prompt to create a new image. We need to think about what to give this denoising intensity as a standard. It's simpler than you think. Now, you just need to think about two things. What do you create new? Or do you change a little bit from what you had? You can think about it. If you change a little bit from what you had, It's a little change from the color of your hair or your skin. The number I give a little change is usually less than 0.5. But I said I'd put on sunglasses in this woman's image this time. Now, putting on sunglasses is making something that didn't exist. Now, to make something that wasn't there in my eyes, You need something new. So you can give a little higher denoising intensity at this time. So it's the default value right now, but you can give it 0.5 or 0.6, 7, 8, or 0.9. But if the number goes up too much, No matter how much I do this mask content as the original, You can get a weird image. So it's good to give the denoising intensity several times. But it's making something new that didn't exist. I'll leave it at 0.75 and create an image. And if you want to put on a mask, it's not a mask, it's sunglasses. What do you do to put on sunglasses? You have to do it. At the end, this prompt is also included. So I wrote it down in advance, but I'll explain it again. First of all, it's a woman's image, so I wrote one girl. Wear sunglasses. If you simply enter this, the result will come out. I'll leave it in this state and create it. Create The first result came out. Let's check it out. Now, if you look at this, you can see how it changed from the original. I can't feel the difference right now, so I'll take a look at the original. The left side is the original, and the right side is the image of the sunglasses that I just painted. If you look at it, the original and the other parts haven't changed at all. You can see that only the sunglasses are naturally placed on the eyes. But these sunglasses will come out at different prices every time. So now I don't like these sunglasses. Then you can create a new one and spin it until you get the sunglasses you want. Or if this sunglasses is too unnatural, adjust the mask area little by little. Or if you adjust the denoising intensity, you can get better results. I don't like this sunglasses a little bit, so I'll just change it back to glasses. Now, go back to the prompt window, and I don't think there's anything to touch anymore. I'll just change the glasses to English and create them again. Create Now, the result of only putting on glasses has been created. Then, I'll put the original image of putting on sunglasses and the image of changing it to glasses and compare them. Now, the left side is the original image. And the middle is the first image we put on sunglasses and pulled out. And the last image is the image of sunglasses that I just put on glasses because I didn't like it. Personally, I like the image of putting on glasses the most. Now, if you do inpaint, you can only fix the part you want without affecting the background or other parts. But if you're quick-witted, you may have already found something strange. If you look closely, you can see that it's different from the original eye. Now, I had to do that because I painted all this side of the inpaint area. Now, if you look again, I painted all the areas around the eyes like this. Now, since I set all this part to the mask area, all the pupils are included. Now, then, this eye will eventually have to be changed. So, if you just want to make the border easier, you can set the mask area like this. I can reduce the size of the mask and make a frame of glasses like this to do inpaint work. Of course, the result is not 100% guaranteed, but I'll try to create it again in this state. Now, the result is out. I'll compare it with the image taken. Now, the left is the original image, and I just set the inpaint part to the area where I put on the frame of glasses. Now, you can see that the frame of the left eye is almost the same. Now, you can see that the inpaint work is done by recognizing only the part I set as a frame of glasses. The inpaint work was not perfect, but if you proceed in this way, you can add a new object or frame of glasses while saving the part you don't want to disappear. But when I first do inpaint work, it often doesn't work as I want. So, there are quite a few people who give up when they do inpaint work. But if you keep doing it, you'll have to do well in this field. Don't give up. If you have a difficult part, please leave a comment or come to the cafe and post it on the question board. There are a lot of people who are really good at it, so I think I can help you with the comments. So, that's it for today's lecture. I'll see you next time with more useful content. Thank you.