Skip to content

Correct Layer Weights for Strong Style Transfer to Prevent Subject Migration#797

Open
programming-pupil wants to merge 3 commits intocubiq:mainfrom
programming-pupil:main
Open

Correct Layer Weights for Strong Style Transfer to Prevent Subject Migration#797
programming-pupil wants to merge 3 commits intocubiq:mainfrom
programming-pupil:main

Conversation

@programming-pupil
Copy link

🐛 Issue
The original strong_style_transfer incorrectly included ​**structural layers (0-5 in SDXL)**​ in its weight allocation, causing unintended subject migration

🔧 Fix
File: IPAdapterPlus.py

# Original (Problematic)
elif weight_type == "strong style transfer":
    if is_sdxl:
        weight = {0:w, 1:w, 2:w, 4:w, 5:w, 6:w, 7:w, 8:w, 9:w, 10:w}  # Structural layers 0-5 included
    else:
        weight = {0:w, 1:w, 2:w, 3:w, 6:w, ...}  # SD1.5 structural layers included

# Fixed
elif weight_type == "strong style transfer":
    if is_sdxl:
        # Remove structural layers 0-3, reduce layer 4-5 weights
        weight = {
            4: w*0.3,  # Structural layer (reduced by 70%)
            5: w*0.5,  # Transition layer (reduced by 50%)
            8: w*1.2,  # Style layers (enhanced)
            9: w*1.2,
            10: w*1.2
        }
    else:
        weight = {  # SD1.5 fix
            4: w*0.2,  # Structural layer
            5: w*0.4,  # Transition layer
            9: w*1.1,  # Style layers
            10: w*1.1,
            11: w*1.1
        }

🚀 Key Improvements

  1. ​Structural Layer Exclusion:
  • SDXL layers 0-3 ​fully removed​
  • Layer 4-5 weights reduced by ​**70%-50%**​ (SDXL/SD1.5)
  1. Style Layer Enhancement:
  • Layers 8-10 (style/texture) boosted by ​**20%**​

@programming-pupil
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant