diff --git a/README.md b/README.md index e4e494d..f66ad27 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,19 @@ # StyleAligned for ComfyUI -Implementation of the [StyleAligned](https://style-aligned-gen.github.io/) paper for ComfyUI. Work in progress. \ No newline at end of file +Implementation of the [StyleAligned](https://style-aligned-gen.github.io/) paper for ComfyUI. + +### Installation + +Simply run `git clone git@github.com:brianfitzgerald/style_aligned_comfy.git` in your `custom_nodes` directory. + +### Usage + +Use the example workflow from [here](resources/example_workflow.json) +Or, simply add the `StyleAlignedPatch` node after `LoadCheckpoint`. + +### Parameters + +- `model`: Required, the base model to patch. +- `style_image`: Optional, path to the latent to use as a style inference. If left blank, the first latent in the batch will be used, effectively making the output of the batch consistent. +- `share_norm`: Whether to share normalization across the batch. Defaults to `both`. Set to `group` or `layer` to only share group or layer normalization, respectively. +- `scale`: The scale at which to apply the style-alignment effect. Defaults to `1`. \ No newline at end of file diff --git a/__init__.py b/__init__.py index 5e2f56e..b62acb5 100644 --- a/__init__.py +++ b/__init__.py @@ -147,7 +147,7 @@ class StyleAlignedPatch: return { "required": { "model": ("MODEL",), - "share_norm": (["disabled", "group", "layer", "both"],), + "share_norm": (["both", "group", "layer", "disabled"],), "scale": ("FLOAT", {"default": 1, "min": 0, "max": 1.0, "step": 0.1}), }, "optional": { diff --git a/resources/example_workflow.json b/resources/example_workflow.json new file mode 100644 index 0000000..fced8ee --- /dev/null +++ b/resources/example_workflow.json @@ -0,0 +1,418 @@ +{ + "last_node_id": 12, + "last_link_id": 12, + "nodes": [ + { + "id": 4, + "type": "CheckpointLoaderSimple", + "pos": [ + 26, + 474 + ], + "size": { + "0": 315, + "1": 98 + }, + "flags": {}, + "order": 0, + "mode": 0, + "outputs": [ + { + "name": "MODEL", + "type": "MODEL", + "links": [ + 11 + ], + "slot_index": 0 + }, + { + "name": "CLIP", + "type": "CLIP", + "links": [ + 3, + 5 + ], + "slot_index": 1 + }, + { + "name": "VAE", + "type": "VAE", + "links": [ + 8 + ], + "slot_index": 2 + } + ], + "properties": { + "Node name for S&R": "CheckpointLoaderSimple" + }, + "widgets_values": [ + "sd_xl_base_1.0.safetensors" + ] + }, + { + "id": 5, + "type": "EmptyLatentImage", + "pos": [ + 455, + 645 + ], + "size": { + "0": 315, + "1": 106 + }, + "flags": {}, + "order": 1, + "mode": 0, + "outputs": [ + { + "name": "LATENT", + "type": "LATENT", + "links": [ + 2 + ], + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "EmptyLatentImage" + }, + "widgets_values": [ + 512, + 512, + 4 + ] + }, + { + "id": 8, + "type": "VAEDecode", + "pos": [ + 1247, + 7 + ], + "size": { + "0": 210, + "1": 46 + }, + "flags": {}, + "order": 6, + "mode": 0, + "inputs": [ + { + "name": "samples", + "type": "LATENT", + "link": 7 + }, + { + "name": "vae", + "type": "VAE", + "link": 8 + } + ], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 10 + ], + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "VAEDecode" + } + }, + { + "id": 10, + "type": "PreviewImage", + "pos": [ + 1509, + 110 + ], + "size": { + "0": 481.1595764160156, + "1": 565.72705078125 + }, + "flags": {}, + "order": 7, + "mode": 0, + "inputs": [ + { + "name": "images", + "type": "IMAGE", + "link": 10 + } + ], + "properties": { + "Node name for S&R": "PreviewImage" + } + }, + { + "id": 7, + "type": "CLIPTextEncode", + "pos": [ + 427, + 426 + ], + "size": { + "0": 425.27801513671875, + "1": 180.6060791015625 + }, + "flags": {}, + "order": 4, + "mode": 0, + "inputs": [ + { + "name": "clip", + "type": "CLIP", + "link": 5 + } + ], + "outputs": [ + { + "name": "CONDITIONING", + "type": "CONDITIONING", + "links": [ + 6 + ], + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "CLIPTextEncode" + }, + "widgets_values": [ + "text, watermark, low quality, ugly" + ] + }, + { + "id": 6, + "type": "CLIPTextEncode", + "pos": [ + 410, + -74 + ], + "size": { + "0": 422.84503173828125, + "1": 164.31304931640625 + }, + "flags": {}, + "order": 3, + "mode": 0, + "inputs": [ + { + "name": "clip", + "type": "CLIP", + "link": 3 + } + ], + "outputs": [ + { + "name": "CONDITIONING", + "type": "CONDITIONING", + "links": [ + 4 + ], + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "CLIPTextEncode" + }, + "widgets_values": [ + "a toy train, macro photo, high quality, centered, zoom lens" + ] + }, + { + "id": 3, + "type": "KSampler", + "pos": [ + 955, + 340 + ], + "size": { + "0": 315, + "1": 474 + }, + "flags": {}, + "order": 5, + "mode": 0, + "inputs": [ + { + "name": "model", + "type": "MODEL", + "link": 12 + }, + { + "name": "positive", + "type": "CONDITIONING", + "link": 4 + }, + { + "name": "negative", + "type": "CONDITIONING", + "link": 6 + }, + { + "name": "latent_image", + "type": "LATENT", + "link": 2 + } + ], + "outputs": [ + { + "name": "LATENT", + "type": "LATENT", + "links": [ + 7 + ], + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "KSampler" + }, + "widgets_values": [ + 156680208709677, + "fixed", + 32, + 7, + "uni_pc", + "sgm_uniform", + 1 + ] + }, + { + "id": 11, + "type": "StyleAlignedPatch", + "pos": [ + 476, + 191 + ], + "size": { + "0": 216.59999084472656, + "1": 102 + }, + "flags": {}, + "order": 2, + "mode": 0, + "inputs": [ + { + "name": "model", + "type": "MODEL", + "link": 11 + }, + { + "name": "style_image", + "type": "IMAGE", + "link": null + } + ], + "outputs": [ + { + "name": "MODEL", + "type": "MODEL", + "links": [ + 12 + ], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "StyleAlignedPatch" + }, + "widgets_values": [ + "both", + 1 + ] + } + ], + "links": [ + [ + 2, + 5, + 0, + 3, + 3, + "LATENT" + ], + [ + 3, + 4, + 1, + 6, + 0, + "CLIP" + ], + [ + 4, + 6, + 0, + 3, + 1, + "CONDITIONING" + ], + [ + 5, + 4, + 1, + 7, + 0, + "CLIP" + ], + [ + 6, + 7, + 0, + 3, + 2, + "CONDITIONING" + ], + [ + 7, + 3, + 0, + 8, + 0, + "LATENT" + ], + [ + 8, + 4, + 2, + 8, + 1, + "VAE" + ], + [ + 10, + 8, + 0, + 10, + 0, + "IMAGE" + ], + [ + 11, + 4, + 0, + 11, + 0, + "MODEL" + ], + [ + 12, + 11, + 0, + 3, + 0, + "MODEL" + ] + ], + "groups": [], + "config": {}, + "extra": {}, + "version": 0.4 +} \ No newline at end of file