Transcript 0:00 All right, welcome back to Denoised. Uh, so this episode we're gonna kinda take a step back, broader view. We're gonna look at concepts of how AI image generation works from a high level- Mm-hmm... 0:10 and then look at that a little bit more detailed inside ComfyUI, talk about ComfyUI a bit, and look at what a typical ComfyUI workflow looks like. Yeah. 0:17 And also how you can use that in the future, and as AI tools get more and more advanced, where ComfyUI still comes in handy, uh, for different workflow- For sure... and use cases. Yeah. 0:27 At this time, I think we can both agree that ComfyUI is the universal tool across different AI companies, different creators. Yeah. 0:35 Once you sort of get to a certain level and you're like, "I need to either have more control or automate things"- Yeah... ComfyUI usually comes to the conversation. 0:42 But, I mean, we've had this conversation before of, um, you know, with tools like Runway References or- Yeah... Flux Context, how useful are LoRAs and stuff like that. We're getting ahead of ourselves. 0:52 Let's start high level. We'll talk about that a little bit later in the episode. [laughs] Yeah. This is gonna be a fun one. Yeah. 0:55 And please, uh, engage us with questions and comments, and we're gonna get to them as well. Yeah. [upbeat music] All right. So let's talk high level first, AI image generation. AI image generation. How does this work? 1:08 What is happening? [laughs] It's actually a miracle that even works. Okay. If y- if I go under the hood and sort of explain how it actually works. 1:16 So one thing that all image generation, video generation relies on is a neural network. Mm-hmm. And a neural network is what separates computer vision, machine learning from AI. 1:28 So when people say, "Well, we've been using AI for 20-plus years," uh, not exactly neural networks. That is a new thing, especially neural networks at scale. 1:38 When we talk about a image generation model, like the one Midjourney has or Stable Diffusion, you're talking about billions of nodes inside of a neural network. And a neural network node is nothing complicated. 1:51 It's actually a very simple mathematical function. It's, uh, x times y plus b, so i- it's essentially linear algebra. Uh, so you have a slope, which is- Mm-hmm... 2:04 the, the x, and then you have a bias on the slope, which is a plus b. 2:08 The thing that makes it incredibly, uh, useful is when you do this millions and millions and millions of times, you have millions of nodes, and then you go to billions of nodes, then it starts to develop a sor- source of understanding of big concepts. 2:23 And not just concepts of what an image should look like, but associating that with words, and that is the magic here. 2:31 Uh, like for example, if you have a notion of a beach, regardless of language, you could say it in Mandarin, in Tagalog, in American English. Mm-hmm. 2:40 Uh, but a beach, that concept is associated in that neural network to that of Malibu, that of, you know, Cannes Film Festival. 2:50 Like, beaches everywhere in the world are associated with the word beach and the notion of the word beach. So how is this all built? It's actually built from images, and the way we train them, I have... 3:04 A, a, an actual tactile demo. Yes. Okay. So this is noise, and it's hard to believe that a neural network can turn this into an image that we can recognize. 3:16 So it goes from this to this, or it can go in the reverse order. It can actually take this, go back into noise, and it happens by training. So the way it does this is it adds steps of noise. Mm-hmm. 3:30 So it'll take an input image, and then it'll slap on some noise, and you can still kinda see the image there, but this is what it's using for training to understand the denoising process, and it's the training of the denoiser that's the magic. 3:46 Then- So it's taking a nice clean image, adding the noise, and sort of memorizing each step of like- Yeah... this level of noise is for this image, and it's doing this billions of times. 3:56 Yeah, and the neural network is able to train itself on what is noise and what is image. Mm-hmm. Which is the c- crucial part. 4:03 And as the noise gets thicker and thicker, like here, you can see the job gets harder and harder. Like, you could barely make out the text and our faces there. Yeah. 4:13 But it is using, uh, recognition of features in there, and it is doing it in a mathematical space called latent space. Latent space. All right. Yeah. 4:23 Which is quite different from how we traditionally compute, uh, stuff like edge detection or video compression. That stuff happens in the frequency domain, uh, typically using convolutions and cosines and sine waves. 4:40 Um, this is happening in a space that is multidimensional. [laughs] It's happening in the multiverse. Exactly. So, like each vector can have 20 different commas on it. Mm-hmm. Right? 4:54 Because it's 20 different, uh, axes on, in this multidimension. 4:59 And, uh, you know, i- if you imagine, like the way I imagine latent space is you have, like, this gladiator arena, this giant space, and then in there, there's tiny little neighborhoods. 5:11 Like, you have your Santa Monica, you have your Echo Park- [laughs]... you have your Valley, and each neighborhood represents an idea of a thing that we associate with the real world. 5:23 Like, Echo Park is just all about, you know, uh, lamps and lights- Uh-huh... and table lamps and floor lamps and lights. Santa Monica is all about the beach and the sand and the beach umbrella and those things. 5:37 So, like, they're clustered together. 5:39 So when a text prompt comes in and says, you know, "I wanna generate a light that's sitting on the sand at a beach," then it's pulling, the latent space is pulling from Echo Park, it's pulling from Santa Monica, and guiding that noise into an image. 5:55 Based on the training data and based on when you trained it with the image, you a- also were, had proper labeling and id- identification to know thatCorrect... this is two guys on a podcast image- Yeah... 6:06 or this is a picture of a beach. And so it's trained on that way, so then when you wanna generate something- Yeah... it has- A neural network is only as good as the training data. Mm-hmm. 6:16 And, uh, like you nailed it on the head. The captioning process and the data grooming process is as important- Mm-hmm... as the training process. So you're, you're talking about millions, if not billions, of images. 6:27 That's why scale AI is worth billions of dollars. Right. And we're only getting started. Uh, so if you follow the big AI companies, um, you'll see an exponential growth in scale. 6:37 So for example, ChatGPT-4 to ChatGPT-3 I think had, like, 100x scale in the size and complexity of the neural network, and they are looking to one-up that one again and again. Mm-hmm. 6:49 So we're gonna get to a point where the notion of things, uh, not only exists, but the granularity in which they exist is even finer and finer. 6:58 So then I could determine a beach in Santa Monica versus a beach in Tahiti versus a beach in south of France. Mm-hmm. And those things will have individual, very granular changes to them. Okay. 7:09 So to summarize, training, we take a high quality image with good, uh, data captioning, and then it gets noisied up step by step. 7:18 The models are trained on, like, this level of noise, at this step, kind of produces this image. So then later on when we're like, "Okay, I wanna generate an image," we start with the very noisy- You just feed it-... 7:27 base image... random noise. You feed it random noise. Right. And that's where the seed... Also, the seed is a thing that comes in. Yeah. So, like, you need to start with a base noise image. Yeah. Empty latent image. 7:36 Yeah. Called in, in- Nice... in Comfy UI. I'm checking 'cause I know Comfy UI, I gotta add, add an empty latent image. Yeah. Just the... Which looks like one of the static images that- Yeah... you just showed. Yeah. 7:46 And then it- So you give this to the ksampler in Comfy UI. Mm-hmm. And then based on your number of steps, it starts denoising that image to create based on whatever your text prompt was. Correct. Correct. 7:59 High level explanation. Yeah. And the training is so computationally expensive, Joey. You're talking about millions of images, but it doesn't go through the neural network once. 8:09 It'll go through it thousands [laughs] of times. And each time it'll, like, put different weights on each neural network node differently. Mm-hmm. And then there is a loss function. 8:19 So then when it generates something and we determine it as error, or the, another machine determines it error, it goes back in and tries to correct itself and gets better in the next one and the next one. Yeah. 8:30 A lot of training. [laughs] All right. So let's look at this in practice in Comfy UI. And Comfy UI's kinda nice too, because you sort of... 8:36 A- I mean, it can get very high level and technical, but this also gives you more control. Um, but this also is a good way to visualize what's happening under the hood with a lot of AI models- Yeah... 8:45 that you are just kinda going on the website and typing in. This is, in a lot of cases, happening behind the scenes. Yeah. Comfy UI is a free platform f- uh, available on Windows, Mac, and I think- Mm-hmm... 8:55 Linux as well. Uh, I don't... [laughs] We were talking about this. We don't know how they make their money because this stuff is amazing. [laughs] Yeah, we still have not quite figured out yet. It is for free. 9:02 They've also made it a lot more user-friendly, 'cause originally you sort of either had to install it on Terminal- Mm-hmm... or from, like, GitHub or... And, um, now there is an installer. Yeah. 9:10 Uh, there's a Mac installer, there's a Windows installer. Um, I know we have a video about how to do it, but it's literally just download the, the installer package and it sets up any Python stuff- Mm-hmm... 9:18 you might need. So initially when I tried to get into this, I'm not the most technical Terminal person, so, um, it was a little bit scary and complicated- Yeah... but now it's a lot easier to use. 9:27 You and I, uh, I think we're both visual learners. Uh, for me, node-based stuff just is so intuitive. 9:32 And, uh, our viewers out there, if you've used Nuke, if you've used Resolve or Fusion, if you've used Houdini- Mm-hmm... even Unreal Engine Blueprints, you've already got it down. 9:43 You know node-based workflows, so you should have no problem sort of- Yeah, or even any of basic flowchart- Yeah... builder in, in Whimsical or Miro or something that's- Yeah... same idea. Exactly. 9:52 So I loaded up one of their default, uh, text-to-image, uh, templates. They got a lot, a lot of good templates. 9:56 Uh, but this is a good one 'cause it kinda shows all the basic building blocks that happen for taking a text prompt and turning it into an image. First up in our workflow, we got the load checkpoint. Yeah. 10:05 So what are the checkpoints? Yeah. Checkpoint is the model that you're loading. Okay. So if you're generating an image, uh, you could pick, uh, Flux, Dev, Flux Schnell, Stable Diffusion. 10:16 Uh, there's a ton of models to pick from. Yeah, the one that default here is the Stable Diffusion XL. Yep. Which I know a lot of people still like- Yeah, it's, it's-... to use... 10:23 the most popular one- It's also open source... to date. It's open source. You can run it locally. Yeah. Yeah. 10:28 Anyway, I should say too, I mean, we'll talk about APIs in a second, but, uh, the other advantage n- of Comfy that people like a lot is you can download the models and run it on your local machine. So- Yeah... 10:38 if you want to experiment, uh, or generate stuff, you are generating it at, on your computer. There's no credits- Yeah... 10:43 there's no, you know, paying for each generation, so it's good for messing around and experimenting. Totally. Yeah. And the other- On the, on your hardware... just one note, you do need an NVIDIA GPU here. 10:53 You do need that, yes. Yeah. Uh- Because this, these things run on CUDA. Yeah. Yeah. [laughs] Uh, there are some, I mean, I've run it on my Mac. 11:00 Yeah, it can- Some stuff is- It'll run slower [laughs] I've almost burnt my legs running it [laughs] You're like, "Ugh"... with my laptop on my lap and spinning it. 11:09 But yeah, it is possible, but it is more designed to run on NVIDIA cards. Yeah. And I'll just say, uh, if you notice the load checkpoint stuff, it's loading a safetensor file. So what that is- Yeah, what is that?... 11:20 is, is a prepackaged, precompiled version of the model that is uneditable, and that's how the load checkpoint node likes it. 11:28 So there are two types of ways you can download a model, a diffuser file and a safetensor f- file. Okay. Uh, diffusers are more, they're more open to being modified. Okay. 11:39 Uh, you can also load those here as well, but the safetensor's the one that's a single file.Safe sensor, single file- Yeah... not modified. You can modify it in your chain- Yeah... 11:48 that you're building with and- Correct... comfy, but that model itself is- Locked down... everyone's got the same model- Yeah... if you download it. What is... 11:54 'Cause I've seen this on different models too, like FP8, FP16. Yeah. That's a floating point 8-bit or floating point 16-bit. Mm-hmm. It's the precision of the model itself. 12:04 So all the parameters either holding it in a 16-bit float point, which is just a fancy way of saying a really long decimal number. Okay. Or 8-bit would be half the length of the decimal number. 12:15 So I think 8-bit is like.001 up to that accuracy. Would you pick one based on your hardware? 'Cause like, wouldn't a FP16- For sure... require more beefier- Yeah... cards? 12:25 I would say go with FP8 for ideation and stuff like that, and FP16 for the highest quality that you can get. Okay. All right. 12:33 So then we're going out of our checkpoint, our model, and then we've got two clips, C-L-I-P, uh, text and codes, one for our positive prompt and one for negative prompting. Yeah. Okay. So we got the clips. 12:43 We got the two clips 'cause also this model supports, uh, positive prompting and negative prompting, saying what you don't want, but not every model does support that, but in this case it does. Correct. 12:52 And this is not the same clip that you and I think clipping, like clipping an image. Not clippy? [laughs] Not clippy. This is a completely different clip. I think it stands for contrastive language image pre-training. 13:03 It's exactly what I just talked about. Mm-hmm. It's, it's, it's the Silver Lake and the Santa Monica and the latent space. 13:08 So like, not just words, but notions of objects and places and experiences can be stored in the latent space that are associated with words. Mm-hmm. Right? 13:20 So the actual word, actual language is not as relevant as the fact that you're trying to pull an idea from the latent space. 13:29 And so this is actually gonna take your simple text prompt here, and it's gonna encode it into a vector that goes into the latent space, and then the, uh, solve will then use that vector to generate the image. Okay. 13:44 And then I guess at high level, this is taking the text prompt that you wrote out and turning that text into something that the- Yeah... that it can understand and turn into a visual image. 13:54 Yeah, into latent vec- uh, vectors. Latent. Yeah. Okay. And then these are all getting plugged into the KSampler, and the KSampler's sort of been described as sort of the heart of- Absolutely... uh, image generation. 14:05 Yeah. 14:05 Um, and so we've got both the model, uh, our checkpoint loading into the KSampler, um, our positive and negative, uh, prompts loading into the KSampler, and then a latent image, which is basically just a blank, empty image- Yep... 14:17 at the resolution- At the resolution... that we're gonna generate it. Yeah. Which here is 512 by 512, which is pretty small. 14:21 This one's really important because, uh, a lot of models have specific latent image requirements. So I, I know for- Based on like what they were trained on or what they understand. Exactly. Yeah. 14:30 And what they are inherently, uh, doing under the hood. Um, so for example, SD 3.5, uh, uh, Stable Diffusion's latest is a 1024 by 1024 model. 14:41 So if you give it a weird latent image size, it's gonna struggle a little bit. Mm-hmm. So give it its native resolution. Of course. 14:46 So don't do what I first tried to do, where I was like, "I want a 19 by 20 by 1080 image." [laughs] Yeah, that's, so- 'Cause it's not trained on that... there is remedies for that. You can add upscaler models- Uh-huh... 14:55 at the end to get to that. Right. But you'd add that afterwards. You wouldn't change your- Correct... initial latent image- Yeah... because it's not really trained on- Exactly... to do images of that size. Yeah. 15:03 Okay, so in our KSampler, we do have the seed. And so we talked about this before. This is a random number generated, but this is how it generates the very first base layer of noise. Yeah. 15:13 Think of it as a unique identifier for the noise. Mm-hmm. Uh, theoretically, theoretically, if you have the same seed- Mm-hmm... and the same prompt, and you push it through again, you should get the same image. Right. 15:24 Theoretically. I, I haven't, yeah. If every, every other settings are the same. Right. Exactly. You should. 15:28 Um, I mean, I've seen people tr- keep track of seeds too, if they find a seed works out well for some scene, and they might- Mm-hmm... try to use the same seed for other shots in the scene. Yeah. 15:36 Um, but theoretically, possibly helps get more consistent shots. It should. Yeah. It should. I mean, it should get you 80% more consistency than just random seed, random seed, random seed. Mm-hmm. 15:46 And then, uh, we, we got a bunch of other settings. Uh, I will say, so steps. Can you talk about steps? Yeah. So that is the number of steps it is de-noising at. Mm-hmm. 15:56 So imagine that thick fog of noise, uh, broken up into 20 different layers, and then each layer is being de-noised 20 times. Mm-hmm. Right? 16:05 And in theory, the more steps you have, the better image you should get because it's doing- It's-... more steps... diminishing returns- Oh, you're right... like up, up to a point. 16:13 I think I've seen like 20 to 30 be the normal here, and then anything beyond that is just gonna be computationally expensive. Like you're just wasting time. Like if you do 50, you're not gonna get a better image. 16:22 You're just kinda- You're wasting electricity. [laughs] You're melting your card more. Yeah. Yeah, so CFG is classifier free guidance. Okay. 16:29 And, uh, the higher this number is, the more you're giving the AI model leeway to generate what it wants and almost pull away from the text prompt, from the clip. 16:39 So if you have a high CFG value, then let the model, uh, be more creative, right? Mm-hmm. Come up with the thing that it wants to come up with. 16:46 But if you have a low CFG, then, um, it's gonna really stick to what you prompted. Okay. The sampler name, this is the mathematical algorithm that's used under the hood. Euler is the most common. 16:58 Uh, it's the most computationally efficient. I've seen Ancestral Euler, I think that's in there. Yeah, Ancestral, I've seen that too. Yeah. So I see some of that, but, uh, generally, I don't see this being changed. Yeah. 17:08 I mean, I see like 20 different options here. Do, like- If you're an AI scientist, you're using all of the- [laughs] Okay. You're asking for more, but Joey and Adi is using Euler. Okay. 17:17 This is one where it's pretty much... Yeah, you don't need to mess with that too much. Yeah. Scheduler. Scheduler, I actually am not familiar with. Okay. Uh, I usually leave scheduling denoise. 17:26 The nice thing is if you do hover, they do have pretty good, uh, tool, uh, tips- Captions. Yeah... tips pop up. The scheduler controls how noise is gradually removed to form the image. Yeah. 17:34 Probably one to just, you know, unless you know what you're doing, just leave it alone. Yeah. 17:37 And I just wanna say that this entire block, the KSampler block, the mathema- the mathematical, uh, computation is happening in the latent space. Mm-hmm. So this is not happening in XYZ coordinates. 17:48 This is not a CG render. This is not anything that you and I can kinda comprehend in our brain.But it is happening in a high multidimensional space that only exists inside of a computer. Like [laughs] Like not- Yeah. 18:02 [laughs] We don't break the computer open [laughs] like in Zoolander. The files are in the computer. [laughs] But the, the re- so i- i- why do we use latent space? The short answer is it's a compression. Mm-hmm. So if... 18:15 Imagine storing a billion images inside of a model and then shipping that model in a safe tensor file, you would be in the petabytes, right? Even with image compression. 18:27 So latent space allows you to preserve all the notions, all the ideas of that image, and each image come do- comes down to, like, kilobytes or bytes because it's no longer in pixels. 18:39 It's just in this multidimensional vector that it exists. Mm-hmm. A vector is gonna be way lighter than a pixeled rendered- Right, right... raster image, right? 18:49 So that's why we bother with latent space, is that you can, you can get to scale, and then you can still ship the models over the internet. 18:56 You know, a 20 gigabyte model is honestly not a big deal versus, like, a petabyte. Okay. [laughs] Yeah, yeah. Okay. And so then we got... And then we have denoise, which that- Which is the name of our show. 19:08 [laughs] I know. They, they are promoting our podcast- [laughs]... so it's very nice of Comfy. Thanks. Thanks, Comfy. [laughs] No, this would be, uh, come into play more if you're doing, like, an image-to-image. 19:15 Yeah, I believe so. Yeah. Just generally here, you know, the, the steps take care... I, I guess it would be the amount of denoise per step. Uh, well, no, the amount of denoising applied. 19:24 Lower values will maintain the structure of the initial image, allowing for image-to-image sampling. Right. So in this case, 'cause you're starting from nothing, we want... We don't want the noise to stay. 19:32 But if you were starting from an image-to-image workflow, you would want- Yeah... it would control, like, how much of the original image do you want versus how much do you want it to change. Great, great. Yeah. 19:40 W- and we're, we're gonna get into image-to-image in a little bit. Yeah. And then after, and then after KSampler, we've got the VAE Decode. Yes. 19:47 The VAE stands for Variational Auto Encoder and Decoder as well, so this is where you go from the latent space back to pixel space. Okay. Stuff that we understand. 19:57 And so this is taking all of the latent stuff, turning it into an image- Yeah... and then it saves our image. We have a save node, which- Yeah... will save our image. Yeah. Now you're back to, like, a JPEG or whatever. 20:05 Yeah, or PNG. Yeah. And this is the other nice thing about Comfy, is you can set up batches, and it just saves the image to your computer. Mm-hmm. Uh, so you don't have to... 20:14 You know, if you're working on one of the web portals- Yeah... that you're used to, and then you kinda have to, like, flag which stuff you like and then download them individually later. Right. 20:21 Comfy, you run it on a computer, and you just designate a folder, file name, prefix, and everything you generate gets saved. You know what I found out recently too? 20:28 Um, any image you generate on Comfy, if you take that image, I think... Uh, maybe I think it's only PNG files. Mm-hmm. But... And if you drag that image into Comfy, it saves the entire workflow. Oh. 20:40 And so you can pull up... If you have an image or someone sends an image- Yeah... you can pull up the entire workflow that was used to make that image, which is really awesome. Oh, because I know why. 20:50 Uh, so under the hood, uh, this whole node-based thing is really just a text file. Mm-hmm. And it's a JSON file. Yeah. Uh, those in VFX, very familiar with JSON files. 20:59 You can attach the entire JSON file as a metadata to the image. Mm-hmm. And Comfy will read that metadata- Yeah... and recreate the nodes. But yeah, I did not know that it did that with every image. 21:08 So, like, if you are sharing images or something- Yeah... and you wanted to see what the workflow was- Yeah... uh- It's all in there... it's there. So any- Yeah... 21:14 Or if you make the image, and you're like, "What did I use for that thing?" And you didn't save the workflow, you can just- Yeah... drag it in. So I, I just learned that. That's also very cool. 21:20 Also, the other cool thing here is Comfy k- keeps a history of all the input and output images in the local folder that you install it. Mm-hmm. So even if you're not saving images, it's saving it for you. It's sa- yeah. 21:30 Yeah. Yeah. So yeah, it's very good- Yeah... for just, like, uh, pulling back stuff back up again. Yeah. Okay, so now that we've covered basic image generation- Text to image. Yeah. Yeah. Let's cover some other options. 21:39 So the two other one common workflows would be, like, image to image and LORAs. First off, we talked about this before, but LoRA, recap. What is LoRA? Yeah. LoRA is not the name of my girlfriend. 21:49 [laughs] L-O-R-A stands for Lower Ranking Adaptation model. 21:55 So it's essentially, uh, you train a model, a very lightweight model, typically, like, 100 megabytes, and you can attach it to a larger model, which are in the 20, 30 gigabytes, right? 22:07 And what I imagine visually, like, the large model is like the Queen Mary 2 in Long Beach, right? [laughs] It's a giant cruise ship. Okay. 22:15 [laughs] Or, or any of your Carnival cruise ships in Miami, and the LoRA is a tugboat. Mm-hmm. It's, like, a tiny little ship, but it has the power to pull that giant thing to where it needs to go on the dock. Okay. 22:28 And, uh, LORAs are never modifying the actual models. Mm-hmm. Uh, all LORAs are doing is it's attaching itself to the correct, uh, attachment points in the big model to influence it significantly. 22:42 And this could be a style. This could be a face. Yeah. Logo. Characters. Characters. That, that's probably the number one use is, like, I wanna create Joey every time. Yeah. 22:52 You have tons of photos of you, so what you would do is you would train a LoRA model on Joey. Mm-hmm. Call it Joey, and then attach the Joey LoRA to Flux. Mm-hmm. 23:02 The big actual Flux, and then you type, uh, man wearing a suit, and then you tag it with a special tag word, Joey. Whatever I named the Joey. Yeah. Yeah. And then it, it knows that now you're invoking the LoRA. Mm-hmm. 23:18 So it'll generate not just a generic man, but you. Right. Right. Yeah. Yeah. Okay. And you train LoRAs, you just use a what, like, Replit? Is it Rep- not Replit, that's the coding one. 23:26 Replicate is probably the most- Replicate... uh, m- there is, for Flux, you have Flux Gym. For Stable Diffusion, you have Automatic1111 and, uh, Koya. Mm-hmm. Uh, so there's tons of places for you to train LORAs online. 23:40 It's usually pretty easy web interfaces where you just give it the images, and it'll train it- Yeah... and give you the LoRA file. It's not gonna be free. I think it's, there's a cost- No, I think-... 23:47 but it's dirt cheap... it's, yeah. It's, like, a dollar. I think I trained one for, yeah, a few dollars. Yeah. Like, under $5, you could train a LoRA. 23:52 And you can train a LoRA on ComfyUI as well, but I don't recommend it because the internet tools are so much, uh- Mm-hmm... just, just easier. Yeah. Yeah. All right, so, uh, we'll cover the LoRA one first. 24:02 This is just a general LoRA template inside c- uh, Comfy. And so a lot of the basics are the same, so we have our Load Checkpoint, Load Our Model, but now before we go into our KSampler, uh, we have Load LoRA. Correct. 24:15 Yeah, so you're loading the checkpoint, which is the LoRA model, not the main model. So you're gonna have two checkpoints here. The Load Checkpoint is our main model. Main model. Okay, correct. 24:24 So then you're going into the Load LoRA, which is gonna take the main model, attach the LoRA to it, and then send that to the KSampler. Mm-hmm. Which is what's happening here in the Load LoRA node. 24:36 So you see, um, under, on the Load Checkpoint, there's a clip wide, uh, yellow line there. So this model-Also has the clip loaded in it, but a lot of times it could be separate from the model. 24:50 So you can have a load checkpoint and a load clip, and you might have to load both. Oh, you might have to load a clip? Yeah. 24:57 So like, as in, what, like how would that be different than our clip here, which is like just our text prompt that we want? So, so a lot of times, uh, the models generally come with a clip loaded on top. 25:09 Uh, so the safetensor file has this in there, and you don't even notice it. But for more advanced workflows, you can actually put in a much higher quality clip encoding mechanism. Okay. 25:20 And so, uh, the triple clip loader is what I see a lot of times, uh, professionals use, is it'll have a large, uh, it'll have a Clip L, Clip G, and a TPXXL clip model, and those three clip models work together to give you three different vectors for that text prompt. 25:38 So what is this... So what is this doing exactly, and how is this different than our clip text encode here, which is just our prompt? It's giving you the vector in three different ways. 25:48 So the prompt is giving you three different results here, and it's just giving the, uh, the KSampler a more, a more variable environment to build off of. So it's just giving more meat for the generation. Okay. 26:02 But you would still use this in addition to your text prompt- Correct... for what you want to generate? Yeah. Okay. So right now if you see the load checkpoint, that yellow line, the clip here. Uh-huh. 26:10 So you're getting the clip from the safetensor file there, and that's passing from the LoRA into the text into the KSampler. 26:17 But if you want it to be a little bit more advanced and give the generation just more to work with, you can get a triple clip loader and then attach that yellow line- Okay... yep, right, right there. 26:29 Oh, I put it- Yeah... I put it before the LoRA. Before the LoRA. Okay. Yeah. And then you would, you would go about it that way. Okay. 26:35 Uh, you don't actually need that, 'cause you're not gonna use the clip from the checkpoint. Oh, I see. Okay. Yep. Got it. Okay. Interesting. Good tip. And where would you get these clips? 26:42 Like, is it something you have to download? Is it just on the- Great question. 26:45 [laughs] So in general, I would say 99% of the stuff that you actually need to download from ComfyUI exists on a repository called Hugging Face. Okay. 26:55 So Hugging Face is like the national database [laughs] International... international database, if you will, of all of the models. You could get safetensors there, diffusion models there. And that's not the only place. 27:07 There's a couple other places as well. Um, if you go to Civit.ai- Oh, yeah, they have stuff too. So Civit AI specializes in LoRAs, so if you're looking for a specific style. Uh-huh. 27:17 Like let's say you want an anime style transfer, or you want a character that's con- you know, consistently a certain ethnicity- Mm-hmm... you go to Civit AI and grab that LoRA. 27:28 But that LoRA is gonna be specific to an image model, right? You can't just use a Flux LoRA on a stable diffusion model. Right. 27:34 And so here, actually, I pulled up 'cause I was curious, so it's like Comfy, uh, Comfy does have a good model manager built in as well. Yeah. 27:40 And, uh, I searched for clip models, and so here, sta- uh, stable cascade from Stability AI- Yeah... a dedicated clip model. So I assume that would go with- Yeah. So these are probably-... stable diffusion models... 27:48 referencing back to, uh, a, a Hugging Face repository, but the nice thing about Comfy here is it'll download directly into your Comfy local folder. So you don't have to like go to the internet- Yeah... 27:58 and find the thing. Right. Yeah. Text encoder for Flux FP16, text encoder for Flux FP8. Yep. So, yeah, okay. To what you're saying. Yeah. 28:05 And then the other neat thing here is if you're starting with Comfy, you've just downloaded a workflow, if you go to the manager, uh, there is a install missing nodes button. Yeah. 28:14 Which, yeah, which is cool- Yeah, yeah... because like a lot of times there are nodes that are just doing mathematical functions, right? Mm-hmm. It's like, you know, cropping an image, clipping an image- Yeah... 28:23 whatever. And for that, it- it'll just find it on the Comfy server and then put it up here. Yeah. Okay. And then as far as everything else on this workflow, it's exactly the same as what we just covered. 28:34 Uh, it goes into KSampler, it goes into the VAE decode, and then it saves your image. Yeah. So, yeah. We just covered all of this. 28:39 Now, the fact that you have the LoRA in here is gonna significantly impact your image generation. And in your text prompt, you're gonna have to add the tag word for your LoRA. Mm-hmm. 28:50 So like if we added Joey, it's looking... If the Joey is not in there, it's not gonna invoke the LoRA. All right. Next code- Okay. And then, uh-... image to image... real quick, image to image. 28:58 So now let's say you wanna have an existing image and you wanna modify that image. Yeah. 29:02 So this is where I think a lot of professionals will end up, is, um, you'll find that text to i- text to image is not gonna get you where you need to go most of the time. 29:12 In that instance, you already have a good idea of the framing, the blocking- Mm-hmm... where you want the character, where you want the background to be, what objects. You can do something like sketch it up- Yeah... 29:23 or you can go into Unreal and you can block it- Mm-hmm... with a camera and take that render. Bring that in as an, as an input to the generation. 29:31 So here we have a image to image, and then- And our workflow's pretty much the same, except we have this blue box- Yeah... which is to load our image. So we got an, a load image node. Correct. 29:39 And see, all this is happening is it's taking the image and it's encoding into latent space with the- Mm-hmm... VA, variational autoencoder, and then that is gonna go ahead and influence the KSampler. 29:49 So instead of giving it a static empty image, you're giving it an actual image. Mm-hmm. 29:54 And also we can see here that denoise setting that we talked about before, it was set at one when we were doing text to image 'cause we didn't want any noise, but now it's set to.87. Yeah. 30:01 It- Which would- Which would-... modify it a lot, but keep some of the basics of the image. Yeah. And all, all that happens under the hood is, like, that image actually ends up, uh, having structure. 30:11 So, like, if you picture, uh, a portrait of a man, you know, you have the shoulders and the head, there's, like, structure to that image, and it's gonna use it in the, in the guidance. Mm-hmm. 30:21 I also noticed here too, the, the sampler for this is not, uh, Euler- Euler. Yeah... it is DPM PP2M. It's that. 30:32 [laughs] I would say if you load one of the, uh, default Comfy workflows and settings are changed-Leave it as is and, uh- Yeah... to start with, and then maybe modify it, you know, to see what they do. 30:41 But, um, they usually set these for whatever the optimal parameters are for the workflow that you're loading. Yeah. A-and full disclosure to our viewers, like, I am not the Comfy UI expert here. 30:50 I'm just scratching the surface. Yeah. And I think you can say the same. [chuckles] Uh, yeah, I'm, I'm, I'm, I'm just catching up. The A-AI researchers of the world are the ones using this to its full potential. 31:00 Yeah, those are really, really into the mathematics- Yeah... uh, behind this and- Yeah... stuff that I'm not quite sure about yet. But we're, we're bringing you the knowledge that we know. Yeah. Everything. Yeah. 31:06 This is a good lead-in, also, point too, because one of the interesting uses that I've found for Comfy, uh, lately is this is everything we're talking about. This is all running locally, and so you also, like, it... 31:15 This is kind of either gonna kill or not even doable to run. Like, I haven't run any of these as demos because I'm on a MacBook, and it would, um, kind of kill it. 31:23 But even if you did have your own hardware or if you just had a MacBook, what I have found useful is they have API nodes. Nice. And so the API nodes- Yeah... 31:29 at first I thought, "Oh, that seems like a little bit overkill," but they're actually really cool. And so they have a whole variety of, uh, I'll show you in the templates. 31:36 So it'll connect to Runway, it'll connect to Google. It'll connect to any of the- Yeah... main cloud tools that have APIs. That's awesome. And so they've got connections to, uh, LLMs, so OpenAI or Gemini. 31:46 They've got connections to image APIs, so- Yeah... 31:48 Flux, which you could run locally, or if you don't have the hardware, you could go connect to their cloud service and use their cloud servers to generate Runway, Stability, OpenAI, uh, Ideogram, and then they have video APIs as well w-with the main, you know, uh, Peak or Runway. 32:02 Yeah. So how does billing- Um, Luma... and pricing work? So the billing's cool. So at first I was like, "Oh, this seems cool," but then you don't even have to, like, sign up for the APIs- Yeah... 32:09 for each, uh, and developer accounts for each tool, but not the case. Um, Comfy has a cool... Basically, just connect your account and you can just buy- Okay... credits. So they're reselling. 32:19 Yeah, and they're not marking it up. They're just charging you whatever- Nice... the face value is of the, uh, nodes. And then the cool thing too is it'll tell you what... 32:28 Like, w-this is a Runway text-to-image node, and, uh, I think because Runway's pricing is variable, it doesn't have a price here. 32:34 But on some of these nodes, if it's like, you know,.08 cents a generation, it'll tell you up here exactly how much it's gonna cost for each generation, so you can- Before you hit the button... 32:43 before you run it, and you- Yeah... don't have to connect any API. You don't have to... You just load this node, and it just takes the money out of your account. So- That's awesome... really handy. 32:50 And then the advantage of using this is you can do... 32:52 You can connect this to your Comfy workflow, but you have the advantages of, uh, everything you generate's automatically saved to your computer, so you don't have to, like, use a web portal and download each image. 33:01 So if you're trying to do a lot of image generation- Yeah... using these models, that helps speed it up a lot. Um, and I've been using a new node too where you can do a batch generation. 33:09 So you can give it a text file of, like, a bunch of different prompts and then have it generate each prompt. That's cool. And so that's kinda handy for- Yeah... 33:18 just getting a bunch of stuff out to kind of like look around and explore and, and brainstorm, uh, rapidly. Yeah. Also, I think, uh, because, like you said, you're on a MacBook- Mm-hmm... 33:25 you know, you're not on an NVIDIA GPU, you can still have the flexibility of building your own stuff but then running it on the cloud. Exactly. I can just use cloud- Yeah... access cloud hardware- Right... 33:34 to, uh, to, to generate stuff. Yep. So that's... Uh, I've been finding this to be pretty handy- That's awesome... uh, and a good u-use case. 33:39 I-I've never actually used API, but I, I'm sure this is, this is the way to go if, like, the project that you're on right now. Yeah, exactly. Yeah. And then we've talked about... 33:46 So I mean, we've talked about, uh, Comfy and, you know, building out these models. 33:51 It's still kind of a ba- Like, if you were to com-compare, you know, running this workflow of a text image, you know, using Stable Diffusion or even using, uh, Flux compared to the e-more accessible tools like we have on Runway, like we have, um, Flux context on the cloud- Yep... 34:07 with references, how useful or how necessary is it still to train a LoRA or build out a complicated workflow on Runway when we have, like, the ChatGPT interface where you can just give it an image of someone and be like, "Put this person in a car," uh- Yeah... 34:23 or Runway references and you can just do the same thing, conversational, single image. You don't have to train a whole LoRA. Yeah. 34:29 How useful is Comfy in these workflows with the advancement of the other tools that we're seeing? Yeah, great question. I, I think it all comes down to your use case and, uh, what you're trying to do. 34:39 Every AI creator is gonna end up doing a hybrid approach where they're gonna do some of the stuff on Comfy and some of the stuff on the commercially available tools like Runway or Luma. 34:50 Uh, and then they're gonna combine the results in their own unique ways. For me, I find that LoRAs that you build, you're on your own, you're... 34:57 You have really specific control over the captions, over the training set, and so you directly influence the quality of that LoRA. And then, uh, you're all... 35:08 When you're doing image-to-image workflow, you're using depth map, Canny, edge detection, all those things, so you have direct influence and control over. 35:17 The ChatGPT stuff, it's good enough for impressing somebody or doing a social media post. But, uh, when you're getting paid, when you're a commercial creator, right, some brand is paying you to make something, 35:33 you want the highest level of control and consistency. You feel like, you feel like you are obligated because if this looks more complicated, then we have to use this be- [chuckles] if we're... because it... 35:43 because we got more nodes? No, I, I don't think that. Like, like, I mean, I... No, I, I mean, I feel like- Yeah... like, yeah, sometimes it's like, "Ah, man, it feels too easy on ChatGPT." Yeah. 35:52 Like, this should've been more, this should've been more complicated for- Yeah... like, you know- Okay, I'll put it this way... I'm a, I'm a professional. I'll put it this way. 35:57 But, uh, ChatGPT, I still keeps, like, when I wanna give it, you know, a character reference image and just like, "Hey, may put this person in a car," still does a really good job. Still does a good job. 36:07 I, I would say for 90% of the way it's there, and, uh, sooner or later, the stuff that we're building here is gonna get gobbled up by the big commercial services, right? 36:17 Like, Flux context is now essentially making LoRAs for you. Mm-hmm. Right? And- And now they do have a version- Yeah... that you can download and run locally. Correct. Which- Yeah... 36:26 last time we talked about that, that wasn't available yet, but now it is available. Yeah. 36:29 I would say with the Comfy stuff, if you wanna be absolutely cutting edge and have the most level of control, you're like six months to a year ahead of the commercially available tools. 36:39 So if you're just not getting the result that you want on ChatGPT image gen-Then come back to Comfy- Mm-hmm... and try it here. You can- Or need to do volume or like- Yeah... a lot, a lot of stuff. 36:52 Some of the stuff that was... I had another workflow idea too with the API nodes. Mm-hmm. 36:55 You could get the no- you could have a prompt and then connect it to, sync one prompt, connect it to, like, every image generator node. Yes. 37:02 And instantly spin up and see, like, okay, with this prompt, how am I getting from each tool- Yeah... and test it out. And to be fair, there are services now that do- let you do that. So Weavy is one of them. 37:12 Freepik, we talked about. We did, yeah. Yeah. And then LTX Studio, Flora AI. Flora, we've talked about, yeah. Uh, there, there's like five or six- Flora's a bit node-based. Yeah. Yeah. 37:21 The thing I w- kind of wish Flora was a little bit more like Comfy, 'cause Comfy you could build out your workflow, and then you hit Run- Yeah... and it moves through the entire workflow. 37:29 Flora was a bit more like you kinda had to run each node- Yeah... step by step. Everybody is after the Comfy business. Uh, this is what I mean by that. 37:39 Like, [laughs] first of all, we should build a- They should all make their tools free? I, I [laughs] for, for the Comfy business model. Like, they know that professionals want control and- Yeah... 37:46 consistency and repeatability, and Comfy gives you that. And the node-based stuff could be, like you said, it's just a little bit spaghetti for most people. 37:56 So Invoke, Weavy, LTX, Flora, they're all making Comfy-like features that are s- Mm... perhaps a little bit of a simpler user experience. 38:05 I mean, I feel like for a good example of, like, the top level of what you can do with Comfy and some of the crazy workflows is to look at Nick Muppets, who we've talked about before. Yeah. 38:14 Where he's built crazy, complicated, massive Comfy workflows for- Character consistency... character sheets. Yes. Creating one-shot character sheets. So actually that is a pretty good- Yeah... 38:24 use case of Comfy that no, nothing, uh, no other tool really does right now. Yeah. Stylings in Blender, adding lores to characters. 38:29 Yeah, I think, uh, Mick does a really good job of combining traditional 3D with new AI rendering. Yeah. Yeah. Yeah. So- That's something that is quite difficult to ChatGPT, right? 38:40 Like, yeah, you can upload it an image from Unreal and da, da, da, da, da. Mm. But then Unreal has something called Comfy UE now. So you can take screenshots from Unreal right into the Comfy instance instantly. Oh, okay. 38:53 Yeah. Good to know, 'cause I know Blender's heart have had that workflow for a bit. Yeah, yeah. And I've seen other people connect, like, Cinema 4D and other tools. It's all about speed and- Yeah... 38:59 you know, throughput, right? Like, as an artist, you're gonna be in charge of, like, 100 shots or whatever. Yeah. Like, you can't just go to Runway every time. It's gonna be too cumbersome. And also cost too. Cost. 39:10 'Cause, like, if you have the hardware and you can- Yeah... just spin this up on your local machines, that can save more money versus having to pay- Yeah... for API credits every time you wanna generate. 100%. Yeah. 39:19 All right. I think good place to wrap it up. Links in the video for the in- the Comfy install. We'll put that at the, uh, DenoisePodcast.com. 39:24 Um, but yeah, let us know if you have used Comfy, where you kinda land on Comfy in this... 39:29 The, because this is a, a conversation I keep going back and forth with of, like, how useful is Comfy versus how much better the tools are getting- Yeah... 39:35 and just being like, "I want this," and you tell it what you want it. It does it. Yeah, in six months- So let us know where that lands. Yeah, six months from now, like, this could be completely useless of a video. 39:42 [laughs] Yeah. [laughs] Like, that's how fast this is moving. [laughs] And also, like, let us know if this is the type of content you're looking for. 39:47 We'd love to be able to go another step, a little maybe, little bit more advanced into this, give you even more of our knowledge here. 39:55 Yeah, yeah, especially as we, uh, experiment more and find out more workflows that are useful. All right, thanks everyone, we'll catch you in the next episode.