feat: add support for underline style lora of flux (#1103)

* feat: add support for underline style lora of flux

* add support for underline style lora of t5

* add more protected tokens
This commit is contained in:
leejet 2025-12-18 21:44:16 +08:00 committed by GitHub
parent 78e15bd4af
commit 8e9f3a4d9e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -835,6 +835,7 @@ std::string convert_sep_to_dot(std::string name) {
"proj_out", "proj_out",
"transformer_blocks", "transformer_blocks",
"single_transformer_blocks", "single_transformer_blocks",
"single_blocks",
"diffusion_model", "diffusion_model",
"cond_stage_model", "cond_stage_model",
"first_stage_model", "first_stage_model",
@ -876,7 +877,18 @@ std::string convert_sep_to_dot(std::string name) {
"ff_context", "ff_context",
"norm_added_q", "norm_added_q",
"norm_added_v", "norm_added_v",
"to_add_out"}; "to_add_out",
"txt_mod",
"img_mod",
"txt_mlp",
"img_mlp",
"proj_mlp",
"wi_0",
"wi_1",
"norm1_context",
"ff_context",
"x_embedder",
};
// record the positions of underscores that should NOT be replaced // record the positions of underscores that should NOT be replaced
std::unordered_set<size_t> protected_positions; std::unordered_set<size_t> protected_positions;
@ -1020,12 +1032,14 @@ std::string convert_tensor_name(std::string name, SDVersion version) {
} }
} }
if (sd_version_is_unet(version) || is_lycoris_underline) { // LOG_DEBUG("name %s %d", name.c_str(), version);
if (sd_version_is_unet(version) || sd_version_is_flux(version) || is_lycoris_underline) {
name = convert_sep_to_dot(name); name = convert_sep_to_dot(name);
} }
} }
std::vector<std::pair<std::string, std::string>> prefix_map = { std::unordered_map<std::string, std::string> prefix_map = {
{"diffusion_model.", "model.diffusion_model."}, {"diffusion_model.", "model.diffusion_model."},
{"unet.", "model.diffusion_model."}, {"unet.", "model.diffusion_model."},
{"transformer.", "model.diffusion_model."}, // dit {"transformer.", "model.diffusion_model."}, // dit
@ -1040,8 +1054,13 @@ std::string convert_tensor_name(std::string name, SDVersion version) {
// {"te2.text_model.encoder.layers.", "cond_stage_model.1.model.transformer.resblocks."}, // {"te2.text_model.encoder.layers.", "cond_stage_model.1.model.transformer.resblocks."},
{"te2.", "cond_stage_model.1.transformer."}, {"te2.", "cond_stage_model.1.transformer."},
{"te1.", "cond_stage_model.transformer."}, {"te1.", "cond_stage_model.transformer."},
{"te3.", "text_encoders.t5xxl.transformer."},
}; };
if (sd_version_is_flux(version)) {
prefix_map["te1."] = "text_encoders.clip_l.transformer.";
}
replace_with_prefix_map(name, prefix_map); replace_with_prefix_map(name, prefix_map);
// diffusion model // diffusion model