Skip to content

Commit e49ac6b

Browse files
committed
allow clip_vision to be loaded via clip_l or clip_g param
1 parent 2fc31d3 commit e49ac6b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

otherarch/sdcpp/stable-diffusion.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,17 @@ class StableDiffusionGGML {
224224
}
225225

226226
bool is_unet = model_loader.model_is_unet();
227+
int tempver = model_loader.get_sd_version();
228+
bool iswan = (tempver==VERSION_WAN2 || tempver==VERSION_WAN2_2_I2V || tempver==VERSION_WAN2_2_TI2V);
227229

228230
if (strlen(SAFE_STR(sd_ctx_params->clip_l_path)) > 0) {
229231
LOG_INFO("loading clip_l from '%s'", sd_ctx_params->clip_l_path);
230232
std::string prefix = is_unet ? "cond_stage_model.transformer." : "text_encoders.clip_l.transformer.";
233+
if(iswan)
234+
{
235+
prefix = "cond_stage_model.transformer.";
236+
LOG_INFO("swap clip_vision from '%s'", sd_ctx_params->clip_l_path);
237+
}
231238
if (!model_loader.init_from_file(sd_ctx_params->clip_l_path, prefix)) {
232239
LOG_WARN("loading clip_l from '%s' failed", sd_ctx_params->clip_l_path);
233240
}
@@ -236,6 +243,11 @@ class StableDiffusionGGML {
236243
if (strlen(SAFE_STR(sd_ctx_params->clip_g_path)) > 0) {
237244
LOG_INFO("loading clip_g from '%s'", sd_ctx_params->clip_g_path);
238245
std::string prefix = is_unet ? "cond_stage_model.1.transformer." : "text_encoders.clip_g.transformer.";
246+
if(iswan)
247+
{
248+
prefix = "cond_stage_model.transformer.";
249+
LOG_INFO("swap clip_vision from '%s'", sd_ctx_params->clip_g_path);
250+
}
239251
if (!model_loader.init_from_file(sd_ctx_params->clip_g_path, prefix)) {
240252
LOG_WARN("loading clip_g from '%s' failed", sd_ctx_params->clip_g_path);
241253
}

0 commit comments

Comments
 (0)