infer_pulid

infer_pulid

About

1.0.0
Apache-2.0

Pure and Lightning ID customization (PuLID) is a novel tuning-free ID customization method for text-to-image generation.

Task: Image generation
Stable Diffusion
Hugging Face
text-to-image
Generative
ID Customization

Run PuLID, a tuning-free ID customization approach. It's is an ip-adapter alike method to restore facial identity. It uses insightface embedding, CLIP embedding and SDXL-Lightning for inferences in 4 steps.

Note: This algorithm is using about 19 GB of VRAM

output_1

🚀 Use with Ikomia API

1. Install Ikomia API

We strongly recommend using a virtual environment. If you're not sure where to start, we offer a tutorial here.

pip install ikomia

2. Create your workflow

from ikomia.dataprocess.workflow import Workflow
from ikomia.utils.displayIO import display

# Init your workflow
wf = Workflow()

# Add algorithm
algo = wf.add_task(name="infer_pulid", auto_connect=True)

# Run on your image
wf.run_on(url="https://images.pexels.com/photos/4927360/pexels-photo-4927360.jpeg?cs=srgb&dl=pexels-anntarazevich-4927360.jpg&fm=jpg&w=1280&h=1920")

# Inpect your result
display(algo.get_output(0).get_image())

☀️ Use with Ikomia Studio

Ikomia Studio offers a friendly UI with the same features as the API.

  • If you haven't started using Ikomia Studio yet, download and install it from this page.
  • For additional guidance on getting started with Ikomia Studio, check out this blog post.

📝 Set algorithm parameters

  • prompt (str): Text prompt to guide the image generation.
  • negative_prompt (str, optional) - default 'flaws in the eyes, flaws in the face, flaws, lowres, non-HDRi, low quality, worst quality,' 'artifacts noise, text, watermark, glitch, deformed, mutated, ugly, disfigured, hands, ' 'low resolution, partially rendered objects, deformed or partially rendered eyes, ' 'deformed, deformed eyeballs, cross-eyed, blurry'. The prompt not to guide the image generation. Ignored when not using guidance (i.e., ignored if guidance_scale is less than 1).
  • num_inference_steps (int) - default '4': Number of denoising steps.
  • guidance_scale (float) - default '1.2': Stable diffusion Scale for classifier-free guidance. Recommended between [1, 1.5]. 1 will be faster.
  • guidance_scale_id (float) - default '0.8': ID guidance scale. Recommended between [0, 5].
  • seed (int) - default '-1': Seed value. '-1' generates a random number between 0 and 1919655350.
  • num_images_per_prompt (int) - default '1': Number of generated images.
  • mode (str) - default 'fidelity': Mode of the image generation 'fidelity' or 'extremely style'. We don't see much of a difference between the two.
  • width (int) - default '1024': Output width. If not divisible by 8 it will be automatically modified to a multiple of 8.
  • height (int) - default '1024': Output height. If not divisible by 8 it will be automatically modified to a multiple of 8.
  • id_mix (bool) - default 'False': If you want to mix two ID image, please turn this on, otherwise, turn this off.
from ikomia.dataprocess.workflow import Workflow
from ikomia.utils.displayIO import display

# Init your workflow
wf = Workflow()

# Set main image
wf.set_image_input(
url="https://images.pexels.com/photos/4927360/pexels-photo-4927360.jpeg?cs=srgb&dl=pexels-anntarazevich-4927360.jpg&fm=jpg&w=1280&h=1920",
index=0
)

# Set additional image(s) [optional]
wf.set_image_input(
url="https://images.pexels.com/photos/4927361/pexels-photo-4927361.jpeg?cs=srgb&dl=pexels-anntarazevich-4927361.jpg&fm=jpg&w=1280&h=1920",
index=1
)

wf.set_image_input(
url="https://images.pexels.com/photos/4927359/pexels-photo-4927359.jpeg?cs=srgb&dl=pexels-anntarazevich-4927359.jpg&fm=jpg&w=1280&h=1920",
index=2
)

wf.set_image_input(
url="https://images.pexels.com/photos/4927358/pexels-photo-4927358.jpeg?cs=srgb&dl=pexels-anntarazevich-4927358.jpg&fm=jpg&w=1280&h=1920",
index=3
)

# Add algorithm
algo = wf.add_task(name="infer_pulid", auto_connect=False)

# Connect inputs
wf.connect_tasks(wf.root(), algo, [(0,0), (1,1), (2,2), (3,3)])

# Set parameters
algo.set_parameters({
'prompt': 'portrait, color, cinematic, in garden, soft light, detailed face, wonderwoman costum, golden boomerang tiara, short hair',
'guidance_scale': '1.2',
'guidance_scale_id': '0.8',
'num_inference_steps': '4',
'seed': '-1',
'width': '1024',
'height': '1024',
'mode': 'fidelity',
'num_images_per_prompt':'2',
'mix_id' : 'False'
})

# Run your workflow
wf.run()

# Inpect your result
display(algo.get_output(0).get_image())
display(algo.get_output(1).get_image())

🔍 Explore algorithm outputs

Every algorithm produces specific outputs, yet they can be explored them the same way using the Ikomia API. For a more in-depth understanding of managing algorithm outputs, please refer to the documentation.

from ikomia.dataprocess.workflow import Workflow

# Init your workflow
wf = Workflow()

# Add algorithm
algo = wf.add_task(name="infer_pulid", auto_connect=True)

# Run on your image
wf.run_on(url="https://images.pexels.com/photos/4927360/pexels-photo-4927360.jpeg?cs=srgb&dl=pexels-anntarazevich-4927360.jpg&fm=jpg&w=1280&h=1920")

# Iterate over outputs
for output in algo.get_outputs():
# Print information
print(output)
# Export it to JSON
output.to_json()

Troubleshooting

If you encounter issues while installing Insightface on Windows, please follow this guide.

Developer

  • Ikomia
    Ikomia

License

Apache License 2.0
Read license full text

A permissive license whose main conditions require preservation of copyright and license notices. Contributors provide an express grant of patent rights. Licensed works, modifications, and larger works may be distributed under different terms and without source code.

PermissionsConditionsLimitations

Commercial use

License and copyright notice

Trademark use

Modification

State changes

Liability

Distribution

Warranty

Patent use

Private use

This is not legal advice: this description is for informational purposes only and does not constitute the license itself. Provided by choosealicense.com.