mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
chore: black & lint fixes
This commit is contained in:
parent
11c501fc80
commit
b7773c9962
@ -64,8 +64,9 @@ class IPAdapterInvocation(BaseInvocation):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# weight: float = InputField(default=1.0, description="The weight of the IP-Adapter.", ui_type=UIType.Float)
|
# weight: float = InputField(default=1.0, description="The weight of the IP-Adapter.", ui_type=UIType.Float)
|
||||||
weight: Union[float, List[float]] = InputField(default=1, ge=0, description="The weight given to the IP-Adapter",
|
weight: Union[float, List[float]] = InputField(
|
||||||
ui_type=UIType.Float, title="Weight")
|
default=1, ge=0, description="The weight given to the IP-Adapter", ui_type=UIType.Float, title="Weight"
|
||||||
|
)
|
||||||
|
|
||||||
begin_step_percent: float = InputField(
|
begin_step_percent: float = InputField(
|
||||||
default=0, ge=-1, le=2, description="When the IP-Adapter is first applied (% of total steps)"
|
default=0, ge=-1, le=2, description="When the IP-Adapter is first applied (% of total steps)"
|
||||||
|
@ -423,7 +423,8 @@ class StableDiffusionGeneratorPipeline(StableDiffusionPipeline):
|
|||||||
# As it is now, the IP-Adapter will silently be skipped.
|
# As it is now, the IP-Adapter will silently be skipped.
|
||||||
weight = ip_adapter_data.weight[0] if isinstance(ip_adapter_data.weight, List) else ip_adapter_data.weight
|
weight = ip_adapter_data.weight[0] if isinstance(ip_adapter_data.weight, List) else ip_adapter_data.weight
|
||||||
attn_ctx = ip_adapter_data.ip_adapter_model.apply_ip_adapter_attention(
|
attn_ctx = ip_adapter_data.ip_adapter_model.apply_ip_adapter_attention(
|
||||||
unet=self.invokeai_diffuser.model, scale=weight,
|
unet=self.invokeai_diffuser.model,
|
||||||
|
scale=weight,
|
||||||
)
|
)
|
||||||
self.use_ip_adapter = True
|
self.use_ip_adapter = True
|
||||||
else:
|
else:
|
||||||
@ -510,10 +511,14 @@ class StableDiffusionGeneratorPipeline(StableDiffusionPipeline):
|
|||||||
latent_model_input = self.scheduler.scale_model_input(latents, timestep)
|
latent_model_input = self.scheduler.scale_model_input(latents, timestep)
|
||||||
|
|
||||||
# handle IP-Adapter
|
# handle IP-Adapter
|
||||||
if self.use_ip_adapter and ip_adapter_data is not None: # somewhat redundant but logic is clearer
|
if self.use_ip_adapter and ip_adapter_data is not None: # somewhat redundant but logic is clearer
|
||||||
first_adapter_step = math.floor(ip_adapter_data.begin_step_percent * total_step_count)
|
first_adapter_step = math.floor(ip_adapter_data.begin_step_percent * total_step_count)
|
||||||
last_adapter_step = math.ceil(ip_adapter_data.end_step_percent * total_step_count)
|
last_adapter_step = math.ceil(ip_adapter_data.end_step_percent * total_step_count)
|
||||||
weight = ip_adapter_data.weight[step_index] if isinstance(ip_adapter_data.weight, List) else ip_adapter_data.weight
|
weight = (
|
||||||
|
ip_adapter_data.weight[step_index]
|
||||||
|
if isinstance(ip_adapter_data.weight, List)
|
||||||
|
else ip_adapter_data.weight
|
||||||
|
)
|
||||||
if step_index >= first_adapter_step and step_index <= last_adapter_step:
|
if step_index >= first_adapter_step and step_index <= last_adapter_step:
|
||||||
# only apply IP-Adapter if current step is within the IP-Adapter's begin/end step range
|
# only apply IP-Adapter if current step is within the IP-Adapter's begin/end step range
|
||||||
# ip_adapter_data.ip_adapter_model.set_scale(ip_adapter_data.weight)
|
# ip_adapter_data.ip_adapter_model.set_scale(ip_adapter_data.weight)
|
||||||
|
Loading…
Reference in New Issue
Block a user