Skip to content

Commit

Permalink
release PuLID-FLUX-v0.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ToTheBeginning committed Oct 31, 2024
1 parent eb4004c commit 9371620
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app_flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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")
Expand Down
5 changes: 5 additions & 0 deletions docs/pulid_for_flux.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ 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).
The PuLID-FLUX model will be automatically downloaded from [huggingface](https://huggingface.co/guozinan/PuLID/tree/main).

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.

Expand Down
6 changes: 3 additions & 3 deletions pulid/pipeline_flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9371620

Please sign in to comment.