first commit
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
# ComfyUI Random Resolution Selector
|
||||
|
||||
[ComfyUI](https://github.com/comfyanonymous/ComfyUI) 向けのカスタムノードです。
|
||||
設定された基準解像度(Width/Height)をもとに、**「そのまま」「縦横入れ替え」「正方形」** の3つのパターンから解像度をランダム(または指定順)に決定して出力します。
|
||||
|
||||
同じプロンプトで「縦長・横長・正方形」の構図をまとめてテスト生成したい場合や、画角のバリエーションをランダムに持たせたい場合に便利です。
|
||||
|
||||
## インストール方法
|
||||
|
||||
`ComfyUI/custom_nodes/` ディレクトリに移動し、このリポジトリをクローンしてください。
|
||||
|
||||
```bash
|
||||
cd ComfyUI/custom_nodes/
|
||||
git clone https://github.com/fudosanit/ComfyUI-Random-Resolution.git
|
||||
@@ -0,0 +1,3 @@
|
||||
from .random_resolution_selector import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
|
||||
|
||||
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']
|
||||
@@ -0,0 +1,65 @@
|
||||
# random_resolution_selector.py
|
||||
|
||||
import time
|
||||
import random
|
||||
|
||||
class RandomResolutionSelector:
|
||||
last_seed = 0 # increment用
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"height": ("INT", {"default": 896, "min": 1}),
|
||||
"width": ("INT", {"default": 1152, "min": 1}),
|
||||
"random_toggle": ("BOOLEAN", {"default": True}),
|
||||
"seed": ("INT", {"default": 0, "min": 0}),
|
||||
"seed_behavior": (
|
||||
["fixed", "randomize", "increment"],
|
||||
{
|
||||
"default": "randomize",
|
||||
"label": "生成後の制御"
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("INT", "INT", "STRING",)
|
||||
RETURN_NAMES = ("width", "height", "display",)
|
||||
FUNCTION = "select"
|
||||
CATEGORY = "custom/resolution"
|
||||
|
||||
def select(self, height, width, random_toggle, seed, seed_behavior):
|
||||
# シードの決定方法
|
||||
if seed_behavior == "randomize":
|
||||
seed = random.randint(0, 1_000_000_000)
|
||||
elif seed_behavior == "increment":
|
||||
seed = RandomResolutionSelector.last_seed + 1
|
||||
RandomResolutionSelector.last_seed = seed
|
||||
# fixed はそのまま seed を使用
|
||||
|
||||
if random_toggle:
|
||||
mode = seed % 3
|
||||
if mode == 0:
|
||||
mode_name = "original"
|
||||
elif mode == 1:
|
||||
mode_name = "swapped"
|
||||
height, width = width, height
|
||||
else:
|
||||
mode_name = "square"
|
||||
size = int((height + width) / 2)
|
||||
height = width = size
|
||||
else:
|
||||
mode_name = "fixed"
|
||||
|
||||
display_text = f"width: {width}, height: {height} (seed: {seed}, mode: {mode_name})"
|
||||
return (width, height, display_text)
|
||||
|
||||
# ノード登録
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"RandomResolutionSelector": RandomResolutionSelector
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"RandomResolutionSelector": "Random Resolution Selector"
|
||||
}
|
||||
Reference in New Issue
Block a user