Skip to content

Commit

Permalink
Lint format corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Danamir committed Dec 8, 2023
1 parent 5c0d3b8 commit 3272a09
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions ai_diffusion/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def _parse_loras(client: Client, prompt: str) -> list[dict[str, str | float]]:

for client_lora in client.lora_models:
_, lora_filename = os.path.split(client_lora)
lora_filename,_ = os.path.splitext(lora_filename)
lora_filename, _ = os.path.splitext(lora_filename)
if match[0].lower() == lora_filename.lower():
lora_name = client_lora

Expand All @@ -227,10 +227,7 @@ def _parse_loras(client: Client, prompt: str) -> list[dict[str, str | float]]:
log.warning(error)
raise LoraException(error)

loras.append(dict(
name=lora_name,
strength=lora_strength
))
loras.append(dict(name=lora_name, strength=lora_strength))
return loras


Expand All @@ -244,7 +241,13 @@ def _apply_strength(strength: float, steps: int, min_steps: int = 0) -> tuple[in
return steps, start_at_step


def load_model_with_lora(w: ComfyWorkflow, comfy: Client, style: Style, is_live=False, additional_loras: list[dict[str, str | float]] | tuple = ()):
def load_model_with_lora(
w: ComfyWorkflow,
comfy: Client,
style: Style,
is_live=False,
additional_loras: list[dict[str, str | float]] | tuple = (),
):
checkpoint = style.sd_checkpoint
if checkpoint not in comfy.checkpoints:
checkpoint = next(iter(comfy.checkpoints.keys()))
Expand Down Expand Up @@ -471,11 +474,7 @@ def generate(

w = ComfyWorkflow(comfy.nodes_inputs)
model, clip, vae = load_model_with_lora(
w,
comfy,
style,
is_live=live.is_active,
additional_loras=_parse_loras(comfy, cond.prompt)
w, comfy, style, is_live=live.is_active, additional_loras=_parse_loras(comfy, cond.prompt)
)
latent = w.empty_latent_image(extent.initial.width, extent.initial.height, batch)
model, positive, negative = apply_conditioning(cond, w, comfy, model, clip, style)
Expand All @@ -497,7 +496,9 @@ def inpaint(comfy: Client, style: Style, image: Image, mask: Mask, cond: Conditi
expanded_bounds = Bounds(*mask.bounds.offset, *region_expanded)

w = ComfyWorkflow(comfy.nodes_inputs)
model, clip, vae = load_model_with_lora(w, comfy, style, additional_loras=_parse_loras(comfy, cond.prompt))
model, clip, vae = load_model_with_lora(
w, comfy, style, additional_loras=_parse_loras(comfy, cond.prompt)
)
in_image = w.load_image(scaled_image)
in_mask = w.load_mask(scaled_mask)
cropped_mask = w.load_mask(mask.to_image())
Expand Down Expand Up @@ -576,11 +577,7 @@ def refine(

w = ComfyWorkflow(comfy.nodes_inputs)
model, clip, vae = load_model_with_lora(
w,
comfy,
style,
is_live=live.is_active,
additional_loras=_parse_loras(comfy, cond.prompt)
w, comfy, style, is_live=live.is_active, additional_loras=_parse_loras(comfy, cond.prompt)
)
in_image = w.load_image(image)
if extent.is_incompatible:
Expand Down Expand Up @@ -615,11 +612,7 @@ def refine_region(

w = ComfyWorkflow(comfy.nodes_inputs)
model, clip, vae = load_model_with_lora(
w,
comfy,
style,
is_live=live.is_active,
additional_loras=_parse_loras(comfy, cond.prompt)
w, comfy, style, is_live=live.is_active, additional_loras=_parse_loras(comfy, cond.prompt)
)
in_image = w.load_image(image)
in_mask = w.load_mask(mask_image)
Expand Down Expand Up @@ -714,7 +707,9 @@ def upscale_tiled(

w = ComfyWorkflow(comfy.nodes_inputs)
img = w.load_image(image)
checkpoint, clip, vae = load_model_with_lora(w, comfy, style, additional_loras=_parse_loras(comfy, cond.prompt))
checkpoint, clip, vae = load_model_with_lora(
w, comfy, style, additional_loras=_parse_loras(comfy, cond.prompt)
)
upscale_model = w.load_upscale_model(model)
if sd_ver.has_controlnet_blur:
cond.control.append(Control(ControlMode.blur, img))
Expand Down

0 comments on commit 3272a09

Please sign in to comment.