mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-07-29 22:30:43 -05:00
feat: add Longcat-Image / Longcat-Image-Edit support (#1053)
Co-authored-by: leejet <leejet714@gmail.com>
This commit is contained in:
@@ -508,6 +508,12 @@ std::string convert_diffusers_dit_to_original_flux(std::string name) {
|
||||
static std::unordered_map<std::string, std::string> flux_name_map;
|
||||
|
||||
if (flux_name_map.empty()) {
|
||||
// --- time_embed (longcat) ---
|
||||
flux_name_map["time_embed.timestep_embedder.linear_1.weight"] = "time_in.in_layer.weight";
|
||||
flux_name_map["time_embed.timestep_embedder.linear_1.bias"] = "time_in.in_layer.bias";
|
||||
flux_name_map["time_embed.timestep_embedder.linear_2.weight"] = "time_in.out_layer.weight";
|
||||
flux_name_map["time_embed.timestep_embedder.linear_2.bias"] = "time_in.out_layer.bias";
|
||||
|
||||
// --- time_text_embed ---
|
||||
flux_name_map["time_text_embed.timestep_embedder.linear_1.weight"] = "time_in.in_layer.weight";
|
||||
flux_name_map["time_text_embed.timestep_embedder.linear_1.bias"] = "time_in.in_layer.bias";
|
||||
@@ -561,6 +567,11 @@ std::string convert_diffusers_dit_to_original_flux(std::string name) {
|
||||
flux_name_map[block_prefix + "attn.norm_k.weight"] = dst_prefix + "img_attn.norm.key_norm.scale";
|
||||
flux_name_map[block_prefix + "attn.norm_added_q.weight"] = dst_prefix + "txt_attn.norm.query_norm.scale";
|
||||
flux_name_map[block_prefix + "attn.norm_added_k.weight"] = dst_prefix + "txt_attn.norm.key_norm.scale";
|
||||
// Comfy-Org/LongCat-Image stores already-converted RMSNorm tensors as *.weight.
|
||||
flux_name_map[dst_prefix + "img_attn.norm.query_norm.weight"] = dst_prefix + "img_attn.norm.query_norm.scale";
|
||||
flux_name_map[dst_prefix + "img_attn.norm.key_norm.weight"] = dst_prefix + "img_attn.norm.key_norm.scale";
|
||||
flux_name_map[dst_prefix + "txt_attn.norm.query_norm.weight"] = dst_prefix + "txt_attn.norm.query_norm.scale";
|
||||
flux_name_map[dst_prefix + "txt_attn.norm.key_norm.weight"] = dst_prefix + "txt_attn.norm.key_norm.scale";
|
||||
|
||||
// ff
|
||||
flux_name_map[block_prefix + "ff.net.0.proj.weight"] = dst_prefix + "img_mlp.0.weight";
|
||||
@@ -599,8 +610,11 @@ std::string convert_diffusers_dit_to_original_flux(std::string name) {
|
||||
|
||||
flux_name_map[block_prefix + "attn.norm_q.weight"] = dst_prefix + "norm.query_norm.scale";
|
||||
flux_name_map[block_prefix + "attn.norm_k.weight"] = dst_prefix + "norm.key_norm.scale";
|
||||
flux_name_map[block_prefix + "proj_out.weight"] = dst_prefix + "linear2.weight";
|
||||
flux_name_map[block_prefix + "proj_out.bias"] = dst_prefix + "linear2.bias";
|
||||
// Comfy-Org/LongCat-Image stores already-converted RMSNorm tensors as *.weight.
|
||||
flux_name_map[dst_prefix + "norm.query_norm.weight"] = dst_prefix + "norm.query_norm.scale";
|
||||
flux_name_map[dst_prefix + "norm.key_norm.weight"] = dst_prefix + "norm.key_norm.scale";
|
||||
flux_name_map[block_prefix + "proj_out.weight"] = dst_prefix + "linear2.weight";
|
||||
flux_name_map[block_prefix + "proj_out.bias"] = dst_prefix + "linear2.bias";
|
||||
}
|
||||
|
||||
// --- final layers ---
|
||||
@@ -668,7 +682,7 @@ std::string convert_diffusion_model_name(std::string name, std::string prefix, S
|
||||
name = convert_diffusers_unet_to_original_sdxl(name);
|
||||
} else if (sd_version_is_sd3(version)) {
|
||||
name = convert_diffusers_dit_to_original_sd3(name);
|
||||
} else if (sd_version_is_flux(version) || sd_version_is_flux2(version)) {
|
||||
} else if (sd_version_is_flux(version) || sd_version_is_flux2(version) || sd_version_is_longcat(version)) {
|
||||
name = convert_diffusers_dit_to_original_flux(name);
|
||||
} else if (sd_version_is_z_image(version)) {
|
||||
name = convert_diffusers_dit_to_original_lumina2(name);
|
||||
|
||||
Reference in New Issue
Block a user