ArtVentureX/comfyui-animatediff

BaseModel has no attribute `betas`

easeclick opened this issue · 3 comments

ERROR:root:!!! Exception during processing !!!
ERROR:root:Traceback (most recent call last):
File "D:\a\ComfyUI\ComfyUI\execution.py", line 153, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\a\ComfyUI\ComfyUI\execution.py", line 83, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\a\ComfyUI\ComfyUI\execution.py", line 76, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\a\ComfyUI\ComfyUI\custom_nodes\comfyui-animatediff\animatediff\sampler.py", line 288, in animatediff_sample
model = self.inject_motion_module(model, motion_module, inject_method, video_length)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\a\ComfyUI\ComfyUI\custom_nodes\comfyui-animatediff\animatediff\sampler.py", line 218, in inject_motion_module
self.override_beta_schedule(model.model)
File "D:\a\ComfyUI\ComfyUI\custom_nodes\comfyui-animatediff\animatediff\sampler.py", line 189, in override_beta_schedule
self.prev_beta = model.get_buffer("betas").cpu().clone().detach()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\a\ComfyUI\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 762, in get_buffer
raise AttributeError(mod._get_name() + " has no attribute " AttributeError: BaseModel has no attribute betas`

comfyui-animatediff 与 ComfyUI-AnimateDiff-Evolved 在文件 model_base.py 上冲突(D:\a\ComfyUI\ComfyUI\comfy\model_base.py)不升级ComfyUI-AnimateDiff-Evolved报错,升级comfyui-animatediff报错,

添加
self.model_config = model_config
self.register_schedule(given_betas=None, beta_schedule=model_config.beta_schedule, timesteps=1000, linear_start=0.00085, linear_end=0.012, cosine_s=8e-3)
if not unet_config.get("disable_unet_model_creation", False):

def register_schedule(self, given_betas=None, beta_schedule="linear", timesteps=1000,
linear_start=1e-4, linear_end=2e-2, cosine_s=8e-3):
if given_betas is not None:
betas = given_betas
else:
betas = make_beta_schedule(beta_schedule, timesteps, linear_start=linear_start, linear_end=linear_end, cosine_s=cosine_s)
alphas = 1. - betas
alphas_cumprod = np.cumprod(alphas, axis=0)
alphas_cumprod_prev = np.append(1., alphas_cumprod[:-1])

    timesteps, = betas.shape
    self.num_timesteps = int(timesteps)
    self.linear_start = linear_start
    self.linear_end = linear_end

    self.register_buffer('betas', torch.tensor(betas, dtype=torch.float32))
    self.register_buffer('alphas_cumprod', torch.tensor(alphas_cumprod, dtype=torch.float32))
    self.register_buffer('alphas_cumprod_prev', torch.tensor(alphas_cumprod_prev, dtype=torch.float32))

可以解决问题(个人建议)

@easeclick This issue should be fixed on the latest update.