Skip to content

Commit caea524

Browse files
committed
fix photomaker crash
1 parent 684d71e commit caea524

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

otherarch/sdcpp/sdtype_adapter.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ static int cfg_square_limit = 0;
124124
static int cfg_side_limit = 0;
125125
static bool sd_is_quiet = false;
126126
static std::string sdmodelfilename = "";
127+
static bool photomaker_enabled = false;
127128

128129
bool sdtype_load_model(const sd_load_model_inputs inputs) {
129130
sd_is_quiet = inputs.quiet;
@@ -169,6 +170,7 @@ bool sdtype_load_model(const sd_load_model_inputs inputs) {
169170
if(photomaker_filename!="")
170171
{
171172
printf("With PhotoMaker Model: %s\n",photomaker_filename.c_str());
173+
photomaker_enabled = true;
172174
}
173175
if(inputs.quant)
174176
{
@@ -433,6 +435,11 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs)
433435
std::string photomaker_image_data = std::string(inputs.photomaker_image);
434436
std::string sampler = inputs.sample_method;
435437

438+
if(!photomaker_enabled)
439+
{
440+
photomaker_image_data = "";
441+
}
442+
436443
sd_params->prompt = cleanprompt;
437444
sd_params->negative_prompt = cleannegprompt;
438445
sd_params->cfg_scale = inputs.cfg_scale;
@@ -625,7 +632,7 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs)
625632
sd_params->slg_scale,
626633
sd_params->skip_layer_start,
627634
sd_params->skip_layer_end,
628-
(photomaker_image_data!=""?&photomaker_reference:nullptr));
635+
(photomaker_image_data!=""?(&photomaker_reference):nullptr));
629636
} else {
630637

631638
if (sd_params->width <= 0 || sd_params->width % 64 != 0 || sd_params->height <= 0 || sd_params->height % 64 != 0) {
@@ -749,7 +756,7 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs)
749756
sd_params->slg_scale,
750757
sd_params->skip_layer_start,
751758
sd_params->skip_layer_end,
752-
(photomaker_image_data!=""?&photomaker_reference:nullptr));
759+
(photomaker_image_data!=""?(&photomaker_reference):nullptr));
753760
}
754761

755762
if (results == NULL) {

0 commit comments

Comments
 (0)