BRIA-2.3-ControlNet-Depth
BRIA 2.3 ControlNet-Depth, entrenado sobre la base del modelo BRIA 2.3 Text-to-Image, permite la generación de imágenes de alta calidad guiadas por una indicación textual y la estimación de profundidad monocular extraída de una imagen de entrada. Esto permite la creación de diferentes variaciones de una imagen, todas compartiendo la misma geometría. BRIA 2.3 fue entrenado desde cero exclusivamente con datos licenciados de nuestros estimados socios de datos. Por lo tanto, es seguro para uso comercial y proporciona cobertura total de responsabilidad legal por infracción de derechos de autor y privacidad, así como mitigación de contenido dañino. Es decir, nuestro conjunto de datos no contiene materiales con derechos de autor, como personajes ficticios, logotipos, marcas registradas, figuras públicas, contenido nocivo o contenido que infrinja la privacidad.
Como usar
Ejemplo de código usando Diffusers
pip install diffusers
from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline
import torch
from transformers import DPTFeatureExtractor, DPTForDepthEstimation
depth_estimator = DPTForDepthEstimation.from_pretrained("Intel/dpt-hybrid-midas").to("cuda")
feature_extractor = DPTFeatureExtractor.from_pretrained("Intel/dpt-hybrid-midas")
def get_depth_map(image):
image = feature_extractor(images=image, return_tensors="pt").pixel_values.to("cuda")
with torch.no_grad(), torch.autocast("cuda"):
depth_map = depth_estimator(image).predicted_depth
image = transforms.functional.center_crop(image, min(image.shape[-2:]))
depth_map = torch.nn.functional.interpolate(
depth_map.unsqueeze(1),
size=(1024, 1024),
mode="bicubic",
align_corners=False,
)
depth_min = torch.amin(depth_map, dim=[1, 2, 3], keepdim=True)
depth_max = torch.amax(depth_map, dim=[1, 2, 3], keepdim=True)
depth_map = (depth_map - depth_min) / (depth_max - depth_min)
image = torch.cat([depth_map] * 3, dim=1)
image = image.permute(0, 2, 3, 1).cpu().numpy()[0]
image = Image.fromarray((image * 255.0).clip(0, 255).astype(np.uint8))
return image
controlnet = ControlNetModel.from_pretrained(
"briaai/BRIA-2.3-ControlNet-Depth",
torch_dtype=torch.float16
)
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
"briaai/BRIA-2.3",
controlnet=controlnet,
torch_dtype=torch.float16,
)
pipe.to("cuda")
prompt = "A portrait of a Beautiful and playful ethereal singer, golden designs, highly detailed, blurry background"
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"
# Calculate Depth image
input_image = cv2.imread('pics/singer.png')
depth_image = get_depth_map(input_image)
image = pipe(prompt=prompt, negative_prompt=negative_prompt, image=depth_image, controlnet_conditioning_scale=1.0, height=1024, width=1024).images[0]
Funcionalidades
- Generación de imágenes guiada por texto
- Estimación de profundidad monocular
- Creación de variaciones de una imagen compartiendo la misma geometría
- Entrenado con datos licenciados
- Seguro para uso comercial
- Cobertura total de responsabilidad legal
Casos de uso
- Generación de retratos artísticos
- Creación de variaciones de imágenes para publicidad
- Visualización de diseños conceptuales
- Creación de contenido visual creativo