This repository is the official implementation of FLUX-customID. It is capable of generating images based on your face image at a level equivalent to real photographic quality. Our base model is FLUX.dev, which ensures the generation of high-quality images.
- 🌟2024-11-13: Released the code and weights for FLUX-customID.
Here are some example samples generated by our method.
conda create -n customID python=3.10 -y
conda activate customID
conda install pytorch==2.4.0 torchvision==0.19.0 pytorch-cuda=11.8 -c pytorch -c nvidia -y
pip install -i https://mirrors.cloud.tencent.com/pypi/simple diffusers==0.31.0 transformers onnxruntime-gpu insightface sentencepiece matplotlib imageio tqdm numpy einops accelerate peft
git clone https://github.com/damo-cv/FLUX-customID.git
cd FLUX-customID
mkdir pretrained_ckpt
cd pretrained_ckpt
#Download CLIP
export HF_ENDPOINT=https://hf-mirror.com
pip install -U "huggingface_hub[cli]"
huggingface-cli download \
--resume-download "laion/CLIP-ViT-H-14-laion2B-s32B-b79K" \
--cache-dir your_dir/
ln -s your_dir/models--laion--CLIP-ViT-H-14-laion2B-s32B-b79K/snapshots/de081ac0a0ca8dc9d1533eed1ae884bb8ae1404b pretrained_ckpt/openclip-vit-h-14
#Download FLUX.1-dev
huggingface-cli download \
--resume-download "black-forest-labs/FLUX.1-dev" \
--cache-dir your_dir/
ln -s your_dir/models--black-forest-labs--FLUX.1-dev/snapshots/303875135fff3f05b6aa893d544f28833a237d58 pretrained_ckpt/flux.1-dev
#Download FLUX-customID
Download our trained checkpoint from https://huggingface.co/Damo-vision/FLUX-customID and place FLUX-customID.pt in the floder pretrained_ckpt/
run infer_customID.ipynb
For production deployments or scaling to multiple users, we provide a RunPod serverless implementation.
- Automatic scaling based on demand
- GPU acceleration with NVIDIA A5000 or better
- Persistent model storage
- RESTful API endpoint
- Detailed logging and monitoring
- Follow the detailed instructions in RUNPOD_DEPLOYMENT.md
- Key requirements:
- RunPod account
- 80GB storage volume for models
- NVIDIA GPU (16GB+ VRAM)
import requests
import base64
def encode_image(image_path):
with open(image_path, "rb") as f:
return base64.b64encode(f.read()).decode('utf-8')
# Replace with your endpoint URL
endpoint = "https://your-endpoint.runpod.net"
image = encode_image("path/to/your/image.jpg")
response = requests.post(endpoint, json={
"input": {
"image": image,
"prompt": "professional ID photo",
"num_samples": 1,
"height": 1024,
"width": 1024
}
})
# Response includes base64-encoded generated images
result = response.json()
For detailed deployment instructions and troubleshooting, see RUNPOD_DEPLOYMENT.md
We would like to announce that we are currently working on a related project, CustomAnyID. Below are some preliminary experimental results:
We would like to announce our Controlnet model. Below are some preliminary experimental results:
- Python 3.10
- CUDA 11.8
- 16GB+ GPU VRAM
- 32GB+ System RAM
- NVIDIA A5000 or better GPU
- 80GB storage volume
- 20GB container disk
Dongyang Li: [email protected]
The partial code is implemented based on IP-Adapter and PhotoMaker.