Fix After Detailer (#471)

* api doc

* fix adetailer
pull/472/head
Chengsong Zhang 2024-03-16 00:13:49 -05:00 committed by GitHub
parent bf92123125
commit 7219066279
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 5 deletions

View File

@ -2,6 +2,7 @@ from calendar import c
from typing import List
from types import MethodType
from httpx import get
import numpy as np
import torch
@ -84,7 +85,20 @@ class AnimateDiffInfV2V:
if ad_params is None or not ad_params.enable:
return
if cfg_params.denoiser.step == 0 and getattr(ad_params, "step", -1) != 0:
# !adetailer accomodation
if not motion_module.mm_injected:
if cfg_params.denoiser.step == 0:
logger.warning(
"No motion module detected, falling back to the original forward. You are most likely using !Adetailer. "
"!Adetailer post-process your outputs sequentially, and there will NOT be motion module in your UNet, "
"so there might be NO temporal consistency within the inpainted face. Use at your own risk. "
"If you really want to pursue inpainting with AnimateDiff inserted into UNet, "
"use Segment Anything to generate masks for each frame and inpaint them with AnimateDiff + ControlNet. "
"Note that my proposal might be good or bad, do your own research to figure out the best way.")
return
if cfg_params.denoiser.step == 0 and getattr(cfg_params.denoiser.inner_model, 'original_forward', None) is None:
# prompt travel
prompt_closed_loop = (ad_params.video_length > ad_params.batch_size) and (ad_params.closed_loop in ['R+P', 'A'])
ad_params.text_cond = ad_params.prompt_scheduler.multi_cond(cfg_params.text_cond, prompt_closed_loop)
@ -156,10 +170,9 @@ class AnimateDiffInfV2V:
mm_cn_restore(_context)
return x_out
if getattr(cfg_params.denoiser.inner_model, 'original_forward', None) is None:
logger.info("inner model forward hooked")
cfg_params.denoiser.inner_model.original_forward = cfg_params.denoiser.inner_model.forward
cfg_params.denoiser.inner_model.forward = MethodType(mm_sd_forward, cfg_params.denoiser.inner_model)
logger.info("inner model forward hooked")
cfg_params.denoiser.inner_model.original_forward = cfg_params.denoiser.inner_model.forward
cfg_params.denoiser.inner_model.forward = MethodType(mm_sd_forward, cfg_params.denoiser.inner_model)
cfg_params.text_cond = ad_params.text_cond
ad_params.step = cfg_params.denoiser.step