ComfyUI Fundamentals - Building Modular Workflows

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right hello and welcome to another comi tutorial uh today we're going to be covering how to build modular workflows like the one I have here um this is not what we're going to be working on this is an example of what a modular workflow can become like how complex and how much stuff you can have in them and you know it's just kind of an example of what we're kind of aiming for by the end of this you'll have a workflow where you've got all of these little nodes that do little things and stuff like that and you know the reason that I want to show modular workflows to people is because um when a lot of people first start doing um comfyi they start with the default workflow and the default workflow unfortunately is a linear workflow it's not modular it's not designed in a way that makes it easy to um to work with in terms of making Advanced systems it's designed to do one thing and that's to make a single image and so when people learn using this as a basis uh what you get is people who plug everything in directly to individual nodes so you'll have everything plugged in all the way back here at the start of your load checkpoint you'll have everything plugged into the clip thinger so you'll have multiple K samples all plugged back into this one uh you'll have uh weird things where you've got stuff placed over here and things so that everything is accessible in one place for the person working on it and then you get these big Tangles of noodles because it's not laid out in in a way that makes it easy to work with um and because of that um I want to teach people how they can actually lay it out so that it doesn't become a ball of spaghetti it doesn't become a problem and and it allows you to make use of some more advanced things to do with comi that you won't have access to if you use a tangled kind of setup uh it allows you to make use of bypassing it allows you to make use of um you the pipe system for um impact pack or there's another one anyway basically um you if you have a modu workflow uh you can just you have access to a whole lot more power to work with than you do with a normal workflow um and you when it comes to fixing issues with the workflow as well like and and sharing with other people it it's so much easier to do because uh people open it and they don't have a huge amount of trouble figuring out what's doing things and what's doing what and you know where a problem might be because everything becomes located in kind of small sections of your workflow instead of spread out across large sections of the work workflow in kind of like a tree format um instead you have everything divided into small sections as in this one sorry this one and um you know each each one of these boxes contains a specific process a specific task and if we if we teach you how to build each of your systems in this kind of way then you can actually create something really really powerful I might as well zoom in on the we got here um this one this particular module for example it's a really simple one it's one of my older modules it's something I've had around for a while it makes gradients and it chooses a random gradient and then it sends the random gradient on so it brings in just the height and the width of the image you're working with and then it sends out the gradient as an image to be used however you want elsewhere in the workflow which means you could use it in more than one place um you know you could use it however you want as but it works by itself it can be completely disabled or removed from the workflow if you're not using it or plug back in and it works but there's some really powerful stuff you can do that's not just the only thing you can do all kinds of stuff with modules so we go back to the default thing um you can see that it's linear it's set up so that we start on the left we go to the right and that everything is plugged in you know in a generally halfhazard way now if we want to turn this into a modular version of this it's not that hard and I I'll explain to you roughly how module works first so a module essentially mirrors a Cas sampler so in a in a module generally it's just like with the K sampling note you bring in information on the left hand side and you send out information on the right hand side you bring in all the model stuff the the positive and negative prompt the latent image anything related to any of these that You' set as an input you know bring that all in on the left and it outputs whatever it outputs and it makes the changes and does the action in here now a module could include a big system of case samples that do a certain thing with an upscale and a bunch of other stuff um but it's still outwardly in the entire group kind of mirrors the way that the case sample works so if we wanted to make a module we would add whoops yeah group and then we'll add three root and we'll add a couple of these so if we were to make a case sample as kind of a um as a uh module it would it would look like this right so you've got the information comes in on the left and leaves on the right and if we plug this actually in the way you would plug this in in a in a module it goes like this and there you go you've got yourself a little module and you know it's kind of a silly module because it only does one thing but you if you wanted to now if you wanted to kind of expand this up and make something a bit more useful um you can change more stuff so you keep this output because you want to be able to Output stuff but you might want to add another one so say you want to uh do V code so let's run V code now we're outputting in image and Laden and we could plug in either one if we wanted to um we need a v now in here which we didn't need before and we add another input over here and we plug in this now if we wanted to make it more neat neat we might rerooted as well cuz you know you can reroot it you going set it up like this and it'll work and you could probably run a preview in this corner as well and there you go now you've got a a little case sampler Group which includes a vcode function and a preview and it's in one little module now what if you wanted to go even further than this if you wanted to add even more well to make this even more expansive you just keep expanding this out it you see how I'm working on it a lot like I would with a regular workflow um I'm working on just an individual component of the larger workflow here so if anything goes wrong I know it's probably related to everything within this box box as well if you're ever like doing this kind of stuff and building these workflows it actually becomes really easy to debug it at this stage because anything goes wrong it's probably where you just change stuff so you you don't have to look everywhere else to find a problem you just look in here and you okay it's probably in here so if we want to go even further with this let's grab another Cas ampler put a code over here preview here and we'll bring this down a bit more now I'll get rid of this stuff because we're going to do something a little bit different I'm going to keep these cuz the final output we're going to be using is going to be probably [Music] this oops grab your preview okay so I need need access to this same stuff again and you know in this module I have two Cas Samplers so do I really want my the wires going through everything underneath everything else not really so if I copy this stuff out again now I make use of this method of re-rooting things if you are using impact pack there is an option of using the from basic pipe and to basic pipe which allow you to combine information to a single um a single line rather than running multiple like how I'm doing West suit also has recently added another one like a a similar thing which is actually a little bit more usable than the um impact pack one kind of wish the impact pack want to do it the same way but can't have everything we want all right so plugged in that plugged in that and let's plug actually let's might as well show you this while you can click on these and you can add a node reot if you click on that middle dot you can just add a reot from there if you want all right so please be straight today workflow line I wish I could just like press a button and it snaps everything to the current rid one of the hazards are working with groups okay now I can drag this out as well grab that over here plug that into V and there you go we've got two thingo but they're not connected properly yet this will just generate two images so if we want to actually make use of this you know more like how you probably would go upscale late and bu and there you go now this is basically doing the highes fix um run this run run this at something like 52 is um I don't generally upscale by 58 usually go at 120 the the the higher the upscale in in a um hrose fix kind of thing the more likely it's going to be a bit messed up in the process I generally keep up scale a little bit lower on that all right so now it is running through here and it has its own little kind of path of information up here and this is what's called a bus now what I have down here is actually something that we need in the rest of the workflow as well and the reason Reon we use this is because it allows us to pass information that we would need further down the line um instead of going all the way back and wiring things at the start so instead of wiring everything to these nodes and having tables going under everything else I'm use reroot to change where the information is available to me and in keeping this all within this module within this group I can now drag this wherever I want in my workflow so I have successfully now created a module for the um the case ampl part of the basic load default thing I'm going to remove that CU I don't really need to save stuff I remove that now let's focus on this bit here so load is pretty simple typically it can go in with these with these neres um don't necessarily always want to include the prompt in with your loaders because um all right so let's go and cover this stuff now uh so this is the the loader section of your workflow it's the part which starts everything running it's the part which runs um you know without which you're you cannot make any images so you know it loads your model um let's use real Vision um the clip text and code is kind of vital to things and stuff like that so we're including the positive and negative one I'm going to change the color cuz I always do and I generally would include a laden empty Laden with this as well and everything in here produces everything we need over here as well it produce everything we need for the um this bus thing here so now we just have to wire it in kind of a semi sensible way now the cool thing about prompt text kind of nodes you don't really need to make them gigantic I Like to Lay these things out in a way that kind of makes a little bit of sense if we uh run all this over here like so we can effectively build our bus over here as well and we'll grab this to wrong thing okay there we've just created this kind of little weird little setup here now if I was bringing any information into this kind of setup I would probably be having um three roots on the left hand inside somewhere so if I decided that and this is something I commonly do which is to uh run stuff from a text box instead so I can use a text box in more than one place um I would probably have this rerooted in from somewhere else where I actually generate that in another module so with random wild cards or whatever I would probably have that kind of stuff I'm just going to check and see if I have a random wild card to use I might have one in my node templates location generator yeah that'll do all right free module uh add group stick it yeah and now we have a module that's a really powerful thing to be aware of by the way the um the node templates you have to click on the background and right click on the background to get access to it and you have to select like a whole group of nodes and then right click on the background to gain access to it um which allows you to copy and save chunks of your workflow to be used again unfortunately it doesn't work on groups which is kind of disappointing it would make my life easier okay this one is very simple it generates a phrase which says creates a location for our prompt so inside a deserted empty Parkland inside a blah outside of blah and then it will randomly generate these things using a few words so here I'm generating the phrase here I'm generating the kind of descriptive thing for it and here I'm generating the actual location itself in the bottom one just so you know what it's doing and I as well we're going to need a subject for this so let's add another one in here we may as well add multi m one day I will have my hands able to there we go go I got it oh we good and is there a freaking Cate no there not so let's add another one okay and we'll extend this a little bit to make it all fit together so what I've just done is this is the random Generation section and in this little prompt here I've added a little thing where I can just manually put a subject and it is sticking it to the front of the list that when this generates it will now have a person or something in the front of that if I just say a giant Red Alien standing Al and then when I do this it should should just generate hang on I'll just generate as it is go R alien standing alone outside a cold dark Parkland yeah that works for me all right so now we are generating The Prompt and we can send it right over here and um the difference between a standard module like this kind of set up over here which requires a whole bunch of this stuff um stuff like the prompt usually connects to the loader itself rather than to the um to the bus and I'll show you how to build a bus which is pretty much already did over here can I just copy these yes yes I can so as I said if you've got was suit or you've got um impact pack there is options for this which mean you don't have to gradually wire up a a bus the way I'm currently doing and as I said before the bus is basically it's a highway of information for your uh workflow it carries everything through and if you change anything and you want to use it in line with everything else you just plug it back into the bus so it carries information wherever you're going to need it basically that's its job now the other thing that I generally do with a bus is I put it in a group me just this I spent a lot of time adjusting where things are don't worry it's it's fine I'm not OCD okay right so now we have a bus sitting in this group here we have a loader module over here we have a little thing to generate a prompt for us and over here we have the K sampler now the the reason that we are replicating this stuff in here is because if we we can only plug we can plug this place this in one place so it's unlikely that I can accidentally get in the way of this as long as this remains plugged in in one place so I can't do something and plug it into this bus in between here unless I really really want to um because it's it's replicating it in here instead of copying and plugging in the other sampler into somewhere along here um which it could do but if I do that then obviously I can have problems um and if we do it this way um you know it saves us a lot of work when it comes to reorganizing the workflow we have to do that at some point and what okay so now this is plugged in and as you can see it's plugged in in one place I'm I'm not running stuff underneath anything here there's not any tangle going on there's a little bit of ickiness going on in here with Tangles of things a little bit um which could be fixed with some scaling and maybe some minimizing of nodes and that kind of stuff um but generally speaking you can see how super organized it kind of looks um from doing this stuff and if we generate this it should should generate an image if I did everything right and I didn't break anything okay generating a a red alien that's good probably make this module a little bit bigger so we can increase the size of all right so final image is this now um as you can see works the same as that original default one except for the additional little bit of upscaling we're doing in here um and the prompt generation stuff but generally it's kind of based off the same stuff it's a very simple kind of layout and the advantage of this is if I want to add more stuff I want to add more complexity I want to change things I want to add things like control net and and IB adapter and whatever like anything else you can be wanting to run um lur or whatever all you have to do is make this longer and add more segments to it in order order to increase the complexity you just keep extending this alone and then you just plug more stuff into it and instead of sending like rewiring the entire thing to change a couple of things you're just rewiring inside the modules and there's one other cool thing I'm going to show you about these um if you are running um this kind of a a setup because these basically like a case sampler node they set up information on the left and out on the right right or any other node really um because they're set up that way you can actually treat these the same way so normally on a big complex messy kind of workflow you can't really make proper use of bypassing and bypassing is where you can select a node and press control B and then anything which would run in here doesn't run but anything which is sent to this passes through it so the the um the empty Laden that comes from here is going to pass straight through this to the next sample um and because of that this can be a really good way of turning off bits of your workflow you don't want to run in the case of a um module workflow because this is so condensed and so controllable over what plugs into where um you can just select the whole segment and go and then it won't run the module at all it'll run rest the workflow and it won't run this and if you plug say if I plug the empty latent back into here um it would just pass empty all the way through so yeah pretty kind of powerful kind of thing to be making yourself and as you can see there's some benefits for being more organized and easy to see what's doing what um hopefully that helps you with you know a good good way of laying out your own workflows um which you may not have seen and may not really have got a handle on uh may as well show you I'll show you the bus I'll show you the bus there's a bus node W suit has this um from from basic pipe and pipe and this is the impact one which does kind of the same thing but it's a little bit more um Bly and these basically plug in the same way you plug in uh everything from your bus into this and then you can just pass one line of information instead of rewiring over and over again all those things you just rewire once and then when you need them you break down and impact pack is the same way yeah hopefully hopefully this has helped uh I'm going to be doing some tutorials soon where I cover just doing modules so small components like what uh some of the things from in here for example gradients I'm going to be showing how to generate noise uh loading different things batch loading stuff I'm going to be showing you know the random generation of locations and stuff what else have I got image analysis I've got uh you know luras uh control net all that kind of stuff and and I'll I'll put all these things in small tutorials so they're not probably not going to be like 20 minutes long or something um maybe 10 minutes long but anyway um hopefully hopefully this is useful to you uh thank you for watching uh I will have more videos out soonish been a little bit busy and health things and Stu anyway thanks for watching
Info
Channel: Ferniclestix
Views: 4,022
Rating: undefined out of 5
Keywords: ComfyUI, stable diffusion, SD, AI art, Workflow, Modular, Tutorial
Id: oTczZsmoRLs
Channel Id: undefined
Length: 26min 51sec (1611 seconds)
Published: Wed Nov 15 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.