diff --git a/src/model.cpp b/src/model.cpp index 8fdde3b76..fdf2b8bf7 100644 --- a/src/model.cpp +++ b/src/model.cpp @@ -437,7 +437,8 @@ SDVersion ModelLoader::get_sd_version() { if (tensor_storage.name.find("model.diffusion_model.joint_blocks.") != std::string::npos) { return VERSION_SD3; } - if (tensor_storage.name.find("model.diffusion_model.transformer_blocks.0.img_mod.1.weight") != std::string::npos) { + if (tensor_storage.name.find("model.diffusion_model.transformer_blocks.0.img_mod.1.weight") != std::string::npos || + tensor_storage.name.find("transformer_blocks.0.img_mod.1.weight") != std::string::npos) { return VERSION_QWEN_IMAGE; } if (tensor_storage.name.find("llm_adapter.blocks.0.cross_attn.q_proj.weight") != std::string::npos) { diff --git a/src/name_conversion.cpp b/src/name_conversion.cpp index 618c7f6e9..81daa2bd4 100644 --- a/src/name_conversion.cpp +++ b/src/name_conversion.cpp @@ -1093,6 +1093,20 @@ std::string convert_tensor_name(std::string name, SDVersion version) { replace_with_prefix_map(name, prefix_map); + // Qwen-Image GGUF (e.g. from unsloth) may store bare tensor names without + // the model.diffusion_model. prefix. Add it so downstream loaders can find + // the tensors when they search with the canonical prefix. + if (sd_version_is_qwen_image(version)) { + if (!starts_with(name, "model.diffusion_model.") && + !starts_with(name, "text_encoders.") && + !starts_with(name, "first_stage_model.") && + !starts_with(name, "vae.") && + !starts_with(name, "cond_stage_model.") && + !starts_with(name, "lora.")) { + name = "model.diffusion_model." + name; + } + } + // diffusion model { for (const auto& prefix : diffuison_model_prefix_vec) {