标签:
- 图像到图像
- StableDiffusionXLControlNetInpaintPipeline
- stable-diffusion-xl
- lora
- diffusers
- 模板:sd-lora
- 图像修复
- 光照估计
- 重光照
基础模型: stabilityai/stable-diffusion-xl-base-1.0
实例提示: >-
一个完美镜面反射的铬球体,一个完美黑色暗调镜面反射的铬球体
许可证: mit
管道标签: 图像到图像
推理: false
DiffusionLight: 通过绘制铬球免费获取光照探针
项目页面 | 论文 | Github | Colab


我们提出了一种简单而有效的技术,用于在单张输入图像中估计光照。当前技术严重依赖HDR全景数据集来训练神经网络,将有限视野的输入回归为完整的环境贴图。然而,由于这些数据集的多样性和规模有限,这些方法在现实世界不受控制的环境中往往表现不佳。为了解决这个问题,我们利用在数十亿标准图像上训练的扩散模型,将铬球渲染到输入图像中。尽管任务看似简单,但仍具挑战性:扩散模型常会插入不正确或不一致的物体,且难以直接生成HDR格式的图像。我们的研究揭示了铬球外观与初始扩散噪声图之间的惊人关系,并利用这一关系一致生成高质量的铬球。我们进一步通过LoRA对LDR扩散模型(Stable Diffusion XL)进行微调,使其能够执行曝光包围以实现HDR光照估计。我们的方法在多样化环境中产生令人信服的光照估计,并展示了对野外场景的卓越泛化能力。
使用方法
我们推荐查看Github仓库:https://github.com/DiffusionLight/DiffusionLight,该仓库提供了从任何图像估计光照的代码。包括生成铬球、从铬球中提取环境贴图,以及使用我们自定义的曝光包围方法创建HDR环境贴图。
下载模型
该模型的权重以Safetensors格式提供。
在“文件与版本”选项卡中下载。
触发词
铬球类型 |
提示语 |
正常曝光 |
一个完美镜面反射的铬球体 |
欠曝光 |
一个完美黑色暗调镜面反射的铬球体 |
铬球生成
我们采用自定义流程来丰富铬球特性以满足需求。包括抗锯齿平滑边缘、迭代修复增强光照方向准确性,以及嵌入插值生成不同曝光的铬球。因此,我们强烈建议您访问我们的GitHub仓库。
但如果您希望仅使用此LoRA通过diffusers的现成代码生成铬球,可参考以下示例:
import torch
from diffusers.utils import load_image
from diffusers import StableDiffusionXLControlNetInpaintPipeline, ControlNetModel
from transformers import pipeline
from PIL import Image
import numpy as np
IS_UNDER_EXPOSURE = False
if IS_UNDER_EXPOSURE:
PROMPT = "一个完美黑色暗调镜面反射的铬球体"
else:
PROMPT = "一个完美镜面反射的铬球体"
NEGATIVE_PROMPT = "磨砂, 漫反射, 平坦, 暗淡"
IMAGE_URL = "https://raw.githubusercontent.com/DiffusionLight/DiffusionLight/main/example/bed.png"
controlnet = ControlNetModel.from_pretrained("diffusers/controlnet-depth-sdxl-1.0", torch_dtype=torch.float16)
pipe = StableDiffusionXLControlNetInpaintPipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
controlnet=controlnet,
torch_dtype=torch.float16,
).to("cuda")
pipe.load_lora_weights("DiffusionLight/DiffusionLight")
pipe.fuse_lora(lora_scale=0.75)
depth_estimator = pipeline(task="深度估计", model="Intel/dpt-large")
init_image = load_image(IMAGE_URL)
depth_image = depth_estimator(images=init_image)['深度图']
def get_circle_mask(size=256):
x = torch.linspace(-1, 1, size)
y = torch.linspace(1, -1, size)
y, x = torch.meshgrid(y, x)
z = (1 - x**2 - y**2)
mask = z >= 0
return mask
mask = get_circle_mask().numpy()
depth = np.asarray(depth_image).copy()
depth[384:640, 384:640] = depth[384:640, 384:640] * (1 - mask) + (mask * 255)
depth_mask = Image.fromarray(depth)
mask_image = np.zeros_like(depth)
mask_image[384:640, 384:640] = mask * 255
mask_image = Image.fromarray(mask_image)
output = pipe(
prompt=PROMPT,
negative_prompt=NEGATIVE_PROMPT,
num_inference_steps=30,
image=init_image,
mask_image=mask_image,
control_image=depth_mask,
controlnet_conditioning_scale=0.5,
)
output["images"][0].save("output.png")
引用
@inproceedings{Phongthawee2023DiffusionLight,
author = {Phongthawee, Pakkapon and Chinchuthakun, Worameth and Sinsunthithet, Nontaphat and Raj, Amit and Jampani, Varun and Khungurn, Pramook and Suwajanakorn, Supasorn},
title = {DiffusionLight: 通过绘制铬球免费获取光照探针},
booktitle = {ArXiv},
year = {2023},
}
访问我们 🦉
