SD3 Image into Layer
Patch any weight tensor in the model with a picture
- sd3_model
- layer_image
- MODEL
SD3 Image into Layer is the generic write-back node of the SD3 Powerlab pack: the one that lets you patch any layer tensor in the model with data pulled from an image, not just the attention matrices the other nodes fuss over. Give it a layer name, feed it a picture, and it clones the model, squeezes your image down into the shape the tensor expects, and splices it in via ComfyUI's add_patches mechanism - the same machinery LoRAs use, deployed as a sledgehammer.
It's the mirror image of the pack's SD3 Layer to Image node (which dumps tensors as images). This one works backwards. Where the attention nodes are locked to a specific block and dimension, this one is freeform: any key in the model's state dict that contains your layer string is fair game, whether that's an embedding, a bias, a norm weight, or a full linear layer.
The inputs that matter
- sd3_model - the checkpoint to patch; it's cloned internally, so the loaded original is untouched.
- layer - a tensor name, multiline, substring-matched against the state dict (last match wins, so be specific).
- layer_image - the IMAGE that becomes your patch data.
- tensor_dimension - how to convert the image to match the target tensor:
2d,1d, or(1,a,b). This is the knob that makes the node work on differently-shaped tensors. - patch_strength (default 1.0) and model_strength (default 0.0) - the blend between your patch and the original weights, exactly like the attention write-back node. Defaults mean full replacement; lower the one or raise the other to interpolate toward stock.
The conversion trick
Because images are 3D (height × width × channels) and most weight tensors are 2D or 1D, the image has to be reduced before it can be patched in:
- 2d - takes just the red channel of the image as a 2D matrix. Two-thirds of your image is discarded; the picture is a data carrier, not a portrait.
- 1d - collapses the image down to a single row via a median squeeze, for 1D tensors like biases.
- (1,a,b) - the 2D extraction plus a leading batch dimension, for tensors shaped (1, a, b).
The output is a single MODEL, wired into your sampler to replace the original.
Why you'd bother
This is the "experiment on SD3 Medium's internals" node. The pack came out of the summer-2024 "perturbed SD3" scene, when people were injecting noise and swapping values into individual layers to figure out what each one did - and this is the tool that generalizes that to any tensor. Want to see what happens when block 12's bias becomes an image-derived mess at half strength? Set patch_strength to 0.5 and find out. It's not a fine-tuning tool and it won't produce coherent style transfer; it's a microscope you can stab things with, and that's honestly the appeal.
Installing it
ComfyUI Manager → search ComfyUI-SD3-Powerlab → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/G-370/ComfyUI-SD3-Powerlab
No requirements.txt, no model downloads. The pack imports matplotlib at module load and ComfyUI doesn't bundle it, so if the nodes don't show up, pip install matplotlib into ComfyUI's Python.
Gotchas
The usual pack quirks apply: shape mismatches fail hard, the substring match grabs the last key containing your string, and the author's error messages are raised as bare strings, which Python reports as the baffling TypeError: exceptions must derive from BaseException. The bigger conceptual trap is dimension count - if you feed a (1,a,b) tensor while in 2d mode, the patch silently won't line up. And remember the image→tensor conversion throws away most of the information, so what you're really doing is smuggling numbers into the weights, not "drawing on the model." If you want that illusion with less math, the attention pair (SD3 Attention To Image → SD3 Image Into Attention) is the friendlier door in.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| sd3_model | MODEL | — | |
| layer | STRING | — | |
| layer_image | IMAGE | — | |
| patch_strength | FLOAT | 1.000–1 | — |
| model_strength | FLOAT | 0.000–1 | — |
| tensor_dimension | COMBO | 3 options: 2d, 1d, (1,a,b) |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |