Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update presets #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib_free_u/global_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,22 @@ def apply_xyz():
default_presets = {
"SD1.4 Recommendations": State(
stage_infos=[
StageInfo(1.2, 0.9),
StageInfo(1.3, 0.9),
StageInfo(1.4, 0.2),
StageInfo(1, 1),
],
),
"SD2.1 Recommendations": State(
stage_infos=[
StageInfo(1.1, 0.9),
StageInfo(1.2, 0.2),
StageInfo(1.4, 0.9),
StageInfo(1.6, 0.2),
StageInfo(1, 1),
],
),
"SDXL Recommendations": State(
stage_infos=[
StageInfo(1.1, 0.6),
StageInfo(1.2, 0.4),
StageInfo(1.3, 0.9),
StageInfo(1.4, 0.2),
StageInfo(1, 1),
],
),
Expand Down
8 changes: 4 additions & 4 deletions lib_free_u/unet.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def free_u_cat_hijack(hs, *args, original_function, **kwargs):

h[:, mask] *= get_backbone_scale(
h,
backbone_factor=lerp(1, stage_info.backbone_factor, schedule_ratio),
base_scale=lerp(1, stage_info.backbone_factor, schedule_ratio),
)
h_skip = filter_skip(
h_skip,
Expand All @@ -74,17 +74,17 @@ def free_u_cat_hijack(hs, *args, original_function, **kwargs):
return original_function([h, h_skip], *args, **kwargs)


def get_backbone_scale(h, backbone_factor):
def get_backbone_scale(h, base_scale):
if global_state.instance.version == "1":
return backbone_factor
return base_scale

#if global_state.instance.version == "2":
features_mean = h.mean(1, keepdim=True)
batch_dims = h.shape[0]
features_max, _ = torch.max(features_mean.view(batch_dims, -1), dim=-1, keepdim=True)
features_min, _ = torch.min(features_mean.view(batch_dims, -1), dim=-1, keepdim=True)
hidden_mean = (features_mean - features_min.unsqueeze(2).unsqueeze(3)) / (features_max - features_min).unsqueeze(2).unsqueeze(3)
return 1 + (backbone_factor - 1) * hidden_mean
return 1 + (base_scale - 1) * hidden_mean


def filter_skip(x, threshold, scale, scale_high):
Expand Down