|
1 | 1 | # Intrinsic Image Decomposition via Ordinal Shading
|
2 |
| -Code for the paper: Intrinsic Image Decomposition via Ordinal Shading, [Chris Careaga](https://ccareaga.github.io/) and [Yağız Aksoy](https://yaksoy.github.io) , ACM Transactions on Graphics, 2023 |
3 |
| -### [Project Page](https://yaksoy.github.io/intrinsic) | [Paper]() | [Video]() | [Supplementary]() | [Data]() |
4 |
| - |
5 |
| -In this work, we achieve high-resolution intrinsic |
6 |
| -decomposition by breaking the problem into two parts. First, we present a |
7 |
| -dense ordinal shading formulation using a shift- and scale-invariant loss in |
8 |
| -order to estimate ordinal shading cues without restricting the predictions to |
9 |
| -obey the intrinsic model. We then combine low- and high-resolution ordinal |
10 |
| -estimations using a second network to generate a shading estimate with both |
11 |
| -global coherency and local details. We encourage the model to learn an ac- |
12 |
| -curate decomposition by computing losses on the estimated shading as well |
13 |
| -as the albedo implied by the intrinsic model. We develop a straightforward |
14 |
| -method for generating dense pseudo ground truth using our model’s pre- |
15 |
| -dictions and multi-illumination data, enabling generalization to in-the-wild |
16 |
| -imagery. |
| 2 | +Code for the paper: Intrinsic Image Decomposition via Ordinal Shading, [Chris Careaga](https://ccareaga.github.io/) and [Yağız Aksoy](https://yaksoy.github.io), ACM Transactions on Graphics, 2023 |
| 3 | +### [Project Page](https://yaksoy.github.io/intrinsic) | [Paper](https://yaksoy.github.io/papers/TOG23-Intrinsic.pdf) | [Video](https://www.youtube.com/watch?v=pWtJd3hqL3c) | [Supplementary](https://yaksoy.github.io/papers/TOG23-Intrinsic-Supp.pdf) | [Data](https://github.com/compphoto/MIDIntrinsics) |
| 4 | + |
| 5 | +We propose a method for generating high-resolution intrinsic image decompositions, for in-the-wild images. Our method relies on a carefully formulated ordinal shading representation, and real-world supervision from multi-illumination data in order to predict highly accurate albedo and shading. |
| 6 | + |
| 7 | +[](https://www.youtube.com/watch?v=pWtJd3hqL3c) |
| 8 | + |
| 9 | + |
| 10 | +Try out our pipeline on your own images! [](https://colab.research.google.com/github/compphoto/Intrinsic/blob/main/intrinsic_inference.ipynb) |
| 11 | + |
| 12 | +## Method |
| 13 | +The inherently under-constrained and scale-invariant nature of the intrinsic decomposition makes it a challenging problem. |
| 14 | +Shading, which represents complex interactions in the scene, is difficult for neural networks to predict. |
| 15 | +Compounded by the scarcity of dense ground-truth data, state-of-the-art models fail at high resolutions in real-world scenarios. |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | +Our method focuses on generating high-resolution shading estimations, rather than attempting to estimate shading and albedo separately. |
| 20 | +Since shading values are unbounded, we develop a representation of shading values called "inverse shading" which maps the shading values into the zero-one range. |
| 21 | +This creates a balanced distribution of values in a well-defined range that is desirable for training neural networks. |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | +Rather than directly regressing the inverse shading values, we relax the problem and aim to predict *ordinal* shading values. |
| 26 | +To do this, we train our network using shift- and scale-invariant loss functions. |
| 27 | +This simplifies the task of shading estimation as the model does not need to estimate precise values that satisfy the core intrinsic decomposition model |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +Our ordinal estimations exhibit specific behaviors at different resolutions. |
| 32 | +At low resolutions, the model can generate globally coherent predictions, but the outputs lack details. |
| 33 | +At high resolutions, the model can predict fine local details, but at the cost of global coherency. |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | +To generate a final shading estimation we combine two ordinal estimations, at low and high resolutions, with the input image and send them through a second network. |
| 38 | +We use the final shading estimation, and the input image in order to compute our estimated albedo. This allows us to compute losses on both shading and albedo while |
| 39 | +using only a single network. |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +We train our method on multiple rendered datasets. In order to generate real-world supervision for our method we use multi-illumination data. |
| 44 | +Using our pipeline we estimate the albedo for each image in a given multi-illumination scene. By taking the median across these albedo estimations, small errors are removed resulting in a single accurate albedo. |
| 45 | +We use these 25,000 pseudo-ground-truth pairs as training data and continue training our pipeline. |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +Our method can be used for complex image editing tasks such as recoloring and relighting |
| 50 | + |
| 51 | + |
| 52 | + |
17 | 53 |
|
18 | 54 | ## Setup
|
19 | 55 | Depending on how you would like to use the code in this repository there are two options to setup the code.
|
20 | 56 | In either case, you should first create a fresh virtual environment (`python3 -m venv intrinsic_env`) and start it (`source intrinsic_env/bin/activate`)
|
21 | 57 |
|
22 |
| -#### Option 1 |
23 |
| -If you would like to download the repository to run and make changes you can simply clone the repo: |
| 58 | +You can install this repository as a package using `pip`: |
24 | 59 | ```
|
25 | 60 | git clone https://github.com/compphoto/Intrinsic
|
26 | 61 | cd Intrinsic
|
| 62 | +pip install . |
27 | 63 | ```
|
28 |
| -then pip install all the dependencies of the repo: |
29 |
| -``` |
30 |
| -pip install -r requirements.txt |
31 |
| -``` |
32 |
| - |
33 |
| -#### Option 2 |
34 |
| -Alternatively, you can install this repository as a package using `setup.py`: |
35 |
| -``` |
36 |
| -git clone https://github.com/compphoto/Intrinsic |
37 |
| -cd Intrinsic |
38 |
| -python setup.py |
39 |
| -``` |
| 64 | +If you want to make changes to the code and have it reflected when you import the package use `pip install --editable` |
40 | 65 | Or perform the same action without cloning the code using:
|
41 | 66 | ```
|
42 |
| -pip install https://github.com/compphoto/Intrinsic/archive/master.zip |
| 67 | +pip install https://github.com/compphoto/Intrinsic/archive/main.zip |
43 | 68 | ```
|
44 |
| -This will allow you to import the repository as a python package, and use our pipeline as part of your codebase. |
| 69 | +This will allow you to import the repository as a Python package, and use our pipeline as part of your codebase. |
45 | 70 |
|
46 | 71 | ## Inference
|
47 | 72 | To run our pipeline on your own images you can use the decompose script:
|
| 73 | +```python |
| 74 | +from chrislib.general import view, tile_imgs, view_scale, uninvert |
| 75 | +from chrislib.data_util import load_image |
| 76 | + |
| 77 | +from intrinsic.pipeline import run_pipeline |
| 78 | +from intrinsic.model_util import load_models |
| 79 | + |
| 80 | +# load the models from the given paths |
| 81 | +models = load_models('final_weights.pt') |
| 82 | + |
| 83 | +# load an image (np float array in [0-1]) |
| 84 | +image = load_image('/path/to/input/image') |
| 85 | + |
| 86 | +# run the model on the image using R_0 resizing |
| 87 | +results = run_pipeline( |
| 88 | + models, |
| 89 | + image, |
| 90 | + resize_conf=0.0, |
| 91 | + maintain_size=True |
| 92 | +) |
| 93 | + |
| 94 | +albedo = results['albedo'] |
| 95 | +inv_shd = results['inv_shading'] |
| 96 | + |
| 97 | +# compute shading from inverse shading |
| 98 | +shading = uninvert(inv_shd) |
| 99 | + |
48 | 100 | ```
|
| 101 | +This will run our pipeline and output the linear albedo and shading. You can run this in your browser as well! [](https://colab.research.google.com/github/compphoto/Intrinsic/blob/main/intrinsic_inference.ipynb) |
| 102 | + |
| 103 | +## Citation |
49 | 104 |
|
50 | 105 | ```
|
| 106 | +@ARTICLE{careagaIntrinsic, |
| 107 | + author={Chris Careaga and Ya\u{g}{\i}z Aksoy}, |
| 108 | + title={Intrinsic Image Decomposition via Ordinal Shading}, |
| 109 | + journal={ACM Trans. Graph.}, |
| 110 | + year={2023}, |
| 111 | +} |
| 112 | +``` |
| 113 | + |
| 114 | +## License |
| 115 | + |
| 116 | +This implementation is provided for academic use only. Please cite our paper if you use this code or any of the models. |
| 117 | + |
| 118 | +The methodology presented in this work is safeguarded under intellectual property protection. For inquiries regarding licensing opportunities, kindly reach out to SFU Technology Licensing Office <tlo_dir <i>ατ</i> sfu <i>δøτ</i> ca> and Dr. Yağız Aksoy <yagiz <i>ατ</i> sfu <i>δøτ</i> ca>. |
0 commit comments