infer_pulid
About
Pure and Lightning ID customization (PuLID) is a novel tuning-free ID customization method for text-to-image generation.
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
🚀 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 Workflowfrom ikomia.utils.displayIO import display# Init your workflowwf = Workflow()# Add algorithmalgo = wf.add_task(name="infer_pulid", auto_connect=True)# Run on your imagewf.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 resultdisplay(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 than1
). - 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 Workflowfrom ikomia.utils.displayIO import display# Init your workflowwf = Workflow()# Set main imagewf.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 algorithmalgo = wf.add_task(name="infer_pulid", auto_connect=False)# Connect inputswf.connect_tasks(wf.root(), algo, [(0,0), (1,1), (2,2), (3,3)])# Set parametersalgo.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 workflowwf.run()# Inpect your resultdisplay(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 workflowwf = Workflow()# Add algorithmalgo = wf.add_task(name="infer_pulid", auto_connect=True)# Run on your imagewf.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 outputsfor output in algo.get_outputs():# Print informationprint(output)# Export it to JSONoutput.to_json()
⏩ Troubleshooting
If you encounter issues while installing Insightface on Windows, please follow this guide.
Developer
Ikomia
License
Apache License 2.0
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.
Permissions | Conditions | Limitations |
---|---|---|
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.