Transcript for:
Cartoonizing Photos with Comfy Tutorial

welcome to episode 18 of our comfyi tutorial Series today I will show you how I convert photos of people or animals into cute cartoon characters I will present different options for both sdxl and flux even a combination of both so you can choose the option that works best for you uh to ensure you have the latest version go to the manager and click update all then restart um I am using the new interface if you go to settings you can change it to look the same as mine if you search for the menu you can find the option under use new menu to place it on top then if you search for workflow uh you will see the option for workflow position I prefer to have it on top just like I do in Photoshop uh for the badge options uh I set All To None except for the source which I set to hide built-in uh this will show me which custom node a node is part of now we can open workflows just like in any software from the workflow menu and click open I have saved a few workflows here that worked well for me let's start with this sdxl workflow first because I chose to have the workflow on top I can now have multiple workflows open in this tab and easily switch between them U if you close a workflow it will ask if you want to save the changes let me show you what this workflow does I uploaded this portrait of a woman here then I added a short prompt that describes the photo next I can run the workflow and the result is this cartoon version of the woman you can compare it before and after as you can see it's not perfectly identical to the photo since AI tends to create random images rather than exact replicas but it's quite close let me show you another example this time I am uploading this portrait photo of a wizard then I describe the photo very briefly keep it short because I added extra elements that help make it as cartoonish and sdxl doesn't like prompts that are too long if I run the workflow I get this cartoon wizard image you can see that it does a nice job creating cartoon versions from photos and you can run the workflow several times until you find a version you like of course depending on the photo prompt and your preferences you will need to adjust the den value if it's smaller the result will be more similar to the photo and less cartoonish if the Deno value is higher it will look even more cartoonish so always experiment with the Deno until you find the perfect balance I have included some recommended values for denoise as you can see if the the denoise value is too small it doesn't have enough power to change the image but as soon as I start increasing the denoise the cartoon version um becomes more obvious now let me explain this workflow and what you need to make it work I have included a note here with a link to a model that you need to download this model is from civit AI called wildcard XL animation it's an SD XL model trained on cartoon images download it then go to the comfy UI folder look for the models folder then for the checkpoints folder and place your model there as you can see I already downloaded the model once you have the model downloaded it should appear in this list and you can select it after the model is loaded we have the prompt it looks complex but it's quite simple I have a short prompt here that describes the image and under it is a longer prompt that describes the cartoon style I made it this way so it's easier to just input your short description without uh having to worry too much about the cartoon style prompt then I used a text concatenate node to combine those two prompts if I add a show any node you can see how the prompts are combined first the wizard then the cartoon style description so it's first text and then second text I am removing the node since I know how the prompts combined you can collapse the text concatenate node if it takes up too much space then the combined text goes to the clip text and code where you usually put prompts I converted the widget to text so I can add the text for the negative prompt I added some words to prevent it from looking too ugly or too realistic like a photo then we load an image in a normal image to image process we just have a load image and vae encode that goes to K sampler however sdxl prefers to work with images around 1,24 pixels in size to prevent getting images that are too big or too small I use this resize node and calculator to ensure it gets a size that produces the best results this image resize node normally looks like this I put it in resize mode and you usually need to input sizes manually for width and height so what I did was convert the width and height to inputs as you can see it now looks the same as the one for the workflow I connected the width and height from the resolution calculator to the image resize node I added a show any node to preview the actual size you choose your ratio to match the uploaded image for some ratios you might want to adjust the megapixel if it's too big usually uh one works fine if I choose a wide ratio you can see the actual size here as you can see the image will look distorted If the ratio doesn't match so I will leave it at a ratio of one uh now that the image is loaded it uses the calculator to get the right size and the image is resized then the image is encoded and goes to K sampler where all the magic happens to have even more control I also added control net check episode 9 to learn more about that the image goes to a pre-processor so we get it in a format that stable diffusion understands um you can try different pre-processors like cany which captures the Contours and edges from an image or you can use a depth map to get a depth map from the image it all depends on the image you are using and how well the pre-processors can capture details from it I like to use the anyine art pre-processor keep in mind that the first time you use it it will download the model automatically from the internet so it can take some time check the command window if you don't have long path activated in Windows it might not be able to download for you and you'll get an unfinished message because it didn't download the the models you can post a screenshot of the error on Discord and I can tell you how to download it manually if that happens next we use a control net model again check episode 9 if you don't have it already it must be the sdxl compatible model then we have the settings for applying control net um here I changed the value to end percent so the strength of control net ends sooner allowing some space to add that cartoon style on top of the original photo the settings for case Samplers should be the ones recommended for your model and for Deno as you saw play around with values until you get the right balance and that is the entire workflow if you have questions um The Comfy UI channel on Discord is the best place to ask let me reopen the workflow so it's nice and organized let's do some more tests on animals I hope the people doing animal tests don't complain so I uploaded this cat and used just a simple prompt that says a cat when I run the workflow I get this cute cartoon cat as you can see before and after you can run it a few times until you're happy with the results let's try a different subject like this night photo for the prompt something simple like uh a night should work and this is the result I got a nice and clean cartoon version of this KN so far I've used this model but I also tried another cartoon model and you can experiment with your favorite models maybe like anime or other styles this workflow is using another model called real cartoon and you have the link here the models generate images like this so let's give it a test with a photo of a dog in the forest I added a short prompt mention in the most obvious subjects in the scene and the result is this cartoon dog uh let's try something different like this robot um you can see the robot looks more realistic and I want a cartoon version of it the line is nice and clean but the final result isn't very different as I mentioned it depends on the image and the prompt and in this case it's probably because the contour line was so clear that the control net is too strong you could reduce the control net strength but I prefer to play with the Deno value so let's increase that as you can see this version is more cartoonish you can try uh different seeds until you find something you like I can also make it look uh more different by changing the prompt for example I can add some orange eyes to make it cuter and the result is this now let me show you what you can do if the image is not a person or animal in this case it's a red flower so I don't want it to look like a cartoon character I want it to look like a cartoon flower when I test it you will see that on some seeds it tries to add eyes to make it look like a character in that case let's revisit the second prompt where I put the style where it says a cute character with big eyes I will move that part and put an object or item if you want to be more general or you can put a flower if you only want to generate flowers then I will remove all other words related to a character Let's test it again for objects and other things it doesn't need to be identical it just needs to be similar so you have more freedom I use higher values for Deno and it will still look good the higher you go the more obvious the cartoon effect will be so that was for sdxl it works even on lower-end video cards now let's try a flux based workflow this one is a simple one I just Ed uh Laura for flux like in the last episode what's different is that I used the turbo Alpha Laura to speed up the generation and used only eight steps um for Laura I used AC cute 3D cartoon Laura and you have the link here um this is what it creates I split the prompt into two parts so you can have the trigger words in one place and the prompt in another we use a photo that is then scaled down to fit 1,24 pixels but flux can go bigger or smaller in size to get better results Use multiples of 64 like you can literally add 64 to that number and it does the math for you or you can decrease the values the same way then you play around with Den noise again let's test it the result looks like this it's quite similar to the original but I want it to be more cartoonish so I will increase the deno's value let's increase it even more and now it's really cartoonish it lost some pose because we don't have control net I tried with control net but it's too strong for flux and barely leaves any room room for nice animation and it slows down the generation anyway um you can try different lauras for example I have one here called line War illustration um you can search for it on civit AI and it creates these types of illustrations it has this recommended weight for Laura so I will change it in the workflow then if I go to show info I can click a button to get the info from civit Ai and this is the trigger word for it I select it and click on copy then I paste it here and maybe add some extra cartoon words when I test it it looks like this and this one has a different effect compared to the previous lur so I need to find the right balance I will increase the Deno value and now it's more different even if it's not in the exact same pose it still looks like a cartoon version of that person always try different seeds some results might surprise you for the last workflow I tried a combination of sdxl and flux um the first part is is the sdxl on top and below it is the flux workflow here's how I use this first I set the seed to be fixed you will see in a moment why then I use this flux workflow which is just an imageo image flux workflow to increase the details in the sdxl generation I will disable this entire flux Group by using the I icon now when I run it it will only use the sdxl workflow on top just like you saw earlier it takes the photo and makes it cartoonish with the sdxl model uh the result is this cartoon woman which already has some nice details in this case let's see if we can use flux to add extra details or at least a different variation uh since the seat is fixed I can enable flux and test it as you can see it does not generate the sdxl again because it has already generated up to that point and nothing has changed it just continues from where it left off so this was the sdxl result and now let's check the flux result as you can see it can add those tiny details like finer details in the hair and so on now let's turn off flux again and try a different subject like this night this is the result with sdxl I can go back and add a smile and maybe red eyes the result is this it now has that smile and red eyes if I try to get a different version nothing Chang changes because the seed is fixed so what do you do in that case well you go to the seed and change it manually now I have a new generation let's say I'm happy with the result I can go to flux and enable it and now with that version of the night it will run through the flux workflow resulting in this you can increase the number of steps to 30 if it's too blurry see how the the neck area in the sdxl version doesn't have fine details now look at the flux version see how everything is more detailed I don't like that the eyes aren't red enough in the flux version for that I have this extra prompt field to avoid typing the same prompt again I just connected it to the sdxl workflow and use text concatenate so what I type here will be combined with the original prompt the result is this version with red eyes it's quite cool for those who want to support my channel don't forget you can join uh the membership connect your YouTube account with Discord for priority replies to your comments access to private groups and more I also have these other two channels check them out and subscribe to uh those as well they're still new so uh they need your uh help to uh grow for Discord this invite link should always work on Discord anyone has free access to all the workflows in the pixel Roma workflows Channel you can see that each episode has quite a few workflows and sometimes I add more in a few days with updates for that episode uh you can search for the episode in the top right the first Nine episodes have a zero in front and you can jump to that episode that's all for today thank you to the Legends and all the members who subscribed and gave us super thanks as you know any like and comment helps so if you found this video helpful please press that like button have a great day and see you on Discord [Music]