00:00Are you ready for another video tutorial? Today, we will talk about editing images with AI using Flux to Kline
00:07Flux to Kline is an image AI model made by Black Forest Labs
00:10It is very fast and works on low VRAM
00:13It can do two main things
00:16First, it can generate images from text
00:18Second, it can also edit images, meaning you can give it a picture and tell it what to change, like make it night time or change the outfit
00:29The name Kline basically means little in German
00:31So, compared to bigger models, it is designed to run quicker and feel more responsive, while still keeping strong image quality
00:41As usual, the workflows are free on Discord in the Pixel Roma workflows channel
00:46You will need to download the file for episode 04
00:49And here you have a zip archive with today's workflows
00:52You can download that archive on your computer
00:56Go to the ComfyUI folder and look for the user folder
01:00Click on default and finally the workflows folder
01:04This is where you need to put the workflows
01:06Let's go to that folder now
01:09You can see I am in the workflows folder
01:11I will extract the content of the archive here, then I will delete the zip archive
01:15After that, you should have, like me, the episode 4 workflows
01:21And inside you will see two folders with workflows for two versions of the models
01:25After that, you can go to ComfyUI and on the left you have workflows
01:30Click on the refresh button so it can see the workflows we just added
01:34You can also click on the arrows to see the content of those folders
01:39Let's open the image generation workflows first
01:42I will open both just to show you the difference, but you can keep only the one that works best for you
01:47If we go to the first one, you can see it says Flux to Kline and then it has the number 4B, which stands for 4 billion parameters
01:58For the second one, we have the 9B version, which is smarter and for my tests gives better results, but it can be a little bit slower and needs more VRAM
02:10I managed to run both without problems on my older PC with 6 GB of VRAM and 64 GB of system RAM
02:16Also, the license is different
02:19You cannot use the 9B model for commercial work, but you can use the output images you generate with it for commercial work
02:27Both models I show today are distilled versions, so they work with only four steps
02:33There are also base versions that people use for training and other stuff, but for my tests, these are faster and the results are actually better
02:39Another difference is the text encoder used
02:41For the 4B version, the text encoder is Qwen 3, the 4B version, and for the 9B version, we use the text encoder with 8B instead of 4B
02:55But don't worry, you have in the workflows exactly the links for each model, so you don't get them mixed up
03:01The workflows are quite simple
03:03I will show you first the image generation workflow, since it is easier to understand, and you already practiced this in other episodes, and then we can continue to adapt it for editing and inpainting
03:15On the left side of the workflow, you have a note with links to all the models
03:19Let's download the diffusion model first
03:23You should know by now that all models go to the models folder, and for Flex Client, we need to place it in the diffusion models folder
03:28To keep it organized, I will create a folder called Flex 2, since it is quite different from the first Flex version, and we save the model here
03:38Then it is time to download the text encoder
03:42We navigate again to the models folder, and this time we go inside the text encoders folder, and we save the model there
03:49I already have it
03:49The last model is the VAE
03:52Again, go to the models folder, look for the VAE folder, and save it here
03:59Now, I will repeat the steps for the 9B model
04:01We download the diffusion model in the flux 2 folder
04:04Then we download the Quinn text encoder in the text encoders folder
04:08And the VAE is the same VAE as in the first workflow
04:13Okay
04:13Now, all you need to do is wait for the models to download
04:15Then you can refresh by pressing the R key, which will refresh the node definitions
04:20Now, we can select the models on each node just to make sure
04:24If you have the same folders and models like me, it should already be selected in those nodes
04:32Let's run the workflow now, and we got our first image generated with this flux 2 Klein model
04:35Let's test the 9B version also
04:40I check the models are there, and run the workflow, and we got our result
04:44Now, if you are interested in the difference between these two models, the 4B version is quite fast
04:48It takes around a second on my 24 GB VRAM card to generate an image, which is crazy fast
04:58And the 9B model takes around 1.8 seconds
05:02But the less VRAM you have, the bigger the difference in speed will be
05:06When it comes to quality, definitely the 9B gives better results compared to the 4B version
05:13So, if the speed difference is not huge for you, I would go with the 9B version
05:18Not only does it have 9 billion parameters, but the text encoder we use with it has 8 billion parameters
05:22So, the results are more accurate
05:26What I want to do now is recreate the simple workflow from scratch, so we can practice a little
05:32Let's create a blank new workflow
05:34Double click on the canvas, search for load diffusion model, then select your model
05:39For this example, I will show the 9B version
05:43You can resize the node to see the entire model name
05:47Let's add another node called load clip
05:49For this one, we need to change the type to flux two
05:51Then for the model, I will select Quinn three, the 8B version
05:58Next, we need a node to load the VAE model, and here we select the flux two VAE
06:04If you are a beginner, make sure you check episode one first, where I explain things in more detail about how nodes work
06:12Now search for clip text encode
06:15I like to make this one green, and I can change the title to say positive prompt
06:20Since we are using the distilled model, I will not use a negative prompt
06:22The next node we need is the K sampler
06:27Okay, let's create some links between these nodes
06:29We connect our model to the K sampler
06:33We connect the clip to the text encoder, and then connect that to the positive input of the K sampler
06:40I told you we don't use a negative prompt here, so I will add a conditioning zero out node
06:45Now we can connect it like this, so we are able to connect something to the negative input, and we don't get an error saying it is missing
06:52Next, we have the latent input
06:52Let's search for empty flux
06:55Until now, we used empty latent or empty latent SD3, but now we use one called empty flux two latent
07:04I will make it purple, and now we can connect it
07:06From the K sampler, we need to decode the information, so we add a VAE decode node, and we connect the VAE input to the VAE model
07:16All that is left now is to save the image with a save image node
07:22That's all
07:23Let's run the workflow
07:25Obviously, it doesn't look good, so we need to adjust some settings
07:28Let's change the steps to four and the CFG value to one
07:33Let's also add a prompt really quick and run it again
07:35Now our workflow works, and we got a bunny ninja
07:43I can compare this to the one already saved that you can download from Discord if you don't want to do all the steps yourself
07:49It is identical
07:49Just arranged a little bit better so it doesn't take up so much space
07:55You can save the workflow you just created if you want, but I already have it, so I will not save it
08:01I will also close the other workflows and leave only this image generation workflow
08:06Now, I want to show you how you can change this into an image editing workflow since most people will use it more for that
08:12If I open this one image edit workflow, you can see it has some extra nodes
08:19It looks more complex, but it is actually quite simple once you understand it
08:23In fact, I will show you how to modify the previous image generation workflow into an image editing workflow
08:32I move these nodes to the side to make some room
08:34Now, let's search for a node called reference latent
08:36We actually need two of these, so I will duplicate the node
08:41Reference latent lets Flux Klein follow a reference image at the latent level, helping preserve things like composition, style, or character consistency instead of relying only on text
08:53So, let's connect the top one to positive and the bottom one to negative
08:58Now, we need to connect the other side
09:00From positive, we go to the top one, and we need to do the same for negative
09:05Since we don't use a negative prompt, we pass the conditioning zero out through it
09:10Let me arrange this a bit so it's easier to see
09:12Now, all that's missing is a latent
09:14We already have one, but for the reference, we need an image latent, not an empty one
09:20So, let's add a load image node
09:22You should have this bunny explorer image if you use the easy installer
09:26If not, you can download it from Discord
09:30Next, we need a node called image scale to total pixels to make sure the image size is around 1 megapixel
09:35If the images are too big, the model can get confused because it was not trained with very large images
09:41So, after the image is loaded, it is resized down to a manageable size
09:46You can use different upscale methods here
09:48I like to make any nodes that work with size or image resolution purple
09:53Now, we need to encode that image to get a latent
09:55So, we use the VAE in code node
09:57Then, we connect that latent to the reference latent node, so it knows which image to reference
10:06Now, it will take the prompt and also the reference from that image and send everything to the K sampler, so it can edit the image
10:11We also need to connect the VAE model here
10:14Now, the workflow is done
10:18One thing to keep in mind is that you would normally need to manually adjust the size of the empty latent each time to match the size of the loaded image
10:26But, to make this easier, we can automatically get that size
10:28Let's drag a link from here and search for get image size
10:33With this node, we can output the width and height
10:36So, now the image is loaded, resized to a manageable size, we get that new size, and we connect it to the empty flux to latent
10:46This way, the size of our generated image will always match the size of the reference image
10:50I hope this didn't mess with your brain too much
10:55>> [laughter] >> Let's run the workflow
10:57We obviously need to change the prompt and talk about the actual bunny and what changes we want for the edit
11:02So, we need to give instructions prompts
11:06For example, let's say replace the clothes with orange clothes, and let's run it again
11:11Now, we got the bunny in orange clothes
11:13But, it is kind of hard visually to compare the original with the generated image when one image is at the beginning of the workflow and the other one is at the end
11:24Luckily, we have a node for that
11:24Search for the image compare node from RG3
11:29Let's see how we can link the images
11:31We want the image after it is scaled down to be connected to image A and the image after it is decoded to be connected to image B
11:39That should work
11:41Let's run the workflow
11:42We got this small preview here
11:42Let's make it larger so we can see it better
11:47Now, if we move the mouse to the right, we can see how it looks after
11:50And if we move it to the left, we can see it before
11:55This makes it quite easy to compare
11:58So, this is an edit workflow for this model
12:00If we go to the one downloaded from Discord, you can see it is identical
12:02I called it one image edit because it edits one image
12:10If we go to workflows, you will see later that you can edit two or more images or use it for in-painting a specific area
12:18What is different in the workflow from Discord is that we have a small note here that is collapsed
12:22Let me zoom in so you can see it
12:25It says prompt ideas with an arrow pointing to that dot
12:30Click on that dot to expand it
12:33I prepared quite a few prompts here that you can use to edit and practice, but I will show you most of them in the tutorial anyway
12:40You can see it says which image you can use to practice, like bunny explorer
12:46This is the bunny explorer image
12:46If we go down, we also have some prompts for logos, like the Pix Aroma logo
12:53But you can use your own logo as well
12:56You should find that in the input folder, too
12:59Let's go back to the bunny explorer and test what the flux climb model can do for us
13:02It is quite good at replacing the background and keeping things consistent
13:05I like to add the instruction first, like what to change, and then add what to keep, like the bunny identity, face, or whatever you want to preserve
13:16You can see how it changed the background and also adjusted the lighting to match, so it looks like it really belongs in that environment
13:24Pretty cool
13:24Now, let's say we want a cabin interior and we want to keep the character identical
13:29For image editing, it takes a bit more time
13:32In this case, almost 7 seconds, but it is still a good speed
13:38The less VRAM you have, the more time it will take
13:42Now, the bunny is in that cabin interior
13:44I added 3D cartoon in the prompt because if I don't, sometimes it gives a very realistic environment that does not match the style
13:51We can also change the lighting
13:53For example, I can change it to a night time scene with moonlight and all that
13:58Or I can make it snow if I want snowflakes and some mountains in the distance
14:04Or you can change specific parts
14:04Maybe I want a different backpack and I want a larger yellow one
14:09And we got what we asked
14:09Obviously, it is not always perfect and for some things it might be harder to edit, but for a small model, it can do a decent job
14:19I can make the bunny be in a running pose if I want
14:21So, you can play with different poses
14:24Or you can play with emotions
14:26Like, I can make it sad and crying
14:31>> [snorts] >> Try different seeds and see which seed works best for what you have in mind
14:36Play with prompts and give details on how you want it to look
14:39Another thing you can do is change the art style
14:41For example, I can change this to a watercolor illustration if I want
14:46Or maybe I want a cell shading cartoon style
14:50So, play with different art styles and see what works
14:54We can also change the style of the outfit or the material of the outfit
14:58Like here, I added a black leather outfit
15:00You can also add extra objects and remove things in the same prompt
15:06For example, I want it to hold a lantern and remove the backpack
15:10It can be hard to control which hand is holding something since it does not seem to understand right and left very well
15:17Sometimes when I want to replace the outfit, it keeps some parts from the old outfit
15:21If that happens, you can prompt it to remove the old outfit first, then add the details for the new outfit
15:26I also added what to do with the hands because if I don't, it will keep the hand in that backpack position and it will not make sense for the new outfit that doesn't have a backpack
15:36Look how cute the bunny is in that summer outfit
15:40>> [laughter] >> Some things with the camera work well, others not so much
15:43You can do a crop or zoom into the face if you want and that usually works pretty well
15:50We can also change the entire color palette of the image like going for a pastel look if I want
15:54Can you imagine how hard this would be to do manually in Photoshop? We can also add text or labels
16:01The 9B model I use is okay with text but not the best and the 4B version is worse with text
16:08Still, if you only need a clear word or two, you can usually get away with it
16:13Here I added a sign with the word pizza
16:17It helps to put the text you want in quotes
16:20You can also change the camera angle
16:22For example, I can get a side view of the bunny, a back view, or other angles
16:28Let's change the input image to something else
16:31I will use this simple black and white logo
16:33Let's say I want that logo to be on a white mug
16:35This can help a lot with branding and presentations for social media
16:41The more details you add, the better you can control the generation
16:43Like here, I put the logo on a coffee bag
16:46I tried to add both a logo and text but it kind of failed so it cannot handle very complex requests all the time
16:53It really depends on what you ask
16:56Here I wanted a woman to hold a tote bag and now we see a common problem with hands
17:03This will happen a lot with this model
17:06There are models like Quinn edit that handle hands better but they are a bit slower
17:10Sometimes this can be fixed by changing the seed
17:12Like here, the hand looks better with a different seed
17:14Or you can prompt it in a way that hides the hands if needed
17:18One thing I really like to do is convert flat logos into 3D looking renders
17:25It is very fast and quite good at it, especially if the logo is simple
17:28It is definitely faster than any 3D software
17:33You can try all kinds of 3D styles and materials
17:37You can also get more creative, like playing with textures, as I did here with this ink splash
17:43Or you can make your logo look like it is painted on a wall
17:46Sometimes I like to do macro shots, like close-up details of the logo on a material, such as textile
17:53This seed looks quite nice
17:53I like the textile texture, and it is better than any mock-up I can do with smart objects in Photoshop, because it blends texture and lighting and makes everything fit naturally
18:06There was a period a few years ago when gold foil mock-ups were very popular, and you can easily recreate that style here
18:12The imagination is really the limit
18:15Using an edit model lets you use your own images and modify them
18:17So even if we use AI, the result feels more unique
18:23Let's try it with a sketch and see what we can do
18:25I want to colorize this into clean, flat colors with a cartoon cell shading look
18:32It is quite similar to the sketch, but I did not prompt what colors I want
18:34So I got random colors
18:36With each seed, I will get a different variation
18:41If you want to be more precise, you can add details like red clothes, green hills, blue sky, and so on
18:45And you should get something closer to what you asked
18:50It is quite powerful when it works
18:52But like I said, for some things it can fail
18:55Sometimes you can clean up your sketches to create a clean vector look, like I did here
19:01See how clean the design looks now compared to the sketch? And you can try different seeds to see what you can get
19:08Let's move to the next subject, which many of you might wonder about, how it works with real people
19:12I will use this woman image to do some tests
19:17Let's start with something simple, like replacing the background with a corporate office
19:21It did a good job
19:21It kept the woman and replaced the background
19:26Now, let's say I want a simple dark background
19:28And again, it seems to work fine
19:32Let's change the lighting since my image seems a little too dark
19:34Okay, I did not expect this to come out so good
19:39The lighting that brightens the face is actually really good
19:43You can also change the clothes color and the material if you want, or we can change the blouse completely
19:47Changing one thing at a time helps to keep the face consistent
19:51We can also play with emotion, but depending on the prompt or the image, it can alter the face a little
19:58Still, it is worth exploring
20:01Sometimes, I like to change the hairstyle just to see how it looks with different styles
20:07Of course, we can change the hair color, too, since women dye their hair in all kinds of colors
20:11So, it can be useful to preview different options
20:16You can also retouch the skin and play with makeup like I did here
20:20What do you think? It seems it also changed the lighting a little
20:24Let's see if we add a strong eyeliner, that dark contour around the eyes
20:28So, you can try all kinds of makeup, including more fantasy style makeup if you want
20:34And of course, you can add accessories, like glasses or jewelry
20:37You can also change the pose, but it depends on the pose and how far the subject is from the camera
20:45The further away it is, the more mistakes you will see
20:49And the more changes you will see in the face
20:51And of course, the problem with hands
20:54Sometimes, it makes huge hands for some reason
20:56You can try different seeds, but some hands will still look ugly
21:01The Queen Edit model can do better hands, like I said, but sometimes it reduces the realism
21:05You can change the pose and the environment, but don't expect miracles
21:11Like I said, changing one thing and keeping the pose gave me the best results
21:15But since this is a fast model, you can play around and do a lot of generations until you get one that works
21:22Let's go to workflows again, and this time I want to show you an in-painting workflow
21:29You can upload an image here, but I will just search for this woman again
21:33Now, you will notice this in-painting workflow is a little different
21:35It has some extra nodes
21:39It has an in-painting crop node
21:39It also has in-painting conditioning and a stitch node that stitches everything back together
21:47I will not go into too much detail, since this episode is already too long, but let me show you how it works
21:54We right click on the loaded image and we have an option called open in mask editor
21:59This will open the mask editor
22:02You have a mask brush, an eraser, and other tools
22:06Make sure you select the mask option, then for opacity, make sure it is set to one, so maximum
22:11Now we can paint the mask, but let's make the brush a little larger
22:17That circle is larger now, so that is the size of our brush
22:21You don't have to be super precise here
22:23In fact, it is better to make the selection a little larger than the exact area you want to in-paint
22:27I want to add a necklace in this area, so this should be enough selection for where I want the necklace to be
22:35Now I click the save button
22:38And we can see the mask here
22:40It is basically like a hole in the image
22:43Behind that hole will be our generated content, and at the end, we will see the necklace there
22:49For the prompt, I asked to add a pearl necklace
22:53Now when I run it, the loaded image with the mask will go into the in-painting crop node
22:58You can see in this preview what it does
23:01It creates a square image with the size I selected here
23:05I also want a little context, so the model understands the image better
23:07So, the mask area is extended a bit
23:09This way it sees more of the woman and understands where to place the necklace
23:16The result is that the image stays identical
23:18It is not a new image generation
23:20It is the same image except for the neck area we masked where it generates the necklace
23:27So, this is a powerful workflow that lets you keep the image and only edit a small portion of it
23:31The cropped image with the mask goes into the K sampler
23:37And before it is saved, it is stitched back using this node onto the original image
23:43Let me try to explain it a bit better
23:45We used a brush to paint a mask in the neck area
23:48When we press save, that image is saved inside the input folder where it creates a clip space folder
23:54Inside that folder, you will find an image like this
23:56I added the transparency grid so you can see that it is basically an image with a hole in it
24:03Then the crop node takes that area plus a bit of extra space for context and sends that cropped image to the K sampler where a new image is generated
24:13So, basically, we take a selection from the original image and run it through a normal edit workflow
24:17We prompt something like add a necklace and it generates it
24:21At this point, we have two things
24:24We have a copy of the original image with a hole in it and we also have a new larger generated image that contains the necklace
24:33The stitch node then takes that generated image, resizes it back to the original small size, and places it behind the image with the hole so it fits perfectly in that area
24:44That is why the final image looks identical to the original except for the masked part where the necklace appears
24:51At least this is how I understand what is happening
24:54It is hard to know exactly how everything works behind the scenes, but this should give you a clear idea of what is going on
25:01Let's try this on a different image, like this bunny sitting
25:03Right click on the image and open it in the mask editor
25:07Make sure the opacity is set to one
25:10Now, I want to add a t-shirt on this bunny, so I paint an area a bit larger, something like this, then press the save button
25:18Now, we have the mask
25:18Let's add a prompt, like the bunny wears a pink t-shirt
25:23We get the crop for that area
25:26If we look at the original image, we can see that the entire image is smaller than the actual selection
25:32That is because we want better quality when we generate at a size the model works best with, and then it is resized back to the smaller size when everything is stitched together
25:41Look at this result
25:41It looks really good
25:43If some parts are cut by the mask, you can always open the mask editor again and adjust the mask
25:50Let's try with a different image, like this dog
25:52Open it in the mask editor, and this time I will mask the top area, since I want the dog to wear a hat
25:57I adjust the prompt to add a black hat on the dog's head
26:03The result looks great, so in-painting works quite nicely with this model
26:07Let's go to workflows again, and this time open the last workflow, the one that can edit two images
26:14If we look at this workflow, you can see we have a reference latent for the first image, and we also have a second image that is scaled down and goes into another set of reference latent nodes
26:24You can do this up to four images used as reference
26:28Here I have this photo of the dog and an image of my logo
26:30I want the same dog, but with a collar on its neck that has my logo on it
26:35Let's run the workflow
26:38For this one, I did not add an image comparer, since we have two image inputs and only one output
26:44The result is the dog with the logo, just like I asked
26:46When it comes to multiple image editing, sometimes it works well and sometimes it fails
26:51So, it is not as reliable as single image edits
26:56If we look at the one image edit workflow, we saw that the get image size node was connected to the empty flux to latent node
27:03But, when you have two images, I did not want to depend on one image since they might have different ratios and sizes
27:12So, I left an empty flux to latent and decided the ratio manually
27:18That is what I did in this two image edit workflow
27:20Maybe you want a landscape ratio
27:22You just set the size here, generate again, and you get an image in that ratio
27:28This is quite useful in many situations when you need an exact size, and your input images have different ratios
27:32And it works with people as well
27:37Thank you for watching until the end
27:41I hope you learned something new today
27:45Press that like button and leave a comment to help this channel grow
27:48>> [music] >> Thank you, legends, and everyone who subscribed to the membership
27:55I wish you a great day, and I will see you on Discord.