briaai / BRIA-2.3-ID_Preservation

huggingface.co
Total runs: 0
24-hour runs: 0
7-day runs: 0
30-day runs: 0
Model's Last Updated: January 14 2025
text-to-image

Introduction of BRIA-2.3-ID_Preservation

Model Details of BRIA-2.3-ID_Preservation

BRIA 2.3 ID preservation Adapter

BRIA 2.3 ID preservation Adapter is a model designed to allows various style transfer operations or tweaks on facial image using textual prompts. The model is fully compatible with auxiliary models like ControlNets and LoRAs, enabling seamless integration into existing workflows.

Trained exclusively on the largest multi-source commercial-grade licensed dataset, BRIA 2.3 ID preservation Adapter guarantees best quality while safe for commercial use. The model provides full legal liability coverage for copyright and privacy infrigement and harmful content mitigation, as our dataset does not represent copyrighted materials, such as fictional characters, logos or trademarks, public figures, harmful content or privacy infringing content.

This model is optimized to work sseamlessly in high resolution, upper body part facial images.

Join our Discord community for more information, tutorials, tools, and to connect with other users!

What's New

BRIA 2.3 ID preservation Adapter can be applied on top of BRIA 2.3 Text-to-Image and therefore enable to use BRIA auxiliary models.

Model Description
  • Developed by: BRIA AI
  • Model type: Latent diffusion image-to-image model
  • License: bria-2.3 inpainting Licensing terms & conditions .
  • Purchase is required to license and access the model.
  • Model Description: BRIA 2.3 ID preservation Adapter was trained exclusively on a professional-grade, licensed dataset. It is designed for commercial use and includes full legal liability coverage.
  • Resources for more information: BRIA AI
Get Access to the source code and pre-trained model

Interested in BRIA 2.3 ID preservation Adapter? Our Model is available for purchase.

Purchasing access to BRIA 2.3 ID preservation Adapter ensures royalty management and full liability for commercial use.

Are you a startup or a student? We encourage you to apply for our specialized Academia and Startup Programs to gain access. These programs are designed to support emerging businesses and academic pursuits with our cutting-edge technology.

Contact us today to unlock the potential of BRIA 2.3 ID preservation Adapter!

By submitting the form above, you agree to BRIA’s Privacy policy and Terms & conditions .

