Files
2024-06-29 18:50:22 +08:00

66 lines
2.6 KiB
Markdown

---
tags:
- ControlNet
- Weight
---
# T2IAdapter Custom Weights 🛂🅐🅒🅝
## Documentation
- Class name: `CustomT2IAdapterWeights`
- Category: `Adv-ControlNet 🛂🅐🅒🅝/weights/T2IAdapter`
- Output node: `False`
This node is designed to load and configure weights for a custom Text-to-Image (T2I) Adapter within the Advanced ControlNet framework. It allows for the dynamic adjustment of weight parameters to fine-tune the control over the image generation process, incorporating options to flip weights for varied effects.
## Input types
### Required
- **`weight_i`**
- unknown
- Comfy dtype: `FLOAT`
- Python dtype: `unknown`
- **`flip_weights`**
- A boolean parameter that, when enabled, reverses the order of weights, potentially altering the image generation outcome for creative variations.
- Comfy dtype: `BOOLEAN`
- Python dtype: `bool`
## Output types
- **`CN_WEIGHTS`**
- Comfy dtype: `CONTROL_NET_WEIGHTS`
- Outputs the configured weights as a set, ready for application within the T2I Adapter for controlling image generation.
- Python dtype: `list[float]`
- **`TK_SHORTCUT`**
- Comfy dtype: `TIMESTEP_KEYFRAME`
- Generates a keyframe group based on the configured weights, facilitating precise control over the image generation timeline.
- Python dtype: `TimestepKeyframeGroup`
## Usage tips
- Infra type: `CPU`
- Common nodes: unknown
## Source code
```python
class CustomT2IAdapterWeights:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"weight_00": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
"weight_01": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
"weight_02": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
"weight_03": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ),
"flip_weights": ("BOOLEAN", {"default": False}),
},
}
RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",)
RETURN_NAMES = WEIGHTS_RETURN_NAMES
FUNCTION = "load_weights"
CATEGORY = "Adv-ControlNet 🛂🅐🅒🅝/weights/T2IAdapter"
def load_weights(self, weight_00, weight_01, weight_02, weight_03, flip_weights):
weights = [weight_00, weight_01, weight_02, weight_03]
weights = get_properly_arranged_t2i_weights(weights)
weights = ControlWeights.t2iadapter(weights, flip_weights=flip_weights)
return (weights, TimestepKeyframeGroup.default(TimestepKeyframe(control_weights=weights)))
```