From 9371620a2a0ef73b6305f3b72b73c693629a049c Mon Sep 17 00:00:00 2001 From: yanzewu Date: Thu, 31 Oct 2024 16:40:55 +0800 Subject: [PATCH] release PuLID-FLUX-v0.9.1 --- app_flux.py | 3 ++- docs/pulid_for_flux.md | 5 +++++ pulid/pipeline_flux.py | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app_flux.py b/app_flux.py index 39a7a45..254fda4 100644 --- a/app_flux.py +++ b/app_flux.py @@ -49,7 +49,7 @@ def __init__(self, model_name: str, device: str, offload: bool, aggressive_offlo self.pulid_model.face_helper.face_det.device = torch.device("cuda") self.pulid_model.face_helper.device = torch.device("cuda") self.pulid_model.device = torch.device("cuda") - self.pulid_model.load_pretrain(args.pretrained_model) + self.pulid_model.load_pretrain(args.pretrained_model, version=args.version) @torch.inference_mode() def generate_image( @@ -305,6 +305,7 @@ def create_demo(args, model_name: str, device: str = "cuda" if torch.cuda.is_ava import argparse parser = argparse.ArgumentParser(description="PuLID for FLUX.1-dev") + parser.add_argument('--version', type=str, default='v0.9.1', help='version of the model', choices=['v0.9.0', 'v0.9.1']) parser.add_argument("--name", type=str, default="flux-dev", choices=list('flux-dev'), help="currently only support flux-dev") parser.add_argument("--device", type=str, default="cuda", help="Device to use") diff --git a/docs/pulid_for_flux.md b/docs/pulid_for_flux.md index 83f5e7b..adfaa23 100644 --- a/docs/pulid_for_flux.md +++ b/docs/pulid_for_flux.md @@ -4,6 +4,9 @@ We are happy to release the **PuLID-FLUX-v0.9.0** model, which provides a tuning If PuLID-FLUX is helpful, please help to ⭐ this repo or recommend it to your friends 😊 ## Inference +### :triangular_flag_on_post: Update +- 2024.10.31: We release the **PuLID-FLUX.v0.9.1** model. Compared to the previous version, v0.9.1 has improved the ID fidelity, with an increase of about 5 percentage points in quantitative metrics of facial similarity. + ### Local Gradio Demo You first need to follow the [dependencies-and-installation](../README.md#wrench-dependencies-and-installation) to set up the environment, and download the `flux1-dev.safetensors` (if you want to use bf16 rather than fp8) and `ae.safetensors` from [black-forest-labs/FLUX.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev/tree/main). @@ -11,6 +14,8 @@ The PuLID-FLUX model will be automatically downloaded from [huggingface](https:/ There are following four options to run the gradio demo: +:notes: Note: The Gradio demo defaults to using the latest version of the model. If you need to switch to an older version or a specific version, please append `--version SPECIFIC_VERSION` to the following command lines. + #### naive bf16 simply run `python app_flux.py`, the peak memory is under 45GB. diff --git a/pulid/pipeline_flux.py b/pulid/pipeline_flux.py index 7a528d1..019bcef 100644 --- a/pulid/pipeline_flux.py +++ b/pulid/pipeline_flux.py @@ -91,9 +91,9 @@ def components_to_device(self, device): self.clip_vision_model = self.clip_vision_model.to(device) self.pulid_encoder = self.pulid_encoder.to(device) - def load_pretrain(self, pretrain_path=None): - hf_hub_download('guozinan/PuLID', 'pulid_flux_v0.9.0.safetensors', local_dir='models') - ckpt_path = 'models/pulid_flux_v0.9.0.safetensors' + def load_pretrain(self, pretrain_path=None, version='v0.9.0'): + hf_hub_download('guozinan/PuLID', f'pulid_flux_{version}.safetensors', local_dir='models') + ckpt_path = f'models/pulid_flux_{version}.safetensors' if pretrain_path is not None: ckpt_path = pretrain_path state_dict = load_file(ckpt_path)