ComfyUI: Batch Generate Text 2 Image. Easy Tutorial for automating multiple prompts

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
dash lines between prompts of different concept images as a bonus we have 20 different styles mix the original prompts with these art styles what if you could run the workflow once and get a whole bunch of different pictures and variations all from different individual prompts processing your text prompts and batches is going to be a game changer that's gonna save you a ton of time I'm Abe and today I'm gonna show you cool new trick to become more efficient with ComfyUI like you I love the flexibility that comfyUI provides but I found myself spending too much time generating one text prompt at a time which is why I went looking for a solution that I wanna share with you right now it's not that hard I'll explain the solution and make it easy for you to follow along we'll look at custom nodes build a simple workflow and if you stick around we'll even look at some bonus tips and tricks and use cases I'll share the workflow in the description but here's the best part by the end of this video you'll be able to use this method in your own workflows that will save you a ton of time going forward alright so why are we talking about this ComfyUI is great for fine tuning images and generating individual concept but if you're using this professionally you're probably gonna want to generate multiple prompts variations and concepts all at the same time without having to run it individually so how do we unlock this capability first you're going to install a custom node and the custom node we're gonna install is the comfyUI inspire pack you can install this in the comfyUI manager by searching for Dr and it should be the third that shows up here or you can manually install it from the Github page once you've restarted ComfyUI you'll be able to see the Inspire Pack nodes in your menu this node will let us load multiple prompts in a single batch alright so let's show you how to use this in practice by building a simple workflow let's pretend we're a marketing agency that is a client that sells computers to monkeys they've got in touch with you and need a few different concept ideas first thing in the morning now you're not sure what you're going for yet so you wanna create a few different starting points that you can build on top of okay so let's do a little brainstorming and build a typical workflow so in a typical workflow you're gonna load a checkpoint you're gonna put in your text prompts probably gonna need to feed it a latent Image and all of this is gonna go into a sampler which you're going to decode and save okay I'm just gonna go ahead and hook all of these up and of course color code them because that's important my case using computers I don't want any text or watermarks maybe an advertisement all right and let's see if this works gonna queue it and I'm gonna change this for for our next runs okay so it finished running it for us but there's a problem right I have to test each prompt at a time and I'm not quite sure what I want yet let's see how we can do the same process but we run it in a batch instead instead of loading our text prompts in manually we want to load it in from a file um so let's go ahead and open our comfy UI folder I have my ComfyUI folder here with my custom nodes there's my inspire pack and in here I have a folder for prompts and a folder for example so this node by default comes with two different text files the first file shows you how to load in a single prompt from a single file and then the second example file shows you the formatting for loading multiple prompts from a single file so we're gonna go ahead and copy the second file and we're gonna rename this to monkeys dot TXT and as you can see the format here is for each image you're gonna provide it the positive and negative prompt and then you're gonna separate them separate each prompt with these hyphens so let's say I wanna start with monkeys using computers and I'm gonna go ahead and save this at file so now I have the monkeys dot txt file saved here going back to my comfy y interface I'm going to add my inspire pack note for loading prompt and I'm gonna load prompts from file so this is gonna load multiple prompts from a single file and you can see here that file names aren't reflective of what's in the folder and you might run into this issue and to fix it all you have to do is hit refresh on your manager and that doesn't work so you might have to refresh your browser as well and once you do that you will see that you have a monkeys dot txt file here so this isn't perfect but it works for the most part the best way to get around this is to actually fully restart ComfyUI and then you'll see that it actually updates to what's actually present in your files okay as you can see we're loading in prompts from this file and what is gonna give us is a zipped prompt output Inspire Pack has another node that we can connect this to which is to unzip those prompts all right so it takes in a zip prompt and then it will give me a positive negative and then a name that I could potentially use we don't really need our text encode to manually put stuff in so we can go ahead and convert this text to input now we can feed in the text directly from the file that's get the kits unzipped and then goes into the positive and negative notes if I run this now I'll open up the terminal so here it's starting to run the sampler with 20 steps but you can see it's automatically working on the another sampler with 20 steps right so basically what it's gonna do is gonna iterate across that file and run all four prompts it's important that you have these dashes that's how it distinguishes between each individual prompt here it's finished running and you can see that it put it in four different images here for each of our prompts not the perfect image we can probably tweak these but we managed to generate all four of these in a single run all that works but if that's all you know you're still gonna run into a couple of issues and I wanna show you how to deal with those issues and show you a couple of cool use cases at the same time so let's run a couple of more workflows to show you how to do that going back to the marketing example you wanna run these overnight and have hundreds or thousands of image populate when you come back in the morning you can go ahead and do that but it's a chore to kind of figure out each of these prompts at the same time so you can combine this with something like Gemini or chagpt to generate your prompts format them for you and then leave it running so that you can have a whole bunch when you're back okay so let's go ahead and try doing that post in some custom instructions for generating stable division prompts that I found on a Reddit Reddit thread I'm gonna link that in the description below this is a prompt guide and now it has a complete list of instructions let's see what comes up with now that we have our list of prompts we're gonna ask it to format it based on the file that we have so I have some instructions that I've pasted here okay and here's the example output so we can see it's not perfect so we're gonna have to do some manual cleanup copy going to our monkeys dot txt and now that that's ready I'm gonna save it we're gonna go back to our ComfyUI and hit Q prompt and that's it but we're not in the clear yet do you see we're gonna run into an issue that I wanna show you before you run a batch and come to your computer in the morning and realize that it hasn't worked for you at all so it just finished running and as you can see we have a problem here I think ComfyUI caches the text file and so even though we've updated it and saved it it clearly is using the same 4 prompts that we originally started with so I wanted to make sure you know this so that you don't you know run this by accident and then come in the morning and find out that it hasn't run the updated file so the safest way to avoid this is to go ahead and create a new file and then select that in your inspire module and of course it's not gonna show up here so we're gonna reload the page and we should have monkeys 2 and if we run it now okay so I think that worked because as you can see now it's gone past the four images and it's definitely running it for more than just the initial for that we ran it for so it's finished running and you can see now we can use for our advertisement not all of these will be effective but some of them might be a curious little concept okay so how do we take this one step beyond let's say I wanna experiment not just with the subject but also with different art styles to do that we're gonna go back to Gemini and ask it for 20 different styles so we got 20 different styles as you know we can't reuse the same files so we're gonna create a copy update this so that it's using this style description so we're gonna see our monkey styles I'm gonna um and I'm only gonna use the positive side of these prompts let me show you how I plan to do that so I'm gonna clone these guys here and of course I'm gonna have to refresh and now I have the monkey styles available here I only plan on using the positive okay so now that I've loaded in the styles what I wanna do is I wanna create a combination of the background and the subject prompt and to do that I'm gonna use a module called concatening conditions this is from the impact module the impact plugin is the ComfyUI Impact pack and again you can get this by searching for Dr here I'm gonna feed in my condition 1 which is my subject I'm gonna feed in my condition 2 which is my style and then this is what I'm gonna end up using for my positive conditioning and I'll run this again so you can see it gave us again the same 20 images but they're all done in different art styles so when I'm looking at each of these images now I need to pay attention not only to the subject and if that's good but also the art style and if that's the style that I'm going for and based on that I can figure out what concept I wanna go with or how alright and that's pretty much it you should now be able to use a simple workflow to generate multiple different prompts at the same time and hopefully save you some time like and subscribe if this helped and let me know in the comments if you wanna see more ComfyUI tips and tricks
Info
Channel: Abe aTech
Views: 2,667
Rating: undefined out of 5
Keywords: ComfyUI, AI Art, Text-to-Image, Batch Processing, Prompt Engineering, Stable Diffusion, TXT2IMG
Id: xfelqTfnnO8
Channel Id: undefined
Length: 10min 53sec (653 seconds)
Published: Sat Apr 13 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.