black-forest-labs/FLUX.1-Depth-dev-lora · Hugging Face (original) (raw)

image/png

FLUX.1 Depth [dev] LoRA is a LoRA extracted from FLUX.1 Depth [dev], a 12 billion parameter rectified flow transformer capable of generating an image based on a text description while following the structure of a given input image. For more information, please read our blog post. The LoRA is applicable to FLUX.1 [dev].

Key Features

  1. Cutting-edge output quality.
  2. It blends impressive prompt adherence with maintaining the structure of source images based on depth maps.
  3. Trained using guidance distillation, making FLUX.1 Depth [dev] LoRA more efficient.
  4. Open weights to drive new scientific research, and empower artists to develop innovative workflows.
  5. Generated outputs can be used for personal, scientific, and commercial purposes as described in the FLUX.1 [dev] Non-Commercial License.

Usage

We provide a reference implementation of FLUX.1 Depth [dev], as well as sampling code, in a dedicated github repository. Developers and creatives looking to build on top of FLUX.1 Depth [dev] are encouraged to use this as a starting point.

API Endpoints

FLUX.1 Depth [pro] is available in our API bfl.ml

Diffusers

To use FLUX.1-Depth-dev-lora with the 🧨 diffusers python library, first install or upgrade diffusers, peft, and image_gen_aux.

pip install -U git+https://github.com/huggingface/diffusers
pip install git+https://github.com/asomoza/image_gen_aux.git
pip install -U peft

Then you can use the FluxControlPipeline to run it:

import torch
from diffusers import FluxControlPipeline, FluxTransformer2DModel
from diffusers.utils import load_image
from image_gen_aux import DepthPreprocessor

pipe = FluxControlPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16).to("cuda")
pipe.load_lora_weights("black-forest-labs/FLUX.1-Depth-dev-lora", adapter_name="depth")
pipe.set_adapters("depth", 0.85)

prompt = "A robot made of exotic candies and chocolates of different kinds. The background is filled with confetti and celebratory gifts."
control_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/robot.png")

processor = DepthPreprocessor.from_pretrained("LiheYoung/depth-anything-large-hf")
control_image = processor(control_image)[0].convert("RGB")

image = pipe(
    prompt=prompt,
    control_image=control_image,
    height=1024,
    width=1024,
    num_inference_steps=30,
    guidance_scale=10.0,
    generator=torch.Generator().manual_seed(42),
).images[0]
image.save("output.png")

To learn more, check out the diffusers documentation.


Limitations

Out-of-Scope Use

The model and its derivatives may not be used

License

This model falls under the FLUX.1 [dev] Non-Commercial License.