You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use [PhotoMaker](https://github.com/TencentARC/PhotoMaker) to personalize generated images with your own ID.
310
+
311
+
**NOTE**, currently PhotoMaker **ONLY** works with **SDXL** (any SDXL model files will work).
312
+
The VAE in SDXL encounters NaN issues. You can find a fixed VAE here: [SDXL VAE FP16 Fix](https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/blob/main/sdxl_vae.safetensors).
313
+
314
+
Download PhotoMaker model file (in safetensor format) [here](https://huggingface.co/bssrdf/PhotoMaker). The official release of the model file (in .bin format) does not work with `stablediffusion.cpp`.
315
+
316
+
In prompt, make sure you have a class word followed by the trigger word `"img"` (hard-coded for now). The class word could be one of `"man, woman, girl, boy"`. If input ID images contain asian faces, add `Asian` before the class word.
# keep_vae_on_cpu=True, # If on low memory GPUs (<= 8GB), setting this to True is recommended to get artifact free images
326
+
)
327
+
328
+
output = stable_diffusion.txt_to_img(
329
+
cfg_scale=5.0, # a cfg_scale of 5.0 is recommended for PhotoMaker
330
+
height=1024,
331
+
width=1024,
332
+
style_strength=10, # (0-100)% Default is 20 and 10-20 typically gets good results. Lower ratio means more faithfully following input ID (not necessarily better quality).
333
+
sample_method="euler",
334
+
prompt="a man img, retro futurism, retro game art style but extremely beautiful, intricate details, masterpiece, best quality, space-themed, cosmic, celestial, stars, galaxies, nebulas, planets, science fiction, highly detailed",
335
+
negative_prompt="realistic, photo-realistic, worst quality, greyscale, bad anatomy, bad hands, error, text",
336
+
input_id_images_path="../assets/newton_man",
337
+
)
338
+
```
339
+
340
+
### PhotoMaker Version 2
341
+
342
+
[PhotoMaker Version 2 (PMV2)](https://github.com/TencentARC/PhotoMaker/blob/main/README_pmv2.md) has some key improvements. Unfortunately it has a very heavy dependency which makes running it a bit involved in `SD.cpp`.
343
+
344
+
Running PMV2 Requires running a python script `face_detect.py` (found [here](https://github.com/leejet/stable-diffusion.cpp/blob/master/face_detect.py)) to obtain **id_embeds** for the given input images.
345
+
346
+
```
347
+
python face_detect.py <input_image_dir>
348
+
```
349
+
350
+
An `id_embeds.safetensors` file will be generated in `input_images_dir`.
351
+
352
+
**Note: this step is only needed to run once; the same `id_embeds` can be reused**
353
+
354
+
- Run the same command as in version 1 but replacing `photomaker-v1.safetensors` with `photomaker-v2.safetensors`.
355
+
356
+
You can download `photomaker-v2.safetensors` from [here](https://huggingface.co/bssrdf/PhotoMakerV2).
357
+
358
+
- All the other parameters from Version 1 remain the same for Version 2.
359
+
290
360
### Other High-level API Examples
291
361
292
-
Other examples for the high-level API (such as image to image, upscaling and model conversion) can be found in the [tests](tests) directory.
362
+
Other examples for the high-level API (such as upscaling and model conversion) can be found in the [tests](tests) directory.
293
363
294
364
## Low-level API
295
365
@@ -340,14 +410,6 @@ pip install -e .
340
410
341
411
Now you can make changes to the code within the `stable_diffusion_cpp` directory and test them in your python environment.
0 commit comments