InstantX / InstantID

huggingface.co
Total runs: 61.0K
24-hour runs: 0
7-day runs: 2.5K
30-day runs: 2.1K
Model's Last Updated: January 22 2024
text-to-image

Introduction of InstantID

Model Details of InstantID

InstantID Model Card

Introduction

InstantID is a new state-of-the-art tuning-free method to achieve ID-Preserving generation with only single image, supporting various downstream tasks.

Usage

You can directly download the model in this repository. You also can download the model in python script:

from huggingface_hub import hf_hub_download
hf_hub_download(repo_id="InstantX/InstantID", filename="ControlNetModel/config.json", local_dir="./checkpoints")
hf_hub_download(repo_id="InstantX/InstantID", filename="ControlNetModel/diffusion_pytorch_model.safetensors", local_dir="./checkpoints")
hf_hub_download(repo_id="InstantX/InstantID", filename="ip-adapter.bin", local_dir="./checkpoints")

For face encoder, you need to manutally download via this URL to models/antelopev2 .

# !pip install opencv-python transformers accelerate insightface
import diffusers
from diffusers.utils import load_image
from diffusers.models import ControlNetModel

import cv2
import torch
import numpy as np
from PIL import Image

from insightface.app import FaceAnalysis
from pipeline_stable_diffusion_xl_instantid import StableDiffusionXLInstantIDPipeline, draw_kps

# prepare 'antelopev2' under ./models
app = FaceAnalysis(name='antelopev2', root='./', providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
app.prepare(ctx_id=0, det_size=(640, 640))

# prepare models under ./checkpoints
face_adapter = f'./checkpoints/ip-adapter.bin'
controlnet_path = f'./checkpoints/ControlNetModel'

# load IdentityNet
controlnet = ControlNetModel.from_pretrained(controlnet_path, torch_dtype=torch.float16)

pipe = StableDiffusionXLInstantIDPipeline.from_pretrained(
...     "stabilityai/stable-diffusion-xl-base-1.0", controlnet=controlnet, torch_dtype=torch.float16
... )
pipe.cuda()

# load adapter
pipe.load_ip_adapter_instantid(face_adapter)

Then, you can customized your own face images

# load an image
image = load_image("your-example.jpg")

# prepare face emb
face_info = app.get(cv2.cvtColor(np.array(face_image), cv2.COLOR_RGB2BGR))
face_info = sorted(face_info, key=lambda x:(x['bbox'][2]-x['bbox'][0])*x['bbox'][3]-x['bbox'][1])[-1] # only use the maximum face
face_emb = face_info['embedding']
face_kps = draw_kps(face_image, face_info['kps'])

pipe.set_ip_adapter_scale(0.8)

prompt = "analog film photo of a man. faded film, desaturated, 35mm photo, grainy, vignette, vintage, Kodachrome, Lomography, stained, highly detailed, found footage, masterpiece, best quality"
negative_prompt = "(lowres, low quality, worst quality:1.2), (text:1.2), watermark, painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured (lowres, low quality, worst quality:1.2), (text:1.2), watermark, painting, drawing, illustration, glitch,deformed, mutated, cross-eyed, ugly, disfigured"

# generate image
image = pipe(
...     prompt, image_embeds=face_emb, image=face_kps, controlnet_conditioning_scale=0.8
... ).images[0]

For more details, please follow the instructions in our GitHub repository .

Usage Tips
  1. If you're not satisfied with the similarity, try to increase the weight of "IdentityNet Strength" and "Adapter Strength".
  2. If you feel that the saturation is too high, first decrease the Adapter strength. If it is still too high, then decrease the IdentityNet strength.
  3. If you find that text control is not as expected, decrease Adapter strength.
  4. If you find that realistic style is not good enough, go for our Github repo and use a more realistic base model.
Demos
Disclaimer

This project is released under Apache License and aims to positively impact the field of AI-driven image generation. Users are granted the freedom to create images using this tool, but they are obligated to comply with local laws and utilize it responsibly. The developers will not assume any responsibility for potential misuse by users.

Citation
@article{wang2024instantid,
  title={InstantID: Zero-shot Identity-Preserving Generation in Seconds},
  author={Wang, Qixun and Bai, Xu and Wang, Haofan and Qin, Zekui and Chen, Anthony},
  journal={arXiv preprint arXiv:2401.07519},
  year={2024}
}

Runs of InstantX InstantID on huggingface.co

61.0K
Total runs
0
24-hour runs
2.4K
3-day runs
2.5K
7-day runs
2.1K
30-day runs

More Information About InstantID huggingface.co Model

More InstantID license Visit here:

https://choosealicense.com/licenses/apache-2.0

InstantID huggingface.co

InstantID huggingface.co is an AI model on huggingface.co that provides InstantID's model effect (), which can be used instantly with this InstantX InstantID model. huggingface.co supports a free trial of the InstantID model, and also provides paid use of the InstantID. Support call InstantID model through api, including Node.js, Python, http.

InstantX InstantID online free

InstantID huggingface.co is an online trial and call api platform, which integrates InstantID's modeling effects, including api services, and provides a free online trial of InstantID, you can try InstantID online for free by clicking the link below.

InstantX InstantID online free url in huggingface.co:

https://huggingface.co/InstantX/InstantID

InstantID install

InstantID is an open source model from GitHub that offers a free installation service, and any user can find InstantID on GitHub to install. At the same time, huggingface.co provides the effect of InstantID install, users can directly use InstantID installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

InstantID install url in huggingface.co:

https://huggingface.co/InstantX/InstantID

Url of InstantID

InstantID huggingface.co Url

Provider of InstantID huggingface.co

InstantX
ORGANIZATIONS

Other API from InstantX

huggingface.co

Total runs: 300
Run Growth: -130
Growth Rate: -43.33%
Updated:September 18 2024
huggingface.co

Total runs: 4
Run Growth: 0
Growth Rate: 0.00%
Updated:November 07 2024