vislearn / ControlNet-XS

Apache License 2.0
411 stars 12 forks source link

TwoStreamControlNet: control_scale is always set to 1.0 #17

Closed deltheil closed 6 months ago

deltheil commented 7 months ago

It is initialized in the CTOR and never changes afterwards.

As a consequence, setting control_scale in the high-level get_sdxl_sample API has no effect on it while this factor is involved in the timestep embedding computation.

(In other words, the base model time_embed has no effect whatever the input control_scale)

But also, setting control_scale=0.0 when calling get_sdxl_sample is different than completely disabling ControlNet-XS via no_control = True.

It looks to me, it should be changed via something like:

--- a/scripts/control_utils.py
+++ b/scripts/control_utils.py
@@ -185,6 +185,7 @@ def get_sdxl_sample(

     if float(control_scale) != 1.0:
         model.model.scale_list *= control_scale
+        model.model.control_scale = control_scale
         print(f'[CONTROL CORRECTION OF {type(model).__name__} SCALED WITH {control_scale}]')

     control = torch.stack([tt.ToTensor()(ds['hint'][..., None].repeat(3, 2))] * num_samples).float().to('cuda')
@@ -231,6 +232,7 @@ def get_sdxl_sample(

     #  reset scales
     model.model.scale_list = model.model.scale_list * 0. + 1.
+    model.model.control_scale = 1.

     return x_samples, control

--

Is it intended (bug or feature)? Am I missing something?

Sipirius commented 7 months ago

This functionality should not have been removed and will be added back shortly.

cheers

deltheil commented 6 months ago

This functionality should not have been removed and will be added back shortly.

Looks like this has been fixed by 3df4d6e