mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2025-12-12 13:28:37 +00:00
fix: prevent core dump in PM V2 in case of incomplete cmd line (#950)
This commit is contained in:
parent
c2d8ffc22c
commit
0fa3e1a383
@ -40,7 +40,7 @@ Running PMV2 is now a two-step process:
|
|||||||
```
|
```
|
||||||
python face_detect.py input_image_dir
|
python face_detect.py input_image_dir
|
||||||
```
|
```
|
||||||
An ```id_embeds.safetensors``` file will be generated in ```input_images_dir```
|
An ```id_embeds.bin``` file will be generated in ```input_images_dir```
|
||||||
|
|
||||||
**Note: this step is only needed to run once; the same ```id_embeds``` can be reused**
|
**Note: this step is only needed to run once; the same ```id_embeds``` can be reused**
|
||||||
|
|
||||||
@ -48,6 +48,6 @@ An ```id_embeds.safetensors``` file will be generated in ```input_images_dir```
|
|||||||
|
|
||||||
You can download ```photomaker-v2.safetensors``` from [here](https://huggingface.co/bssrdf/PhotoMakerV2)
|
You can download ```photomaker-v2.safetensors``` from [here](https://huggingface.co/bssrdf/PhotoMakerV2)
|
||||||
|
|
||||||
- All the command line parameters from Version 1 remain the same for Version 2
|
- All the command line parameters from Version 1 remain the same for Version 2 plus one extra pointing to a valid ```id_embeds``` file: --pm-id-embed-path [path_to__id_embeds.bin]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2222,18 +2222,24 @@ sd_image_t* generate_image_internal(sd_ctx_t* sd_ctx,
|
|||||||
id_embeds = load_tensor_from_file(work_ctx, pm_params.id_embed_path);
|
id_embeds = load_tensor_from_file(work_ctx, pm_params.id_embed_path);
|
||||||
// print_ggml_tensor(id_embeds, true, "id_embeds:");
|
// print_ggml_tensor(id_embeds, true, "id_embeds:");
|
||||||
}
|
}
|
||||||
id_cond.c_crossattn = sd_ctx->sd->id_encoder(work_ctx, init_img, id_cond.c_crossattn, id_embeds, class_tokens_mask);
|
if (pmv2 && id_embeds == nullptr) {
|
||||||
int64_t t1 = ggml_time_ms();
|
LOG_WARN("Provided PhotoMaker images, but NO valid ID embeds file for PM v2");
|
||||||
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 {
|
||||||
LOG_WARN("Provided PhotoMaker model file, but NO input ID images");
|
LOG_WARN("Provided PhotoMaker model file, but NO input ID images");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user