StableNormal: Reducing Diffusion Variance for Stable and Sharp Normal

October 21, 2024 · View on GitHub

Chongjie Ye*, Lingteng Qiu*, Xiaodong Gu, Qi Zuo, Yushuang Wu, Zilong Dong, Liefeng Bo, Yuliang Xiu#, Xiaoguang Han#

* Equal contribution
# Corresponding Author

SIGGRAPH Asia 2024 (Journal Track)

Website Paper ModelScope Hugging Face Space Hugging Face Model License

We propose StableNormal, which tailors the diffusion priors for monocular normal estimation. Unlike prior diffusion-based works, we focus on enhancing estimation stability by reducing the inherent stochasticity of diffusion models ( i.e. , Stable Diffusion). This enables “Stable-and-Sharp” normal estimation, which outperforms multiple baselines (try Compare), and improves various real-world applications (try Demo).

teaser

News

  • StableNormal-turbo (10 times faster) is now avaliable on ModelScope . We invite you to explore its features! :fire::fire::fire: (10.11, 2024 UTC)
  • StableNormal is accepted by SIGGRAPH Asia 2024. (Journal Track)) (09.11, 2024 UTC)
  • Release StableDelight :fire::fire::fire: (09.07, 2024 UTC)
  • Release StableNormal :fire::fire::fire: (08.27, 2024 UTC)

Installation:

Please run following commands to build package:

git clone https://github.com/Stable-X/StableNormal.git
cd StableNormal
pip install -r requirements.txt

or directly build package:

pip install git+https://github.com/Stable-X/StableNormal.git

Usage

To use the StableNormal pipeline, you can instantiate the model and apply it to an image as follows:

import torch
from PIL import Image

# Load an image
input_image = Image.open("path/to/your/image.jpg")

# Create predictor instance
predictor = torch.hub.load("Stable-X/StableNormal", "StableNormal", trust_repo=True)

# Apply the model to the image
normal_image = predictor(input_image)

# Save or display the result
normal_image.save("output/normal_map.png")

Additional Options:

  • If you need faster inference(10 times faster), use StableNormal_turbo:
predictor = torch.hub.load("Stable-X/StableNormal", "StableNormal_turbo", trust_repo=True)
  • If Hugging Face is not available from terminal, you could download the pretrained weights to weights dir:
predictor = torch.hub.load("Stable-X/StableNormal", "StableNormal", trust_repo=True, local_cache_dir='./weights')

Compute Metrics:

This section provides guidance on evaluating your normal predictor using the DIODE dataset.

Step 1: Prepare Your Results Folder

First, make sure you have generated a normal map and structured your results folder as shown below:

├── YOUR-FOLDER-NAME 
   ├── scan_00183_00019_00183_indoors_000_010_gt.png
   ├── scan_00183_00019_00183_indoors_000_010_init.png
   ├── scan_00183_00019_00183_indoors_000_010_ref.png
   ├── scan_00183_00019_00183_indoors_000_010_step0.png
   ├── scan_00183_00019_00183_indoors_000_010_step1.png
   ├── scan_00183_00019_00183_indoors_000_010_step2.png
   ├── scan_00183_00019_00183_indoors_000_010_step3.png

Step 2: Compute Metric Values

Once your results folder is set up, you can compute the metrics for your normal predictions by running the following scripts:

# compute metrics
python ./stablenormal/metrics/compute_metric.py -i ${YOUR-FOLDER-NAME}

# compute variance
python ./stablenormal/metrics/compute_variance.py -i ${YOUR-FOLDER-NAME}

Replace ${YOUR-FOLDER-NAME}; with the actual name of your results folder. Following these steps will allow you to effectively evaluate your normal predictor's performance on the DIODE dataset.

Metrics

On DIODE-indoor

Mean ErrorMedian Error<11.25<22.5<30
GeoWizard19.37115.40830.55175.42686.357
Marigold Normal16.67112.08445.77682.07689.879
GenPercept18.34813.36739.17879.81988.551
DSINE18.45313.87136.27477.52786.976
StableNormal-turbo16.74813.57335.80684.58591.335
StableNormal13.7019.46063.44786.30992.107

On IBims-1

Mean ErrorMedian Error< 11.25< 22.5< 30
GeoWizard19.7489.70258.42777.61681.575
Marigold Normal18.4638.44264.72779.55983.199
GenPercept18.6008.29364.69779.32982.978
DSINE18.7738.25864.13178.57082.160
StableNormal-turbo17.4338.14565.68380.90984.527
StableNormal17.2488.05766.65581.13484.632

On Scannet

Mean ErrorMedian Error< 11.25< 22.5< 30
GeoWizard21.43913.39037.08071.65379.712
Marigold Normal21.28412.26845.64972.66679.045
GenPercept20.65210.50253.01774.47080.364
DSINE18.6109.88556.13276.94482.606
StableNormal-turbo17.4329.64458.64379.17784.717
StableNormal18.09810.09756.00778.77684.115

On NYUv2

Mean ErrorMedian Error< 11.25< 22.5< 30
GeoWizard20.36311.89846.95473.78780.804
Marigold Normal20.86411.13450.45773.00379.332
GenPercept20.89611.51650.71273.03779.216
DSINE-----
StableNormal-turbo18.78810.38153.74176.71382.884
StableNormal19.70710.52753.04275.88981.723

Citation

@article{ye2024stablenormal,
  title={StableNormal: Reducing Diffusion Variance for Stable and Sharp Normal},
  author={Ye, Chongjie and Qiu, Lingteng and Gu, Xiaodong and Zuo, Qi and Wu, Yushuang and Dong, Zilong and Bo, Liefeng and Xiu, Yuliang and Han, Xiaoguang},
  journal={ACM Transactions on Graphics (TOG)},
  year={2024},
  publisher={ACM New York, NY, USA}
}