SYSTEM NOTICE

Auto translation by AI. Be sure, accuracy, nuances and authorial intent may not be fully reflected.
見出し画像

I Made a GUI Tool for Batch Generating Different Poses with a Fixed Character [Supports A1111 / ComfyUI]

"Do I have to retype the same prompt again...?"
Have you ever thought that?

When I wanted to mass-produce different poses with a fixed character, I used a fairly primitive method.
I would paste the pose prompt directly into the field where I wrote the character prompt and generate it.
Every time I changed the pose, I would rewrite that part.
That was it.

"It's not impossible, but doing this every time is a hassle."
Since I crossed that line, I decided to make a dedicated GUI tool.

This time, I created it for Stable Diffusion AUTOMATIC1111 and ComfyUI.
I think it can also be applied to ForgeNeo and other tools.


What I was struggling with

Actually, there is a standard feature called 'prompt from file or textbox' that does something similar.
(I think many people don't know about it)

But when I actually tried it, a few tedious points emerged.

・The UI is hard to understand
・It's annoying to remember the rules for creating the txt file

"It's not impossible, but it's tough to do every time."
I wanted to resolve this frustration, so I decided to make it myself.

Explanation of the tool I created

What I made this time is a simple generation support tool with a GUI.
The tool sends requests directly to the AUTOMATIC1111 WebUI API, allowing you to generate different poses in bulk while keeping the character settings fixed.

The concept is simple.
You write the character settings (common prompt) in one place in the txt file as [CHARACTER], and then just list the poses (differential prompts) as [POSE1], [POSE2], and so on.

Here is an example of the actual contents of the txt file👇

[PARAMS]
steps:25
cfg_scale:5

[CHARACTER]
masterpiece, best quality, high quality, highres, 1girl, silver hair, blue eyes, school uniform, skirt

[NEGATIVE]
worst quality, bad quality, extra fingers, missing fingers, bad hands,

[POSE1 1]
smile, upper body,  looking at viewer,
ADD:hair ribbon, wind
DEL:skirt

[POSE2 1]
arms raised,
full body, outdoors,
REPLACE:blue eyes=closed eyes
NEG_ADD:open eyes, looking at viewer

ADD: Add (accessories/atmosphere)
DEL: Delete (exact match tokens)
REPLACE: Replace (in the form of A=B)
NEG_ADD: Add to negative prompt only for this pose

With this, you can complete tasks like 'I want to change the expression only for this pose' on the spot.

You can also specify the number of images to generate for each pose, like [POSE1 5].
You can use it to generate more images for poses you like, for example.

Once generation starts, it processes the poses in order from the top, and the progress flows into the log field.
If you want to stop in the middle, you can use the stop button to immediately interrupt, including the image currently being generated.

【Tool Screen】

How it feels to use it

The best part is that you can leave it alone.

I convert the prompts I made previously into a txt file and just change the character part.
After that, just press the generate button, and it will automatically run for the number of poses.

If you generate a bunch at once, all you have to do is pick the ones you like.
I can focus on the task of choosing "this one is good," which has quietly reduced my stress.

Until now, it felt like I had to copy the next prompt and wait for generation every time I made one image... but now I can do other things while it generates.

Example generated by only replacing the character prompt

Uses beyond just mass-producing poses

This is actually quite useful for things other than "different poses."

Preparing variations for character LoRA training all at once
Mass-producing LINE stickers by just changing the character
・Keeping the composition and story the same, while replacing only the character or outfit entirely

In short, the concept is "fix the common parts and run the variations only where you want to change them," so the range of applications is wide.
By simply swapping [CHARACTER] for another, the same pose collection becomes a version for a different character.

Also, while I made this for AUTOMATIC1111 and Comfy UI this time, if you rewrite the destination, you can also apply it to Forge, NEO, etc..
You don't have to give up thinking, "I don't use A1111, so I guess I can't."

Code release

For those who think it looks hard to make or can't come up with the specifications or format, I am releasing the Python code.
Please feel free to use it as a reference. You are welcome to modify it to fit your own environment.

By the way, some might think, "Doesn't coding require a paid account for Claude Code or ChatGPT?"
But I was able to build this tool using the free tiers of Claude and ChatGPT.
If you aren't doing anything overly complex, you can build it sufficiently with free AI accounts.

If you don't know anything, try passing the file below to ChatGPT or similar.

Note that this batch is intended for use in a local environment.

Stable Diffusion

▶ Detailed usage of sd_batch_gui.py
I have summarized all the features of this tool and the details on how to write the txt file in a manual.
If you want to know the details, click here👇

Before using (supplementary notes)

These are minor precautions, so only those who are actually going to use it need to read this.

▶ Preparation before starting the batch

① Add --api to the contents of the webui-user.bat you are launching.
Since this tool instructs operations via API, you need to make it a launch batch that permits that.

@echo off

set PYTHON=
set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=--api

call webui.bat

② Install requests via pip.
This tool uses a library called requests.
If it is not installed, please run this once in cmd.

pip install requests

Comfy UI

▶ Detailed usage of comfyui_batch_gui.py
I have summarized all the features of this tool and the details on how to write the txt file in a manual.
If you want to know the details, click here👇 Thank you for reading this far.

▶ Workflow used this time
This tool requires your own workflow.
I have attached the workflow used for testing this time.
It is for Anima specifications. Please be careful.

Points to Note

ComfyUI workflows vary greatly from person to person. Therefore, this tool does not support all workflows.

In particular, it does not support workflows that require three or more prompt inputs. Please be aware of this.


▶ When an error occurs
You might feel intimidated if you are a Python beginner, but the solution is simple.
Just take a screenshot of the error screen or copy the error message, paste it into an AI, and ask it to "fix this."
That usually solves it.

▶ About Vibe Coding (An Honest Warning)
I did not write this code by understanding every single detail of its contents myself.
It is what is called "vibe coding," built while interacting with an AI.
So, you can use it with peace of mind if you assume there is a non-zero chance it might behave in unintended ways.

▶ For those who want to customize it further
If you can handle code, I recommend these extensions as well.

Change the image name for each pose (makes it easier to organize later)
Make it possible to change the image output folder as well

Currently, images are saved to the standard output folder of WebUI or ComfyUI, so customizing this part will make it much easier to use.

【Usage Environment】
・AUTOMATIC1111 WebUI
・Comfy UI

This article has been verified in the above environment.

Modification and redistribution are completely free.
However, there is no warranty, so please use it at your own risk.

Afterword

To reiterate, this Python script is not for everyone.
It is reference code intended for you to modify to suit your own needs.
If there are any flaws, I would appreciate it if you could kindly let me know.

By the way, the term "API" appears several times here, but there are no additional charges whatsoever.
You just need to launch Stable Diffusion WebUI with the --api flag.
It is a standard feature that you can use for free as is.
You don't need to be intimidated by the word "API" thinking it will cost money.

Also, some people find it tedious to paste prompts into this txt file according to the format.
I will introduce a tool that automatically extracts prompts from images and converts them into the txt format for batch tools—I'll share that eventually.

Thank you for reading this far.


いいなと思ったら応援しよう!