@@ -63,23 +63,24 @@ struct FrozenCLIPEmbedderWithCustomWords : public Conditioner {
6363 PMVersion pv = PM_VERSION_1,
6464 int clip_skip = -1 )
6565 : version(version), pm_version(pv), tokenizer(sd_version_is_sd2(version) ? 0 : 49407 ), embd_dir(embd_dir) {
66- if (clip_skip <= 0 ) {
67- clip_skip = 1 ;
68- if (sd_version_is_sd2 (version) || sd_version_is_sdxl (version)) {
69- clip_skip = 2 ;
70- }
71- }
7266 if (sd_version_is_sd1 (version)) {
73- text_model = std::make_shared<CLIPTextModelRunner>(backend, tensor_types, " cond_stage_model.transformer.text_model" , OPENAI_CLIP_VIT_L_14, clip_skip );
67+ text_model = std::make_shared<CLIPTextModelRunner>(backend, tensor_types, " cond_stage_model.transformer.text_model" , OPENAI_CLIP_VIT_L_14);
7468 } else if (sd_version_is_sd2 (version)) {
75- text_model = std::make_shared<CLIPTextModelRunner>(backend, tensor_types, " cond_stage_model.transformer.text_model" , OPEN_CLIP_VIT_H_14, clip_skip );
69+ text_model = std::make_shared<CLIPTextModelRunner>(backend, tensor_types, " cond_stage_model.transformer.text_model" , OPEN_CLIP_VIT_H_14);
7670 } else if (sd_version_is_sdxl (version)) {
77- text_model = std::make_shared<CLIPTextModelRunner>(backend, tensor_types, " cond_stage_model.transformer.text_model" , OPENAI_CLIP_VIT_L_14, clip_skip, false );
78- text_model2 = std::make_shared<CLIPTextModelRunner>(backend, tensor_types, " cond_stage_model.1.transformer.text_model" , OPEN_CLIP_VIT_BIGG_14, clip_skip, false );
71+ text_model = std::make_shared<CLIPTextModelRunner>(backend, tensor_types, " cond_stage_model.transformer.text_model" , OPENAI_CLIP_VIT_L_14, false );
72+ text_model2 = std::make_shared<CLIPTextModelRunner>(backend, tensor_types, " cond_stage_model.1.transformer.text_model" , OPEN_CLIP_VIT_BIGG_14, false );
7973 }
74+ set_clip_skip (clip_skip);
8075 }
8176
8277 void set_clip_skip (int clip_skip) {
78+ if (clip_skip <= 0 ) {
79+ clip_skip = 1 ;
80+ if (sd_version_is_sd2 (version) || sd_version_is_sdxl (version)) {
81+ clip_skip = 2 ;
82+ }
83+ }
8384 text_model->set_clip_skip (clip_skip);
8485 if (sd_version_is_sdxl (version)) {
8586 text_model2->set_clip_skip (clip_skip);
@@ -665,15 +666,16 @@ struct SD3CLIPEmbedder : public Conditioner {
665666 std::map<std::string, enum ggml_type>& tensor_types,
666667 int clip_skip = -1 )
667668 : clip_g_tokenizer(0 ) {
668- if (clip_skip <= 0 ) {
669- clip_skip = 2 ;
670- }
671- clip_l = std::make_shared<CLIPTextModelRunner>(backend, tensor_types, " text_encoders.clip_l.transformer.text_model" , OPENAI_CLIP_VIT_L_14, clip_skip, false );
672- clip_g = std::make_shared<CLIPTextModelRunner>(backend, tensor_types, " text_encoders.clip_g.transformer.text_model" , OPEN_CLIP_VIT_BIGG_14, clip_skip, false );
669+ clip_l = std::make_shared<CLIPTextModelRunner>(backend, tensor_types, " text_encoders.clip_l.transformer.text_model" , OPENAI_CLIP_VIT_L_14, false );
670+ clip_g = std::make_shared<CLIPTextModelRunner>(backend, tensor_types, " text_encoders.clip_g.transformer.text_model" , OPEN_CLIP_VIT_BIGG_14, false );
673671 t5 = std::make_shared<T5Runner>(backend, tensor_types, " text_encoders.t5xxl.transformer" );
672+ set_clip_skip (clip_skip);
674673 }
675674
676675 void set_clip_skip (int clip_skip) {
676+ if (clip_skip <= 0 ) {
677+ clip_skip = 2 ;
678+ }
677679 clip_l->set_clip_skip (clip_skip);
678680 clip_g->set_clip_skip (clip_skip);
679681 }
@@ -1010,14 +1012,15 @@ struct FluxCLIPEmbedder : public Conditioner {
10101012 FluxCLIPEmbedder (ggml_backend_t backend,
10111013 std::map<std::string, enum ggml_type>& tensor_types,
10121014 int clip_skip = -1 ) {
1013- if (clip_skip <= 0 ) {
1014- clip_skip = 2 ;
1015- }
1016- clip_l = std::make_shared<CLIPTextModelRunner>(backend, tensor_types, " text_encoders.clip_l.transformer.text_model" , OPENAI_CLIP_VIT_L_14, clip_skip, true );
1015+ clip_l = std::make_shared<CLIPTextModelRunner>(backend, tensor_types, " text_encoders.clip_l.transformer.text_model" , OPENAI_CLIP_VIT_L_14, true );
10171016 t5 = std::make_shared<T5Runner>(backend, tensor_types, " text_encoders.t5xxl.transformer" );
1017+ set_clip_skip (clip_skip);
10181018 }
10191019
10201020 void set_clip_skip (int clip_skip) {
1021+ if (clip_skip <= 0 ) {
1022+ clip_skip = 2 ;
1023+ }
10211024 clip_l->set_clip_skip (clip_skip);
10221025 }
10231026
@@ -1422,4 +1425,4 @@ struct PixArtCLIPEmbedder : public Conditioner {
14221425 }
14231426};
14241427
1425- #endif
1428+ #endif
0 commit comments