reference unet

This commit is contained in:
logtd
2024-03-29 23:56:08 -06:00
parent 71aa8313d3
commit 650c8ed887
11 changed files with 143 additions and 110 deletions
+11 -1
View File
@@ -1,6 +1,7 @@
import torch
from ..modules.attn_wrapper import get_attn_wrapper
from ..modules.unet_wrapper import get_unet_wrapper
from ..modules.ref_controller import RefController
@@ -70,4 +71,13 @@ def setup_ref_attn(model, attn_type):
for _, transformer_module in temp_transformers:
ref_controller.add_temporal_transformer(transformer_module)
return ref_controller
return ref_controller
def setup_ref_unet(model, attn_type):
if not hasattr(model.model.diffusion_model, 'is_ref'):
ref_controller = setup_ref_attn(model, attn_type)
model.model.diffusion_model.__class__ = get_unet_wrapper(model.model.diffusion_model.__class__, ref_controller)
return ref_controller
return None