Code Monkey home page Code Monkey logo

diffusionlight's Introduction

DiffusionLight: Light Probes for Free by Painting a Chrome Ball

Open DiffusionLight in Colab

We present a simple yet effective technique to estimate lighting in a single input image. Current techniques rely heavily on HDR panorama datasets to train neural networks to regress an input with limited field-of-view to a full environment map. However, these approaches often struggle with real-world, uncontrolled settings due to the limited diversity and size of their datasets. To address this problem, we leverage diffusion models trained on billions of standard images to render a chrome ball into the input image. Despite its simplicity, this task remains challenging: the diffusion models often insert incorrect or inconsistent objects and cannot readily generate images in HDR format. Our research uncovers a surprising relationship between the appearance of chrome balls and the initial diffusion noise map, which we utilize to consistently generate high-quality chrome balls. We further fine-tune an LDR diffusion model (Stable Diffusion XL) with LoRA, enabling it to perform exposure bracketing for HDR light estimation. Our method produces convincing light estimates across diverse settings and demonstrates superior generalization to in-the-wild scenarios.

Table of contents



Getting started

conda env create -f environment.yml
conda activate diffusionlight
pip install -r requirements.txt
python inpaint.py --dataset example --output_dir output
python ball2envmap.py --ball_dir output/square --envmap_dir output/envmap
python exposure2hdr.py --input_dir output/envmap --output_dir output/hdr

Installation

To setup the Python environment, you need to run the following commands in both Conda and pip:

conda env create -f environment.yml
conda activate diffusionlight
pip install -r requirements.txt

Note that Conda is optional. However, if you choose not to use Conda, you must manually install CUDA-toolkit and OpenEXR.

Prediction

0. Preparing the image

Please resize the input image to 1024x1024. If the image is not square, we recommend padding it with a black border.

1. Inpainting the chrome ball

First, we predict the chrome ball in different exposure values (EV) using the following command:

python inpaint.py --dataset <input_directory> --output_dir <output_directory>

This command outputs three subdirectories: control, raw, and square

The contents of each directory are:

  • control: Conditioned depth map
  • raw: Inpainted image with a chrome ball in the center
  • square: Square-cropped chrome ball (used for the next step)

2. Projecting a ball into an environment map

Next, we project the chrome ball from the previous step to the LDR environment map using the following command:

python ball2envmap.py --ball_dir <output_directory>/square --envmap_dir <output_directory>/envmap

3. Compose HDR image

Finally, we compose an HDR image from multiple LDR environment maps using our custom exposure bracketing:

python exposure2hdr.py --input_dir <output_directory>/envmap --output_dir <output_directory>/hdr

The predicted light estimation will be located at <output_directory>/hdr and can be used for downstream tasks such as object insertion. We will also use it to compare with other methods.

Evaluation

We use the evaluation code from StyleLight and Editable Indoor LightEstimation. You can use their code to measure our score.

Additionally, we provide a slightly modified version of the evaluation code at DiffusionLight-evaluation including the test input.

Citation

@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: Light Probes for Free by Painting a Chrome Ball},
    booktitle = {ArXiv},
    year = {2023},
}

Visit us ๐Ÿฆ‰

Vision & Learning Laboratory VISTEC - Vidyasirimedhi Institute of Science and Technology

diffusionlight's People

Contributors

pureexe avatar patriciogonzalezvivo avatar eltociear avatar

Stargazers

Seth Hall avatar Sala28 / 28.room avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.