You need a recent version of CUDA installed. This was tested with CUDA 12.6. We recommand using conda virtual environments.
If you don't have this configuration (but have a CUDA 12.6 compatible card), we provide the following docker command to start an interactive shell with the correct CUDA and miniforge versions. It can be used to quickly test our code.
Docker command for CUDA and miniforge
sudo docker run --gpus all -it -v $(pwd):/workspace -w /workspace nvcr.io/nvidia/cuda:12.6.0-devel-ubuntu22.04 bash -c "
apt-get update && apt-get install -y wget bzip2 unzip git && \
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O Miniconda3.sh && \
bash Miniconda3.sh -b -p /opt/conda && \
rm Miniconda3.sh && \
export PATH=/opt/conda/bin:$PATH && \
conda init bash && \
echo 'export PATH=/opt/conda/bin:$PATH' >> ~/.bashrc && \
bash"First, you can create an environment with Python 3.12:
conda create -n diffantirad python=3.12.2Then activate the environment:
conda activate diffantiradIf you have CUDA 12.6 (or in the Docker shell)
You can then update the environment using the yaml file:
conda env update --file environment.ymlIf you have another CUDA version installed:
You can install pytorch manually from the website in the conda environment. Note that although it should work with any CUDA 11.x or 12.x version, we did not test it.
You can then update the environment using the yaml file:
conda env update --file environment_nopytorch.ymlWe also use pytorch3d and nvdiffrast. We found the easiest version to install it is through git (we tested our code with pytorch3d 0.7.8 and nvdiffrast 0.4.0, at the commits hardcoded below, but it should work with the latest versions):
FORCE_CUDA=1 pip install "git+https://github.com/facebookresearch/pytorch3d.git@61cc79aa340412c33407771bc97236ccd9ee1548" --no-build-isolation
pip install git+https://github.com/NVlabs/nvdiffrast.git@253ac4fcea7de5f396371124af597e6cc957bfae --no-build-isolationFinally, you can install our module with:
cd antiradiancediff
pip install . --no-build-isolation
cd ..We provide the data we used in our experiments in a separate link. It can be downloaded with the script:
scripts/download_data.shor it can be found directly at data. To run the experiments, you need to download it (~3 Go), and extract it anywhere on your device (it can be in this directory, but it is not necessary).
We provide scripts to run the trainings we present in the paper. They can be found in the scripts/ directory. They should be executed from the main directory of the repository (this current directory).
The training parameters are hard-coded in the scripts, and the only necessary arguments are the path to the data/ directory, and the path to the output directory for the training (except for scripts/emissivity/*_generate_errors.sh). For example, if data/ is in this directory, you can run:
scripts/envmap/ar_spot/ar_spot1.sh data output/ar/spot1In the scripts' names, the 'ar' prefix stands for antiradiance (with our method), and 'pt' for pathtracing (running with Mitsuba).
There are several python scripts to produce the figures present in the article.
For pathtracing experiments, the trained envmaps are produced during the iterations (as exr files), directly in the training directories.
For our method, envmaps are dumped in the env directory of the training directory. However, they are dumped as objects, not as images. The script generate_envmaps.py can be used to produce exr files of the trained envmaps. It is called automatically at the end of the scripts in scripts/envmap/*. The syntax is:
python generate_envmaps.py outputdir/where outputdir is the path to the training directory. This commands exports the envmap of the last dumped iteration. To produce the envmap associated to a specific (dumped) iteration, one can use:
python generate_envmaps.py outputdir/ iteration_numberThe necessary scripts to reproduce the emissivity experiments are in the subdirectory scripts/emissivity. There are 3 scripts for our method, and 3 for pathtracing (one for each optimization resolution).
There are two additionnal scripts to produce the images in the figure: scripts/emissivity/ar_generate_errors.sh and scripts/emissivity/pt_generate_errors.sh. These scripts take 3 arguments: the path to data and the path to the output of the training (as before), but also a third argument, which is the rate of the optimization (number of seconds per iteration) and is printed during the training. It is used to produce the figures, and is machine-dependent. On our machine (V100), these were between 1.23 and 1.34. The figures are produced in the subdirectory emissivity_errors of the the training directory.
The four scripts used to train the emissivity with/without masking and with/without regularization are in scripts/masking/. To produce the figures, you can use scripts/masking/render_emissivity.sh, and to produce the visualization of the reference, scripts/masking/render_reference.sh.
We provide the script used to train the position in scripts/position/ar_hiddenbunny.sh. To reproduce the path visualization in the paper, we provide scripts/position/vizu_hiddenbunny.sh (both scripts have the same arguments as before).
There are two scripts to run the scripts on both scenes, and two scripts to produce the images, which can be executed as before.