Skip to content

Commit

Permalink
Fixed a bug that json files with controlnet omitted were not available
Browse files Browse the repository at this point in the history
  • Loading branch information
s9roll7 committed Dec 10, 2023
1 parent bed619e commit b6fbe11
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
9 changes: 5 additions & 4 deletions src/animatediff/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,11 @@ def generate(
is_init_img_exist = img2img_map != None
region_condi_list, region_list, ip_adapter_config_map, region2index = region_preprocess(model_config, width, height, length, save_dir, is_init_img_exist, is_sdxl)

for c in controlnet_type_map:
tmp_r = [region2index[r] for r in controlnet_type_map[c]["control_region_list"]]
controlnet_type_map[c]["control_region_list"] = [r for r in tmp_r if r != -1]
logger.info(f"{c=} / {controlnet_type_map[c]['control_region_list']}")
if controlnet_type_map:
for c in controlnet_type_map:
tmp_r = [region2index[r] for r in controlnet_type_map[c]["control_region_list"]]
controlnet_type_map[c]["control_region_list"] = [r for r in tmp_r if r != -1]
logger.info(f"{c=} / {controlnet_type_map[c]['control_region_list']}")

# save config to output directory
logger.info("Saving prompt config to output directory")
Expand Down
17 changes: 10 additions & 7 deletions src/animatediff/pipelines/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2421,11 +2421,12 @@ def __call__(
multi_uncond_mode = self.lora_map is not None

controlnet_for_region = False
for c in controlnet_type_map:
reg_list = controlnet_type_map[c]["control_region_list"]
if reg_list:
controlnet_for_region = True
break
if controlnet_type_map:
for c in controlnet_type_map:
reg_list = controlnet_type_map[c]["control_region_list"]
if reg_list:
controlnet_for_region = True
break

if controlnet_for_region or multi_uncond_mode:
controlnet_for_region = True
Expand Down Expand Up @@ -2778,8 +2779,10 @@ def resize_tensor(ten, size, do_unsharp_mask=False):
shrink_controlnet = True
no_shrink_type = ["controlnet_tile"]

for nt in no_shrink_type:
controlnet_type_map[nt] = controlnet_type_map.pop(nt)
if controlnet_type_map:
for nt in no_shrink_type:
if nt in controlnet_type_map:
controlnet_type_map[nt] = controlnet_type_map.pop(nt)

def need_region_blend(cur_step, total_steps):
if cur_step + 1 == total_steps:
Expand Down

0 comments on commit b6fbe11

Please sign in to comment.