Skip to content

Commit 683f9a7

Browse files
committed
Restore instantx_control_mode field on FLUX ControlNet invocation.
1 parent bb6d073 commit 683f9a7

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

invokeai/app/invocations/fields.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ class FieldDescriptions:
192192
freeu_s2 = 'Scaling factor for stage 2 to attenuate the contributions of the skip features. This is done to mitigate the "oversmoothing effect" in the enhanced denoising process.'
193193
freeu_b1 = "Scaling factor for stage 1 to amplify the contributions of backbone features."
194194
freeu_b2 = "Scaling factor for stage 2 to amplify the contributions of backbone features."
195+
instantx_control_mode = "The control mode for InstantX ControlNet union models. Ignored for other ControlNet models. The standard mapping is: canny (0), tile (1), depth (2), blur (3), pose (4), gray (5), low quality (6). Negative values will be treated as 'None'."
195196

196197

197198
class ImageField(BaseModel):

invokeai/app/invocations/flux_controlnet.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class FluxControlNetField(BaseModel):
2525
default=1, ge=0, le=1, description="When the ControlNet is last applied (% of total steps)"
2626
)
2727
resize_mode: CONTROLNET_RESIZE_VALUES = Field(default="just_resize", description="The resize mode to use")
28+
instantx_control_mode: int | None = Field(default=-1, description=FieldDescriptions.instantx_control_mode)
2829

2930
@field_validator("control_weight")
3031
@classmethod
@@ -70,6 +71,8 @@ class FluxControlNetInvocation(BaseInvocation):
7071
default=1, ge=0, le=1, description="When the ControlNet is last applied (% of total steps)"
7172
)
7273
resize_mode: CONTROLNET_RESIZE_VALUES = InputField(default="just_resize", description="The resize mode used")
74+
# Note: We default to -1 instead of None, because in the workflow editor UI None is not currently supported.
75+
instantx_control_mode: int | None = InputField(default=-1, description=FieldDescriptions.instantx_control_mode)
7376

7477
@field_validator("control_weight")
7578
@classmethod
@@ -91,5 +94,6 @@ def invoke(self, context: InvocationContext) -> FluxControlNetOutput:
9194
begin_step_percent=self.begin_step_percent,
9295
end_step_percent=self.end_step_percent,
9396
resize_mode=self.resize_mode,
97+
instantx_control_mode=self.instantx_control_mode,
9498
),
9599
)

invokeai/app/invocations/flux_denoise.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,9 @@ def _prep_controlnet_extensions(
389389
)
390390
elif isinstance(model, InstantXControlNetFlux):
391391
instantx_control_mode: torch.Tensor | None = None
392-
# if controlnet.instantx_control_mode is not None:
393-
# instantx_control_mode = torch.tensor(controlnet.instantx_control_mode, dtype=torch.long)
394-
# instantx_control_mode = instantx_control_mode.reshape([-1, 1])
392+
if controlnet.instantx_control_mode is not None and controlnet.instantx_control_mode >= 0:
393+
instantx_control_mode = torch.tensor(controlnet.instantx_control_mode, dtype=torch.long)
394+
instantx_control_mode = instantx_control_mode.reshape([-1, 1])
395395

396396
controlnet_extensions.append(
397397
InstantXControlNetExtension(

invokeai/frontend/web/src/services/api/schema.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6323,6 +6323,12 @@ export type components = {
63236323
* @enum {string}
63246324
*/
63256325
resize_mode?: "just_resize" | "crop_resize" | "fill_resize" | "just_resize_simple";
6326+
/**
6327+
* Instantx Control Mode
6328+
* @description The control mode for InstantX ControlNet union models. Ignored for other ControlNet models. The standard mapping is: canny (0), tile (1), depth (2), blur (3), pose (4), gray (5), low quality (6). Negative values will be treated as 'None'.
6329+
* @default -1
6330+
*/
6331+
instantx_control_mode?: number | null;
63266332
};
63276333
/**
63286334
* FLUX ControlNet
@@ -6381,6 +6387,12 @@ export type components = {
63816387
* @enum {string}
63826388
*/
63836389
resize_mode?: "just_resize" | "crop_resize" | "fill_resize" | "just_resize_simple";
6390+
/**
6391+
* Instantx Control Mode
6392+
* @description The control mode for InstantX ControlNet union models. Ignored for other ControlNet models. The standard mapping is: canny (0), tile (1), depth (2), blur (3), pose (4), gray (5), low quality (6). Negative values will be treated as 'None'.
6393+
* @default -1
6394+
*/
6395+
instantx_control_mode?: number | null;
63846396
/**
63856397
* type
63866398
* @default flux_controlnet

0 commit comments

Comments
 (0)