Run this model with HF Jobs
Run beardedTechExec/InstantID on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/beardedTechExec/InstantID. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/beardedTechExec/InstantID on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use beardedTechExec/InstantID with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use beardedTechExec/InstantID with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("beardedTechExec/InstantID", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Commit ·
eeb2daa
0
Parent(s):
Duplicate from InstantX/InstantID
Browse filesCo-authored-by: Haofan Wang <wanghaofan@users.noreply.huggingface.co>
Files changed (8)
- .gitattributesAdded+38
- ControlNetModel/config.jsonAdded+57
- ControlNetModel/diffusion_pytorch_model.safetensorsAdded+3
- README.mdAdded+128
- examples/0.pngAdded
- examples/1.pngAdded
- examples/applications.pngAdded
- ip-adapter.binAdded+3
1234567891011121314151617181920212223242526272829303132333435363738*.7z filter=lfs diff=lfs merge=lfs -text*.arrow filter=lfs diff=lfs merge=lfs -text*.bin filter=lfs diff=lfs merge=lfs -text*.bz2 filter=lfs diff=lfs merge=lfs -text*.ckpt filter=lfs diff=lfs merge=lfs -text*.ftz filter=lfs diff=lfs merge=lfs -text*.gz filter=lfs diff=lfs merge=lfs -text*.h5 filter=lfs diff=lfs merge=lfs -text*.joblib filter=lfs diff=lfs merge=lfs -text*.lfs.* filter=lfs diff=lfs merge=lfs -text*.mlmodel filter=lfs diff=lfs merge=lfs -text*.model filter=lfs diff=lfs merge=lfs -text*.msgpack filter=lfs diff=lfs merge=lfs -text*.npy filter=lfs diff=lfs merge=lfs -text*.npz filter=lfs diff=lfs merge=lfs -text*.onnx filter=lfs diff=lfs merge=lfs -text*.ot filter=lfs diff=lfs merge=lfs -text*.parquet filter=lfs diff=lfs merge=lfs -text*.pb filter=lfs diff=lfs merge=lfs -text*.pickle filter=lfs diff=lfs merge=lfs -text*.pkl filter=lfs diff=lfs merge=lfs -text*.pt filter=lfs diff=lfs merge=lfs -text*.pth filter=lfs diff=lfs merge=lfs -text*.rar filter=lfs diff=lfs merge=lfs -text*.safetensors filter=lfs diff=lfs merge=lfs -textsaved_model/**/* filter=lfs diff=lfs merge=lfs -text*.tar.* filter=lfs diff=lfs merge=lfs -text*.tar filter=lfs diff=lfs merge=lfs -text*.tflite filter=lfs diff=lfs merge=lfs -text*.tgz filter=lfs diff=lfs merge=lfs -text*.wasm filter=lfs diff=lfs merge=lfs -text*.xz filter=lfs diff=lfs merge=lfs -text*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textexamples/0.png filter=lfs diff=lfs merge=lfs -textexamples/1.png filter=lfs diff=lfs merge=lfs -textexamples/applications.png filter=lfs diff=lfs merge=lfs -text123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657{ "_class_name": "ControlNetModel", "_diffusers_version": "0.21.2", "_name_or_path": "/mnt/nj-aigc/usr/guiwan/workspace/diffusion_output/face_xl_ipc_v4_2_XiezhenAnimeForeigner/checkpoint-150000/ControlNetModel", "act_fn": "silu", "addition_embed_type": "text_time", "addition_embed_type_num_heads": 64, "addition_time_embed_dim": 256, "attention_head_dim": [ 5, 10, 20 ], "block_out_channels": [ 320, 640, 1280 ], "class_embed_type": null, "conditioning_channels": 3, "conditioning_embedding_out_channels": [ 16, 32, 96, 256 ], "controlnet_conditioning_channel_order": "rgb", "cross_attention_dim": 2048, "down_block_types": [ "DownBlock2D", "CrossAttnDownBlock2D", "CrossAttnDownBlock2D" ], "downsample_padding": 1, "encoder_hid_dim": null, "encoder_hid_dim_type": null, "flip_sin_to_cos": true, "freq_shift": 0, "global_pool_conditions": false, "in_channels": 4, "layers_per_block": 2, "mid_block_scale_factor": 1, "norm_eps": 1e-05, "norm_num_groups": 32, "num_attention_heads": null, "num_class_embeds": null, "only_cross_attention": false, "projection_class_embeddings_input_dim": 2816, "resnet_time_scale_shift": "default", "transformer_layers_per_block": [ 1, 2, 10 ], "upcast_attention": null, "use_linear_projection": true}123version https://git-lfs.github.com/spec/v1oid sha256:c8127be9f174101ebdafee9964d856b49b634435cf6daa396d3f593cf0bbbb05size 2502139136123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128---license: apache-2.0language:- enlibrary_name: diffuserspipeline_tag: text-to-image---
# InstantID Model Card
<div align="center">
[**Project Page**](https://instantid.github.io/) **|** [**Paper**](https://arxiv.org/abs/2401.07519) **|** [**Code**](https://github.com/InstantID/InstantID) **|** [🤗 **Gradio demo**](https://huggingface.co/spaces/InstantX/InstantID)
</div>
## 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.
<div align="center"><img src='examples/applications.png'></div>
## Usage
You can directly download the model in this repository.You also can download the model in python script:
```pythonfrom huggingface_hub import hf_hub_downloadhf_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](https://github.com/deepinsight/insightface/issues/1896#issuecomment-1023867304) to `models/antelopev2`.
```python# !pip install opencv-python transformers accelerate insightfaceimport diffusersfrom diffusers.utils import load_imagefrom diffusers.models import ControlNetModel
import cv2import torchimport numpy as npfrom PIL import Image
from insightface.app import FaceAnalysisfrom pipeline_stable_diffusion_xl_instantid import StableDiffusionXLInstantIDPipeline, draw_kps
# prepare 'antelopev2' under ./modelsapp = FaceAnalysis(name='antelopev2', root='./', providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])app.prepare(ctx_id=0, det_size=(640, 640))
# prepare models under ./checkpointsface_adapter = f'./checkpoints/ip-adapter.bin'controlnet_path = f'./checkpoints/ControlNetModel'
# load IdentityNetcontrolnet = 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 adapterpipe.load_ip_adapter_instantid(face_adapter)```
Then, you can customized your own face images
```python# load an imageimage = load_image("your-example.jpg")
# prepare face embface_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 faceface_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 imageimage = 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](https://github.com/InstantID/InstantID).
## Usage Tips1. 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
<div align="center"><img src='examples/0.png'></div>
<div align="center"><img src='examples/1.png'></div>
## 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```bibtex@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}}```123version https://git-lfs.github.com/spec/v1oid sha256:02b3618e36d803784166660520098089a81388e61a93ef8002aa79a5b1c546e1size 1691134141.gitattributesAdded+38
ControlNetModel/config.jsonAdded+57
ControlNetModel/diffusion_pytorch_model.safetensorsAdded+3
README.mdAdded+128
examples/0.pngAdded

Large File Pointer Details
- SHA256: b02e16d938c007409c19783d494737230fe7eb890ac60b08267f0f46b9f17f6e
- Pointer size: 132 Bytes
- Size of remote file: 8.71 MB
examples/1.pngAdded

Large File Pointer Details
- SHA256: f20e80f08c8efd2ac74ed93070851bea677489643dee8a28912fcd06b56348d2
- Pointer size: 132 Bytes
- Size of remote file: 8.47 MB
examples/applications.pngAdded

Large File Pointer Details
- SHA256: 59fd297f4b20fcbc51fb100e40bed33a5d27e2b7351576d12f03d34c7608eb88
- Pointer size: 133 Bytes
- Size of remote file: 10.7 MB
ip-adapter.binAdded+3