model detection

This commit is contained in:
leejet 2025-12-20 01:15:37 +08:00
parent a3537f93ac
commit 85fa1b4551
4 changed files with 14 additions and 5 deletions

View File

@ -1051,6 +1051,9 @@ SDVersion ModelLoader::get_sd_version() {
return VERSION_SD3; 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) {
if (tensor_storage_map.find("model.diffusion_model.time_text_embed.addition_t_embedding.weight") != tensor_storage_map.end()) {
return VERSION_QWEN_IMAGE_LAYERED;
}
return VERSION_QWEN_IMAGE; return VERSION_QWEN_IMAGE;
} }
if (tensor_storage.name.find("model.diffusion_model.double_stream_modulation_img.lin.weight") != std::string::npos) { if (tensor_storage.name.find("model.diffusion_model.double_stream_modulation_img.lin.weight") != std::string::npos) {

View File

@ -43,6 +43,7 @@ enum SDVersion {
VERSION_WAN2_2_I2V, VERSION_WAN2_2_I2V,
VERSION_WAN2_2_TI2V, VERSION_WAN2_2_TI2V,
VERSION_QWEN_IMAGE, VERSION_QWEN_IMAGE,
VERSION_QWEN_IMAGE_LAYERED,
VERSION_FLUX2, VERSION_FLUX2,
VERSION_Z_IMAGE, VERSION_Z_IMAGE,
VERSION_OVIS_IMAGE, VERSION_OVIS_IMAGE,
@ -113,7 +114,7 @@ static inline bool sd_version_is_wan(SDVersion version) {
} }
static inline bool sd_version_is_qwen_image(SDVersion version) { static inline bool sd_version_is_qwen_image(SDVersion version) {
if (version == VERSION_QWEN_IMAGE) { if (version == VERSION_QWEN_IMAGE || VERSION_QWEN_IMAGE_LAYERED) {
return true; return true;
} }
return false; return false;

View File

@ -47,12 +47,13 @@ namespace Qwen {
struct QwenTimestepProjEmbeddings : public GGMLBlock { struct QwenTimestepProjEmbeddings : public GGMLBlock {
protected: protected:
bool use_additional_t_cond; bool use_additional_t_cond;
public: public:
QwenTimestepProjEmbeddings(int64_t embedding_dim, bool use_additional_t_cond = false) : QwenTimestepProjEmbeddings(int64_t embedding_dim, bool use_additional_t_cond = false)
use_additional_t_cond(use_additional_t_cond) { : use_additional_t_cond(use_additional_t_cond) {
blocks["timestep_embedder"] = std::shared_ptr<GGMLBlock>(new TimestepEmbedding(256, embedding_dim)); blocks["timestep_embedder"] = std::shared_ptr<GGMLBlock>(new TimestepEmbedding(256, embedding_dim));
if (use_additional_t_cond) { if (use_additional_t_cond) {
blocks["addition_t_embedding"] = std::make_shared<GGMLBlock>(new Embedding(2, embedding_dim)); blocks["addition_t_embedding"] = std::shared_ptr<GGMLBlock>(new Embedding(2, embedding_dim));
} }
} }
@ -542,6 +543,9 @@ namespace Qwen {
continue; continue;
} }
} }
if (version == VERSION_QWEN_IMAGE_LAYERED) {
qwen_image_params.use_additional_t_cond = true;
}
LOG_INFO("qwen_image_params.num_layers: %ld", qwen_image_params.num_layers); LOG_INFO("qwen_image_params.num_layers: %ld", qwen_image_params.num_layers);
qwen_image = QwenImageModel(qwen_image_params); qwen_image = QwenImageModel(qwen_image_params);
qwen_image.init(params_ctx, tensor_storage_map, prefix); qwen_image.init(params_ctx, tensor_storage_map, prefix);

View File

@ -44,6 +44,7 @@ const char* model_version_to_str[] = {
"Wan 2.2 I2V", "Wan 2.2 I2V",
"Wan 2.2 TI2V", "Wan 2.2 TI2V",
"Qwen Image", "Qwen Image",
"Qwen Image Layered",
"Flux.2", "Flux.2",
"Z-Image", "Z-Image",
"Ovis Image", "Ovis Image",