Gemma 4 + New ComfyUI Nodes That Make Prompting Easy! (Ep18)
0:00 · Welcome to another episode. Today, I am talking about Gemma 4 and how to get prompts from images, audio, and video.
0:07 · Also, an easy way to remove backgrounds, a bunch of new nodes for working with prompts that will make your life easier, a better switch node, and many more updates. But first, we need to update easy installer to get the latest changes and scripts. And then, because I use some new models, we need to update ComfyUI. Because if ComfyUI is not updated to the version I use now, it will not work because it will not recognize the nodes and models.
0:32 · If you do not have easy installer, just update ComfyUI first, then update the Pixel Roma nodes. Then get the free workflows from GitHub or Discord, and you can easily access the workflows folder. You just extract the workflows folder there.
0:50 · See how I have it? And there are quite a few for today, so make sure you stick around to learn a few tricks. Let me start ComfyUI and we can start testing.
0:59 · Go to workflows on the left. And for today's episode, if you put them in the same folder like me, they should appear here. Use refresh if ComfyUI was already open. Let me start with Gemma since ComfyUI now supports it as it is without extra nodes. So, as you got used to, you have all the info you need for the workflow in the Pixel Roma node. For the load clip node, you need this Gemma 4B model that the ComfyUI team adapted to work with ComfyUI.
1:26 · You just download this model and place it in the ComfyUI models folder inside the text encoders folder. Then restart ComfyUI or press R on your keyboard to refresh the node definitions. And now, from the load clip node, you can select that Gemma 4 model.
1:44 · You have a note here about what Gemma models can do, so you can read that to understand the model better. You can collapse the note from here to save some space, or you can delete it after like a self-destructing note. So, let me check the actual workflow, since it is quite a simple one. Beside the model, I added here an easy way to have both a formula and a prompt. It is just a text concatenate node that has two fields and joins those texts into one.
2:12 · It is easier that way.
2:14 · You have a formula here, and you can change it. I made it with ChatGPT.
2:19 · And then here is the prompt that is used with that formula.
2:23 · All of that is connected to text generate, and we can run the workflow.
2:27 · Now, the model and formula enter text generate, and it outputs text that you can use in other workflows.
2:34 · You can just drag from here and connect it to a workflow, like you will see in a minute. The show text node also now has a copy button, so you can easily copy the text, since some of you asked for this feature.
2:46 · So, you can paste a prompt here, or just type a short prompt, and Gemma 4 will generate a new detailed prompt for you, depending on the formula you use. The first time is slower, but after that, it is faster.
2:58 · Speaking of speed, it depends on how much VRAM you have. I have 24 GB, and the model uses around 8 GB of VRAM.
3:07 · So, to use this model, you need at least 8 GB of VRAM, or it will be really slow if it cannot fit into memory.
3:16 · At the moment of this recording, the Comfy UI team did not release a smaller model, and the GGUF models do not work with these nodes.
3:24 · And another thing you should know is that if you try to run it multiple times, and you did not change something in the prompt or formula, it will not work. You need to change the seed manually in order to run it again.
3:36 · It is made like that, so it can run once, and then use the same prompt to generate multiple images.
3:42 · Let me show you an example using Z image turbo. We use this model since episode 1, and you have an updated note here with what it needs to run the workflow, even if you did not use it before.
3:54 · So, we have the normal text to image model for Z image, and then under it I pasted the previous workflow with Gemma 4.
4:01 · Now, you can connect either from text generate or from the show text node to the clip text and code node. It is usually an input that appears when you are close to the top left corner of that field. So, now the Z image workflow takes the prompt that is generated with Gemma 4. But, keep in mind that all models are loaded, so it needs more VRAM than running each one separately.
4:23 · From the resolution Pix Aroma node, you can select the ratio and size you want.
4:28 · And then, when you run it, it will first generate the prompt with Gemma 4.
4:33 · Then the Z image workflow uses that prompt and generates an image.
4:38 · Since it is an AI-made prompt, usually things look better than using simple prompts.
4:43 · By the way, for the preview node, you know that you can use preview or save, and some asked to decide how it is by default.
4:51 · So, in settings, if you go to Pix Aroma settings and look for preview save mode, now you can choose save or preview.
4:59 · The next time you add a node, it will have that value by default, and you can change it from the node anyway.
5:05 · So, let me try a different prompt now.
5:07 · Let me replace the bunny with a dog.
5:09 · Since I changed something in the prompt, the Gemma 4 workflow is triggered again, and the result is this one.
5:15 · And if I do not touch the seed or the prompt and run it again, only the Z image workflow will run with the same prompt. So, it is faster since it does not generate the prompt again.
5:26 · So, now it took around 8 seconds. And when it had to generate the prompt with Gemma 4 and then generate the image, it took 18 seconds.
5:36 · But, there is more that you can do with Gemma 4. Let me show you. Open workflow 2A. So, now, instead of improving a prompt, the Gemma 4 model looks at an image and creates a prompt based on that image.
5:51 · The workflow is similar to the previous one with some small differences.
5:55 · If I delete the load image node, it is almost like before.
6:00 · I just have one formula here with no extra prompt. If I delete that one also, you can see that you can put the formula here in text generate. But I like to have it bigger so I can see it quicker where I type and to have more control so I can copy and paste prompts with these new buttons that I added to the text PixRoma node. So when I connect this to text generate, it will use the formula I have in this node.
6:25 · Then I can add a load image node and you can pick any image. Then we connect it to this image input and that way it knows to look at an image.
6:34 · So that is the difference from the previous workflow. It looks at the image and uses a different formula. And now we got a prompt from that image.
6:43 · Let me show you how it looks integrated into a workflow so we can generate the image after we get the prompt.
6:49 · So same workflow for Gemma 4 here and that is connected to the Z image workflow.
6:56 · Now when I generate, I get a prompt based on the image.
7:00 · And the result is this image.
7:02 · How similar it is to the original depends on the prompt but also on the model since AI models are trained on different images and know different styles. And you can change the ratio if you want and generate again.
7:14 · Because I did not change the seed, I get the same prompt used but with different ratios.
7:20 · Another thing that we can do with this model is transcribe audio.
7:25 · So you can use this load audio node to load a woman speaking or anything else.
7:31 · And that is connected to the audio input of text generate.
7:35 · When I run it, I get the text that the voice read in the audio.
7:39 · If I go to upload and get another audio file like this one and run the workflow again, I get a new text transcription with what the man was speaking in that audio.
7:49 · So, it can be quite useful.
7:51 · And beside audio, it can also describe video files.
7:55 · Just keep in mind it can take longer for video since it reads the frames of the video.
8:00 · So, for this one, I adapted the formula to create a video prompt instead. We have this load video node, but it does not let us connect it directly to text generate. So, we need an extra node called get video components to get all video frames as an image batch. So, no audio.
8:18 · And that node is connected to the video input. So, if we look at the video, we have this ballerina cartoon dancing and the prompt describes that how the character is dressed and how it moves.
8:31 · And if I get another video and run the workflow again, we get another prompt adapted to that. So, it is nice that it can read the frames of the video.
8:40 · Sometimes you need a video description instead of a prompt to describe different frames or scenes in that video.
8:47 · In that case, you can see that with a different formula, I got the actual frame description and how it was moving in those frames.
8:55 · It did not describe each frame. I see it got four frames. So, maybe the formula can be improved or it took only the essential parts. I am not sure. And that is pretty much the Gemma model and what it can do. Now, it is time for some new nodes that I think you will like.
9:12 · The first one is a switch node that I searched for a long time and I had to build it myself. Something easy to use and that looks like an actual switch panel.
9:21 · A switch lets you route one or several inputs to a single output and it can be any type and it will output the same format as the input for the switch that is on and only one switch can be on at once.
9:33 · To add a switch, you just search for switch Pix-A-Roma and the first time you add it, it has one input and you can add more up to 32 inputs in total.
9:44 · So, when I run it, in this case, I get the first text because the first switch was on. If I enable the second one and run it, I get the second text.
9:53 · So, if I make a duplicate of this node and add a third example, you can see it lets me connect it there and it prepares another empty one for the next input.
10:02 · And also, it reads the type of input it got, in this case, a string, and puts that string label.
10:08 · Many other nodes let you add connections, but you did not know what that connection was and had to follow the cables. But now, I can rename those labels so I know what cables came from what, so it is easier to work with.
10:20 · So, remember, only one switch can be on at one time.
10:24 · Here is another example for images. If the first image is on, I get the first image. And if I enable the second one, I get the other one. So, it works with any type. Maybe you need for a workflow to switch between two or more models, so you can enable only the one you want to use.
10:43 · Now, let me show you some useful nodes that work with prompts. This prompt stack acts like a text concatenate node.
10:50 · It joins pieces of text together to get one long text.
10:54 · But the advantage is that you can add multiple fields and enable and disable them how you want, so you have more control. So, if I have these three texts on, I get a prompt that has those texts in order.
11:06 · And you can drag from those dots and move them up, so you can change the order.
11:11 · So, I can add another row here to have extra things added to that prompt and now that is added at the end. And you can clear all the text so you can add new prompts.
11:22 · But it keeps the label and which prompts were on and off. So, I can add new prompts there and you can stay organized once you have the prompts that you use most often and you just enable and disable them for different combinations.
11:35 · And if you go to settings, and then to Pixel Aroma, that node uses a comma and a space when it joins the text. And you can change it to a different separator if you want. Even if I add an extra comma here and run it again, it knows not to add two commas there, and only puts one. So, I think it does a good job at joining text. Let me try it in an actual example in a Z image workflow.
11:59 · So, it is easy to connect to the clip text encode node, so it picks that prompt. We got this image generated with it. And if I change the bunny to a cat and generate again, I get a cat image instead.
12:11 · If I turn off the one I labeled environment, now I get only that short prompt without environment details. And you can change the labels to make sense to you, so you stay organized. But so far, we only ran one prompt, either alone or made from small pieces combined. But what if you want to run multiple prompts?
12:31 · For that case, I have this node called prompt pack. Since it packs a bunch of prompts together and runs all of them one by one.
12:39 · You can see we have two options here, paragraph and lines. And that depends on how you write the prompts.
12:46 · So, if you use line mode, it takes one prompt per line, and you can see it reads three prompts. And paragraph mode reads only one prompt because it reads a prompt only if it is separated by a blank line.
13:00 · So, for line mode, we have the first line, then the second line, then the third one. I use this for short prompts.
13:07 · I just write something, press enter, write the next prompt, then press enter again.
13:13 · So, when I run it, it will queue all three prompts. But since it was a short prompt, it was hard to see. If I go here to active, I can use these three dots and clear the history.
13:25 · Now, when I run it, you can see it created three jobs there. So, it runs the workflow once for each prompt. And for paragraph mode, since it only saw one prompt there, it ran it only once.
13:38 · But, if I add more prompts there, it will run for the number of prompts.
13:42 · So, I will clear it again and show you a practical example using the Z image workflow.
13:48 · Starting with line, we have three short prompts here, each on its own line.
13:53 · I run the workflow and it creates three jobs because it saw three prompts. It also shows here how many are left. So, after finishing the first one, it shows two left. You can cancel any time each job from here.
14:10 · Or you can cancel all if you want using this cancel all running jobs button.
14:16 · So, that is pretty much for line mode.
14:18 · One prompt per line and it runs all prompts once.
14:22 · And now, let me show you a paragraph example. Since many times when I use chat GPT, I get this type of prompt that has a blank line between the prompts.
14:32 · You can see this blank line between them and that is how it knows when the next prompt starts. So, if I type something here, it is still three prompts. If I press enter and type more, it is still the same number of prompts.
14:46 · If I press enter twice to get that space, now I have the fourth prompt as you can see here. ASD has his name all over the place. So, yeah, it can be your username ASD.
14:58 · [laughter] Let me delete that extra text so I have only three prompts. And I run the workflow now and I get the bunny first, then the second prompt for the panda, and the third prompt for the cat. Before I created this node, I always had to put the number of runs manually, but now it makes my life easier.
15:18 · For the next node, I wanted to have the option to add multiple prompts in one node, but to pick which prompt goes where. So, I can pick multiple prompts at once to go in different places in the workflow. The node is called prompt multi, and this button does different things, since both work with multiple prompts, but in different ways.
15:37 · So, pay attention.
15:39 · We have three different prompts here. Until now, we could only output one at a time or one after another. But with the list, we can output all the prompts as a list and use this node called prompt from list. But it is important to connect to the prompts output, since that outputs the prompts.
15:58 · You can see a little help on mouseover for the buttons. That tells you, depending on the buttons you have, where to connect. So, for list prompts, you connect to prompts. For Q text, you connect to text. So, for the list prompts option, we have an index here from that list, where we choose which prompt we want. So, you can select from the entire list the one you want.
16:23 · For example, the cute bunny is the first prompt, so it has index one. If I select index two and run the workflow, I get the second prompt from the list. You see the dog in the forest now is output. That way, you can get the right prompt where you want in the workflow. Let me show you a use case, even though many of you will probably use it in video workflows with multiple scenes.
16:46 · In this case, I want to show you an example of multi-editing using flux client. So, I use two prompts, one to replace the bunny with a panda, and one to replace the background with a bamboo forest. So, I can get the first prompt and the second prompt separately. The first prompt is connected to the first clip text encode prompt, and the second prompt is connected to the second clip text encode prompt.
17:09 · So, let's see it in action. The first prompt is used, and the bunny is replaced with a panda. Then, for the second one, we get the background replaced.
17:20 · So, we got the bunny replaced with a panda, and it keeps going like that. You could use one prompt to replace the background and the panda at once, but sometimes when you have multiple edits at once, it does not do it right every time. Doing it in steps can give better results. You can also use different pose prompts to build a data set, describe each scene in a video, or all kinds of stuff.
17:45 · One thing to consider is that if you add another prompt, let's say I want the option for a new scene, and I turn off the second prompt, it will take this one as the first prompt and this one as the second prompt, since it creates a list with the prompts that are active. Since there are only two, the index for this one will be two. You can put a label if you want to remember.
18:08 · So, now, with the same workflow, I can run it again. We get the bunny replaced with the panda, then the panda gets the new background we asked for. So, it is more of an easy way to have all prompts organized in one place and switch quickly, instead of just copying and pasting prompts when you test. And let me also show you the Q text option, since that one works differently.
18:31 · So, instead of lists, I am on Q text. You can see I did not use the prompts output, but the text output instead, and we get a single prompt. This is similar to the prompt pack, but instead of having all the prompts in one field that you have to edit, cut, and paste if you want different prompts, with this Q text option, each prompt sits in its own field.
18:56 · So, I have a bunny, a dog, and a cat. Now, when I run it, it will queue all three prompts. First, it will generate the bunny, then it will generate the dog, and the last one is the black cat. And if you want a a order, you can just move them in the order you want from those dots. You can turn prompts off and add new prompts. So, I can add a unicorn here.
19:19 · When I run it, I get the dog, then the cat, then the unicorn. So, I hope you find this useful. Let's read now to another node that I like to use when I have a lot of images in the output folder and I only want the prompt from it, not the entire workflow.
19:34 · So, I made this node that reads the prompt from an image. I tried to cover as many paths as possible since workflows can be complex. It is not always simple like in the text encoders. Sometimes it goes to switches or the prompt comes from different sources. So, it knows the most popular workflows where the prompt lives, but there might still be cases for certain custom nodes where it does not know how to find the prompt.
19:59 · So, now from the output folder, I can just drag any image I generated with ComfyUI over this node and it will show the prompt even if the node is not connected to anything and you do not want to output the prompt as text. And when you run the workflow, that prompt is output so you can connect it to your workflow to generate new images.
20:22 · You can also use this button to copy the text and just paste it into your workflow if you want something fast. Now, this drop-down and selection only show the input folder content for now, but I will see in the future if I can adapt it to show the output folder, too. But, you can always drag your image that is faster. Or, you can use upload image. Navigate to the output folder and pick the image from there.
20:48 · So, the next time you upload, it opens from that output folder where you left off. You can see this picked both prompts. Since we used that prompt to edit the bunny into a panda and then to change the background, so it had two prompts used in the workflow.
21:05 · And I made one more node that works with text for cases when you want to overlay text over an image. The node is called text overlay and it was quite difficult to get right. I wanted to do something more complex, but I got a lot of bugs. So for now, this version does some basic text overlay. If I run the workflow, you can see it added some text here. That text was set in this field.
21:31 · So I can edit it with something else and then run it. And you have settings in the node for coordinates and how it looks. I can use these align buttons to align it to the bottom and then align it to the right side. So now, when I run it, it is in that bottom right corner. But if you have a different image ratio, you have to adjust the coordinates to fit that ratio.
21:54 · You can also open it in the editor and just place it where you want, then save it. And now, when I run it, I get the text in that position. I had to include a few Google fonts so you have some variety and so you can see the fonts no matter if you have them installed or not since they come with the node.
22:11 · These two align buttons are useful when you have multiple lines of text. Like if I add another two lines and run it, you can see by default it is centered.
22:20 · If I move it to the left and run it, now the lines are aligned to the left. If I align all to the right and run it, I get this result. And if you have the text in a text node or something else, you can connect it here to the text input and it will replace that text field. Let's see how it looks in a real workflow example, like in a Z image text to image workflow.
22:43 · So where you have an image output, you can connect it. It can be from VAE decode or you can connect it here after the preview image node.
22:51 · So now you can see I cannot open the editor since the node cannot see any connected image because I did not run the workflow yet. But I still can change settings here if I want. But, let's run the workflow first. I got this result, and now I can open the editor, change the background if I want, place it in a different position, save it, and now when I run the workflow, I get it in that position.
23:17 · And I can use the align button again, and for the next image, it is aligned where I wanted it to be. So, I hope it is useful for you. You can add your name, details about settings or prompts, or all kinds kinds of information.
23:31 · That is it for text and prompts. Let's move to removing the background from an image. For this, you need ComfyUI updated, because if you did not update it recently, it will not recognize the models. If I run the workflow, you can see I get an image without the background and the option to get the mask or inverted mask. The node is called remove background Pixema.
23:54 · It is inspired by the new ComfyUI node called remove background, but that one needed more nodes to get the models. For mine, I made it easier to get them from here.
24:05 · And for output, it only had the mask, so I had to join the mask with the image after using more nodes, and things were getting too complex. So, with my node, you can get the image without the background and the mask or inverted mask, depending on the case. Now, for models, it only works with three models so far.
24:25 · This is the model that comes from the ComfyUI team. It is pretty much good for everything, and it worked for me even on a 6 GB VRAM card. So, you just download the model and place it in the background removal folder. This one takes more time to remove the background, but it works internally at a bigger size. So, for bigger images, you get more detailed edges and better background removal.
24:49 · So, if you go to the models folder, then to background removal, this is the ComfyUI model, and I found these two alternatives, one high resolution and one with matting. Now, it is important to rename the HR and matting models so my node recognizes them correctly and it knows what resolution to use based on if it can find those letters in the model name.
25:09 · So, when you download the model, you can see it comes with a generic name called model. So, you need to rename it how I showed you. You have the instructions here. So, the HR and matting models might need more VRAM, but they should work fine on most systems. So, let me give it a test. Let me add the Pixel Roma girl image.
25:30 · Then I run it with the default model and it does a good job cutting the background. Now, let me show you the higher quality model. I will run it and if you look at the edges, it changed a little. So, it is more accurate. So, you can test with different images to see what results you get and some models are better than others depending on the image. So, try all of them.
25:52 · For example, the HR model left some things here. If I use the default one, it left a bigger spot here. And if I use the matting one, it left me the ground and only removed the background. So, that is why I think it is good to have all three since they are not so big and you can test them.
26:10 · That is all for background removal. I included the same models in image composer also by default. So, download them first and you can use them there, too. And the next example lets you change the color of the nodes.
26:22 · So, once you change the color of a node, it stays in the workflow and other people will get the same color for the nodes even if they do not have Pixel Roma nodes because the color is saved in the workflow for each node. So, I made quite a few color examples and you can see a name for each color like Pixel blue and so on.
26:40 · I made them in pairs like one with a full color body and another where I use that same body color for the title with a darker gray body.
26:50 · So, let me show you how you can use this function that comes with Pixel Roma nodes. It is not a separate node. You can use it on any node you want. All you have to do is right click on a node, and then you have Pixel Roma colors and reset colors here. You have three dark themes on top. When you select one, the first one is what I usually use for my nodes by default. Then you have those that are actual single colors, like a darker red for the title and lighter red for the body.
27:19 · And from here, you can reset the color back to the default comfy UI gray color. So, for example, I can use Pixel lime that has that green title, or the lime version that has the green body and darker title.
27:34 · So, I added all those themes with colors I like, but of course, you can add your own colors. Go here where it says pick custom. Now, you have a small node preview here. Keep in mind that the title text uses a gray color, and that cannot be changed. So, not all color combinations are possible since some titles are not visible. I wish they left it white. That would have worked with many colors. So, I can use a title bar color from the left and a body color from the right, and look at the node to make sure things are still visible, like the title and the inputs and outputs.
28:09 · And when you apply it, you get those colors on the node. So, if you add another node or select another node from the workflow, from Pixel Roma colors, you can now see that color in favorites.
28:20 · When you click on it, it picks the same color, like the last one you used in custom colors. So, I can select multiple nodes, right click on one, pick the favorite, and now all are colored. And if you want to reset, you can also reset all the nodes, but not to the original color, instead to a gray color. So, this one was more of a fun project to have the node colors how you want them. And speaking of fun, you probably saw that I had some sparks today when running workflows.
28:47 · If I go to Pixelrama settings and look for run button, by default, it is the comfy UI blue button. So, I can change it to Pixelrama orange, or I can change it to the flash style with sparks. So, now when I press it, it gets those flashes. Another effect you can try is ignition, where it gets that ignition effect like a rocket.
29:11 · It is pretty fun to use, like launching a rocket into the unknown each time you run the workflow. There are a few more you can try, so give them a try and let me know your favorite in the comments.
29:22 · And another setting you can enable is connections. So, when that setting is on, when you make a connection, you get a little spark effect. Also, when you are getting close to an input with a cable, you get that nice animation with particles moving back and forward there.
29:40 · That is all for today. I hope you like the new nodes. [music and singing] Thank you, legends, and everyone who subscribed to the membership. [music] If you found something useful, leave a like and a comment to help with the YouTube algorithm. Have a great day.