Best practices:
  1. In your text prompt, start with a short description of the person in the image e.g., A Caucasian female with brown eyes and gray long hair.
  2. Use a protrait image with large face (~20-80% of the image).
  3. Use clean background (or use Bria's RMBG) - this will help you with the canny condition.
  4. You can add style images, and apply using Bria's IP adapter
  5. You can train your own LoRA on your desired style and use within this model.
How To Use
opencv-python==4.10.0.84
torch==2.4.0
torchvision==0.19.0
pillow==10.4.0
transformers==4.43.4
diffusers==0.29.2
insightface==0.7.3
onnx==1.16.2
onnxruntime==1.18.1
import gc
import os
import random
import gradio as gr

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

from transformers import CLIPVisionModelWithProjection
from diffusers.models import ControlNetModel

from huggingface_hub import snapshot_download

from insightface.app import FaceAnalysis

import io
import spaces

from pipeline_stable_diffusion_xl_instantid import StableDiffusionXLInstantIDPipeline, draw_kps

import pandas as pd
import json
import requests
from io import BytesIO
from huggingface_hub import hf_hub_download, HfApi


def resize_img(input_image, max_side=1280, min_side=1024, size=None, 
               pad_to_max_side=False, mode=Image.BILINEAR, base_pixel_number=64):
    
    w, h = input_image.size
    if size is not None:
        w_resize_new, h_resize_new = size
    else:
        ratio = min_side / min(h, w)
        w, h = round(ratio*w), round(ratio*h)
        ratio = max_side / max(h, w)
        input_image = input_image.resize([round(ratio*w), round(ratio*h)], mode)
        w_resize_new = (round(ratio * w) // base_pixel_number) * base_pixel_number
        h_resize_new = (round(ratio * h) // base_pixel_number) * base_pixel_number
    input_image = input_image.resize([w_resize_new, h_resize_new], mode)

    if pad_to_max_side:
        res = np.ones([max_side, max_side, 3], dtype=np.uint8) * 255
        offset_x = (max_side - w_resize_new) // 2
        offset_y = (max_side - h_resize_new) // 2
        res[offset_y:offset_y+h_resize_new, offset_x:offset_x+w_resize_new] = np.array(input_image)
        input_image = Image.fromarray(res)
    return input_image


def make_canny_condition(image, min_val=100, max_val=200, w_bilateral=True):
    if w_bilateral:
        image = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2GRAY)
        bilateral_filtered_image = cv2.bilateralFilter(image, d=9, sigmaColor=75, sigmaSpace=75)
        image = cv2.Canny(bilateral_filtered_image, min_val, max_val)
    else:
        image = np.array(image)
        image = cv2.Canny(image, min_val, max_val)
    image = image[:, :, None]
    image = np.concatenate([image, image, image], axis=2)
    image = Image.fromarray(image)
    return image


default_negative_prompt = "Logo,Watermark,Text,Ugly,Morbid,Extra fingers,Poorly drawn hands,Mutation,Blurry,Extra limbs,Gross proportions,Missing arms,Mutated hands,Long neck,Duplicate,Mutilated,Mutilated hands,Poorly drawn face,Deformed,Bad anatomy,Cloned face,Malformed limbs,Missing legs,Too many fingers"

# Download face encoder
snapshot_download(
    "fal/AuraFace-v1",
    local_dir="models/auraface",
)

app = FaceAnalysis(
    name="auraface",
    providers=["CUDAExecutionProvider", "CPUExecutionProvider"],
    root=".",
)

app.prepare(ctx_id=0, det_size=(640, 640))


# download checkpoints
print("Downloading checkpoints")
hf_hub_download(repo_id="briaai/ID_preservation_2.3_auraFaceEnc", filename="checkpoint_105000/controlnet/config.json", local_dir="./checkpoints")
hf_hub_download(repo_id="briaai/ID_preservation_2.3_auraFaceEnc", filename="checkpoint_105000/controlnet/diffusion_pytorch_model.safetensors", local_dir="./checkpoints")
hf_hub_download(repo_id="briaai/ID_preservation_2.3_auraFaceEnc", filename="checkpoint_105000/ip-adapter.bin", local_dir="./checkpoints")
hf_hub_download(repo_id="briaai/ID_preservation_2.3_auraFaceEnc", filename="image_encoder/pytorch_model.bin", local_dir="./checkpoints")
hf_hub_download(repo_id="briaai/ID_preservation_2.3_auraFaceEnc", filename="image_encoder/config.json", local_dir="./checkpoints")


device = "cuda" if torch.cuda.is_available() else "cpu"

# ckpts paths
face_adapter = f"./checkpoints/checkpoint_105000/ip-adapter.bin"
controlnet_path = f"./checkpoints/checkpoint_105000/controlnet"
base_model_path = f'briaai/BRIA-2.3'
resolution = 1024

# Load ControlNet models
controlnet_lnmks = ControlNetModel.from_pretrained(controlnet_path, torch_dtype=torch.float16)
controlnet_canny = ControlNetModel.from_pretrained("briaai/BRIA-2.3-ControlNet-Canny",
                                                torch_dtype=torch.float16)
    
controlnet = [controlnet_lnmks, controlnet_canny]


image_encoder = CLIPVisionModelWithProjection.from_pretrained(
        f"./checkpoints/image_encoder",
        torch_dtype=torch.float16,
    )
pipe = StableDiffusionXLInstantIDPipeline.from_pretrained(
        base_model_path,
        controlnet=controlnet,
        torch_dtype=torch.float16,
        image_encoder=image_encoder # For compatibility issues - needs to be there
    )

pipe = pipe.to(device)

pipe.use_native_ip_adapter=True

pipe.load_ip_adapter_instantid(face_adapter)

clip_embeds=None


image_path = "<define a path to image>"
img = Image.open(image_path)

prompt = "A male with brown eyes, gray hair, short hair, and wearing sunglasses."
face_image = resize_img(face_image_orig, max_side=resolution, min_side=resolution)
face_image_padded = resize_img(face_image_orig, max_side=resolution, min_side=resolution, pad_to_max_side=True)
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'])


# ================= Parameters =================
kps_scale = 0.6
canny_scale = 0.4
ip_adapter_scale = 0.8

if canny_scale>0.0:
  canny_img = make_canny_condition(face_image, min_val=20, max_val=40, w_bilateral=True)
                
generator = torch.Generator(device=device).manual_seed(seed)


images = pipe(
    prompt = full_prompt,
    negative_prompt = default_negative_prompt,
    image_embeds = face_emb,
    image = [face_kps, canny_img] if canny_scale > 0.0 else face_kps,
    controlnet_conditioning_scale = [kps_scale, canny_scale] if canny_scale>0.0 else kps_scale,
    ip_adapter_scale = ip_adapter_scale,
    num_inference_steps = num_steps,
    guidance_scale = guidance_scale,
    generator = generator,
    visual_prompt_embds = clip_embeds,
    cross_attention_kwargs = None,
    num_images_per_prompt=num_images,
).images[0]

Runs of briaai BRIA-2.3-ID_Preservation on huggingface.co

0
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
0
30-day runs

More Information About BRIA-2.3-ID_Preservation huggingface.co Model

More BRIA-2.3-ID_Preservation license Visit here:

https://choosealicense.com/licenses/bria-2.3

BRIA-2.3-ID_Preservation huggingface.co

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

BRIA-2.3-ID_Preservation huggingface.co Url

https://huggingface.co/briaai/BRIA-2.3-ID_Preservation

briaai BRIA-2.3-ID_Preservation online free

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

briaai BRIA-2.3-ID_Preservation online free url in huggingface.co:

https://huggingface.co/briaai/BRIA-2.3-ID_Preservation

BRIA-2.3-ID_Preservation install

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

BRIA-2.3-ID_Preservation install url in huggingface.co:

https://huggingface.co/briaai/BRIA-2.3-ID_Preservation

Url of BRIA-2.3-ID_Preservation

BRIA-2.3-ID_Preservation huggingface.co Url

Provider of BRIA-2.3-ID_Preservation huggingface.co

briaai
ORGANIZATIONS

Other API from briaai

huggingface.co

Total runs: 392.5K
Run Growth: -254.9K
Growth Rate: -64.94%
Updated:April 06 2026
huggingface.co

Total runs: 263.1K
Run Growth: -108.0K
Growth Rate: -41.03%
Updated:July 06 2025
huggingface.co

Total runs: 3.2K
Run Growth: -399
Growth Rate: -11.00%
Updated:October 29 2025
huggingface.co

Total runs: 777
Run Growth: 135
Growth Rate: 14.06%
Updated:July 05 2026
huggingface.co

Total runs: 629
Run Growth: -312
Growth Rate: -44.32%
Updated:September 09 2026
huggingface.co

Total runs: 538
Run Growth: -515
Growth Rate: -97.17%
Updated:August 18 2026
huggingface.co

Total runs: 301
Run Growth: 618
Growth Rate: 82.40%
Updated:January 30 2026
huggingface.co

Total runs: 235
Run Growth: 0
Growth Rate: 0.00%
Updated:May 12 2024
huggingface.co

Total runs: 211
Run Growth: 126
Growth Rate: 59.72%
Updated:September 05 2026
huggingface.co

Total runs: 135
Run Growth: 85
Growth Rate: 62.96%
Updated:September 01 2025
huggingface.co

Total runs: 131
Run Growth: 0
Growth Rate: 0.00%
Updated:August 04 2024
huggingface.co

Total runs: 104
Run Growth: 39
Growth Rate: 37.50%
Updated:October 16 2025
huggingface.co

Total runs: 67
Run Growth: -9
Growth Rate: -13.24%
Updated:January 15 2026
huggingface.co

Total runs: 46
Run Growth: 0
Growth Rate: 0.00%
Updated:May 12 2024
huggingface.co

Total runs: 30
Run Growth: 0
Growth Rate: 0.00%
Updated:March 13 2024
huggingface.co

Total runs: 28
Run Growth: 28
Growth Rate: 100.00%
Updated:April 10 2025
huggingface.co

Total runs: 9
Run Growth: -6
Growth Rate: -66.67%
Updated:June 11 2025
huggingface.co

Total runs: 4
Run Growth: 0
Growth Rate: 0.00%
Updated:November 19 2024
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:March 18 2024
huggingface.co

Total runs: 0
Run Growth: -2
Growth Rate: 0.00%
Updated:April 10 2025
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:April 08 2025
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:December 11 2025
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:July 16 2026
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:March 25 2026
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:August 19 2026