black-forest-labs/FLUX.1-Canny-dev
FLUX.1 Canny [dev] 是一个 120 亿参数的整流变换器,能够根据文本描述生成图像,同时遵循给定输入图像的结构。
主要功能
- 尖端的输出质量。
- 它将令人印象深刻的及时性与基于 Canny 边缘的源图像结构保持相结合。
- 使用引导蒸馏法进行训练,使 FLUX.1 Canny [dev] 更为高效。
- 开放权重可推动新的科学研究,并增强艺术家开发创新工作流程的能力。
- 生成的输出可用于 FLUX.1 [dev] 非商业许可中所述的个人、科学和商业目的。
使用
要将 FLUX.1-Canny-dev 与 🧨 diffusers python 库一起使用,首先要安装或升级 diffusers 和 controlnet_aux。
pip install -U diffusers controlnet_aux
然后可以使用 FluxControlPipeline 运行模型
import torch
from controlnet_aux import CannyDetector
from diffusers import FluxControlPipeline
from diffusers.utils import load_image
pipe = FluxControlPipeline.from_pretrained("black-forest-labs/FLUX.1-Canny-dev", torch_dtype=torch.bfloat16).to("cuda")
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 = CannyDetector()
control_image = processor(control_image, low_threshold=50, high_threshold=200, detect_resolution=1024, image_resolution=1024)
image = pipe(
prompt=prompt,
control_image=control_image,
height=1024,
width=1024,
num_inference_steps=50,
guidance_scale=30.0,
).images[0]
image.save("output.png")
使用 cpu offload 可以让模型运行在消费级显卡中。
black-forest-labs/FLUX.1-Depth-dev
FLUX.1 深度[dev]是一个 120 亿参数的整流变换器,能够根据文本描述生成图像,同时遵循给定输入图像的结构。
主要功能
- 尖端的输出质量。
- 它将令人印象深刻的及时性与保持基于深度图的源图像结构相结合。
- 使用引导蒸馏法进行训练,使 FLUX.1 深度[开发]更加高效。
- 开放权重以推动新的科学研究,并授权艺术家开发创新的工作流程。
- 根据 FLUX.1 深度[开发]非商业许可证的规定,生成的输出可用于个人、科学和商业目的。
使用
要使用 FLUX.1-Depth-dev 和 🧨 diffusers python 库,首先要安装或升级 diffusers 和 image_gen_aux。
pip install -U diffusers
pip install git+https://github.com/asomoza/image_gen_aux.git
然后可以使用 FluxControlPipeline 运行模型
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-Depth-dev", torch_dtype=torch.bfloat16).to("cuda")
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")
使用 cpu offload 可以让模型运行在消费级显卡中。