fix: make PhotoMakerV2 more robust by image count check (#970)

This commit is contained in:
akleine 2025-11-16 10:10:48 +01:00 committed by GitHub
parent 199e675cc7
commit 6d6dc1b8ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2660,18 +2660,24 @@ sd_image_t* generate_image_internal(sd_ctx_t* sd_ctx,
LOG_WARN("Turn off PhotoMaker"); LOG_WARN("Turn off PhotoMaker");
sd_ctx->sd->stacked_id = false; sd_ctx->sd->stacked_id = false;
} else { } else {
id_cond.c_crossattn = sd_ctx->sd->id_encoder(work_ctx, init_img, id_cond.c_crossattn, id_embeds, class_tokens_mask); if (pm_params.id_images_count != id_embeds->ne[1]) {
int64_t t1 = ggml_time_ms(); LOG_WARN("PhotoMaker image count (%d) does NOT match ID embeds (%d). You should run face_detect.py again.", pm_params.id_images_count, id_embeds->ne[1]);
LOG_INFO("Photomaker ID Stacking, taking %" PRId64 " ms", t1 - t0); LOG_WARN("Turn off PhotoMaker");
if (sd_ctx->sd->free_params_immediately) { sd_ctx->sd->stacked_id = false;
sd_ctx->sd->pmid_model->free_params_buffer(); } else {
} id_cond.c_crossattn = sd_ctx->sd->id_encoder(work_ctx, init_img, id_cond.c_crossattn, id_embeds, class_tokens_mask);
// Encode input prompt without the trigger word for delayed conditioning int64_t t1 = ggml_time_ms();
prompt_text_only = sd_ctx->sd->cond_stage_model->remove_trigger_from_prompt(work_ctx, prompt); LOG_INFO("Photomaker ID Stacking, taking %" PRId64 " ms", t1 - t0);
// printf("%s || %s \n", prompt.c_str(), prompt_text_only.c_str()); if (sd_ctx->sd->free_params_immediately) {
prompt = prompt_text_only; // sd_ctx->sd->pmid_model->free_params_buffer();
if (sample_steps < 50) { }
LOG_WARN("It's recommended to use >= 50 steps for photo maker!"); // Encode input prompt without the trigger word for delayed conditioning
prompt_text_only = sd_ctx->sd->cond_stage_model->remove_trigger_from_prompt(work_ctx, prompt);
// printf("%s || %s \n", prompt.c_str(), prompt_text_only.c_str());
prompt = prompt_text_only; //
if (sample_steps < 50) {
LOG_WARN("It's recommended to use >= 50 steps for photo maker!");
}
} }
} }
} else { } else {