diff --git a/docs/conf.py b/docs/conf.py index c032f517c..4cbab73b2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -40,6 +40,7 @@ extensions = [ "sphinxemoji.sphinxemoji", "myst_parser", "sphinx.ext.napoleon", + "sphinx_copybutton", ] # List of patterns, relative to source directory, that match files and @@ -57,6 +58,12 @@ suppress_warnings = ["myst.header"] html_theme = "furo" html_title = "pyRad" +autosectionlabel_prefix_document = True + +# -- Code block theme -------------------------------------------------------- + +pygments_style = "manni" +pygments_dark_style = "stata-dark" # -- Napoleon settings ------------------------------------------------------- diff --git a/docs/reference/fields.rst b/docs/reference/fields.rst index b1805635b..2ab17d98d 100644 --- a/docs/reference/fields.rst +++ b/docs/reference/fields.rst @@ -22,4 +22,4 @@ NeRF .. automodule:: pyrad.fields.nerf_field :members: - :show-inheritance: \ No newline at end of file + :show-inheritance: diff --git a/docs/reference/index.rst b/docs/reference/index.rst index 64ffc2912..395ccb5dc 100644 --- a/docs/reference/index.rst +++ b/docs/reference/index.rst @@ -6,12 +6,13 @@ API TODO: Explanation of each component .. toctree:: - :hidden: dataset fields fields/modules/index graphs graphs/modules/index + optimizers renderers/index - + utils/index + viewer diff --git a/docs/reference/optimizers.rst b/docs/reference/optimizers.rst new file mode 100644 index 000000000..b392a93ae --- /dev/null +++ b/docs/reference/optimizers.rst @@ -0,0 +1,9 @@ +.. _optimizers: + +Optimizers +============ + +.. automodule:: pyrad.optimizers.optimizers + :members: + :show-inheritance: + diff --git a/docs/reference/utils/colors.rst b/docs/reference/utils/colors.rst new file mode 100644 index 000000000..771b0447b --- /dev/null +++ b/docs/reference/utils/colors.rst @@ -0,0 +1,8 @@ +.. _colors: + +Colors +------------ + +.. automodule:: pyrad.utils.colors + :members: + :show-inheritance: diff --git a/docs/reference/utils/index.rst b/docs/reference/utils/index.rst new file mode 100644 index 000000000..7f872059b --- /dev/null +++ b/docs/reference/utils/index.rst @@ -0,0 +1,10 @@ +.. _utils: + +Utils +=================== + +.. toctree:: + + colors + math + visualization diff --git a/docs/reference/utils/math.rst b/docs/reference/utils/math.rst new file mode 100644 index 000000000..84352afb8 --- /dev/null +++ b/docs/reference/utils/math.rst @@ -0,0 +1,8 @@ +.. _math: + +Math +============ + +.. automodule:: pyrad.utils.math + :members: + :show-inheritance: diff --git a/docs/reference/utils/visualization.rst b/docs/reference/utils/visualization.rst new file mode 100644 index 000000000..db0dbb84d --- /dev/null +++ b/docs/reference/utils/visualization.rst @@ -0,0 +1,8 @@ +.. _visualization: + +Visualization +---------------- + +.. automodule:: pyrad.utils.visualization + :members: + :show-inheritance: diff --git a/docs/reference/viewer.rst b/docs/reference/viewer.rst new file mode 100644 index 000000000..186cf87d5 --- /dev/null +++ b/docs/reference/viewer.rst @@ -0,0 +1,8 @@ +.. _viewer: + +Viewer +============ + +.. automodule:: pyrad.viewer + :members: + :show-inheritance: diff --git a/docs/requirements.txt b/docs/requirements.txt index 6931264a8..94d708e23 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,5 +1,6 @@ furo==2022.4.7 readthedocs-sphinx-search==0.1.2 +myst-parser==0.17.2 sphinx==4.5.0 sphinxemoji==0.2.0 -myst-parser==0.17.2 \ No newline at end of file +sphinx-copybutton==0.5.0 \ No newline at end of file diff --git a/docs/tooling/benchmarking.md b/docs/tooling/benchmarking.md index 80a2f8791..42a39ec04 100644 --- a/docs/tooling/benchmarking.md +++ b/docs/tooling/benchmarking.md @@ -2,12 +2,12 @@ We make it easy to benchmark your new NeRF against the standard Blender dataset. -#### Launching training on Blender +#### Launching training on Blender dataset To start, you will need to train your NeRF on each of the blender objects. To launch training jobs automatically on each of these items, you can call: -``` +```bash ./scripts/benchmarking/launch_train_blender.sh ``` @@ -17,7 +17,7 @@ Simply replace the arguments in brackets with the correct arguments. A full example would be: -``` +```bash ./scripts/benchmarking/launch_train_blender.sh graph_vanilla_nerf 0 1 2 3 ``` @@ -29,7 +29,7 @@ Once you have launched training, and training converges, you can test your metho Modify the `BENCH` variable to specify which jobs you want benchmarked. -``` +```python BENCH = { "method": "graph_vanilla_nerf", # change this to whatever you want "hydra_base_dir": "outputs/", # change this to wherever hydra's default output directory is @@ -40,7 +40,7 @@ BENCH = { Then you can simply run -``` +```bash python scripts/benchmarking/run_benchmark.py ``` diff --git a/docs/tooling/jupyter.md b/docs/tooling/jupyter.md index 48a4cd3cf..8892dc7fa 100644 --- a/docs/tooling/jupyter.md +++ b/docs/tooling/jupyter.md @@ -4,7 +4,7 @@ We provide a few visualization tools with Jupyter that can be found in `notebook To install and run any of the notebooks, simply run the following commands: -``` +```bash python -m jupyter lab build bash environments/run_jupyter.sh ``` \ No newline at end of file diff --git a/docs/tooling/logging.md b/docs/tooling/logging.md index bee9fa39c..25bf6979e 100644 --- a/docs/tooling/logging.md +++ b/docs/tooling/logging.md @@ -3,7 +3,7 @@ We provide integration with multiple logging interfaces to log images and statistics during training. All of these loggers are configurable via the config: -``` +```yaml # e.g. configs/graphs_default.yaml logging: diff --git a/docs/tooling/other_codebase.md b/docs/tooling/other_codebase.md index 7017c0664..9b087924e 100644 --- a/docs/tooling/other_codebase.md +++ b/docs/tooling/other_codebase.md @@ -4,7 +4,7 @@ If you are looking to test out other existing repo's with our data, the pyRad st For instance, you can run nerf-pytorch and jaxnerf with the following commands: -``` +```bash # nerf-pytorch cd external python run_nerf.py --config configs/chair.txt --datadir /path/to/pyrad/data/blender/chair diff --git a/docs/tooling/profiling.md b/docs/tooling/profiling.md index 10fbe3630..8da0878d5 100644 --- a/docs/tooling/profiling.md +++ b/docs/tooling/profiling.md @@ -6,7 +6,7 @@ We provide built-in performance profiling capabilities to make it easier for you #### In-house profiler You can use our built-in profiler by enabling the profiler in the config: -``` +```yaml # e.g. configs/graphs_default.yaml logging: @@ -17,7 +17,7 @@ The profiler computes the average total time of execution for any function with For instance, if you wanted to profile the total time it takes to generate rays given pixel and camera indices via the `RayGenerator` class, you would want to evaluate its `forward()` function. In that class, you would need to add the decorator to the function. -``` +```python class RayGenerator(nn.Module): ... @@ -38,13 +38,13 @@ If you want to profile the entire codebase, we provide functionality to generate Install PySpy -``` +```bash pip install py-spy ``` To perform the profiling, you can either specify that you want to generate a flame graph or generate a live-view of the profiler. -``` +```bash ## for flame graph ./scripts/debugging/profile.sh -t flame -o flame.svg -p @@ -56,7 +56,7 @@ To perform the profiling, you can either specify that you want to generate a fla In both cases, `` can be replaced with any command you would normally run in the terminal. For instance, you can replace `` with `scripts/run_train.py data/dataset=blender_lego`. Then the full command would be e.g.: -``` +```bash ./scripts/debugging/profile.sh -t flame -o flame.svg -p scripts/run_train.py data/dataset=blender_lego ``` diff --git a/docs/tooling/speedup.md b/docs/tooling/speedup.md index 2d4439b88..f366533ae 100644 --- a/docs/tooling/speedup.md +++ b/docs/tooling/speedup.md @@ -3,12 +3,12 @@ Documentation for running the code with CUDA. Please see https://github.com/NVlabs/tiny-cuda-nn for how to install tiny-cuda-nn. -``` +```bash pip install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch ``` To run instant-ngp with tcnn, you can do the following. This is with the fox dataset. -``` +```bash python scripts/run_train.py --config-name=instant_ngp_tcnn.yaml data/dataset=instant_ngp_fox ``` \ No newline at end of file diff --git a/docs/tutorials/creating_graphs.md b/docs/tutorials/creating_graphs.md index edf1f910a..5175ed69e 100644 --- a/docs/tutorials/creating_graphs.md +++ b/docs/tutorials/creating_graphs.md @@ -11,22 +11,22 @@ If you are looking to implemnet a new NeRF method or extend an existing one, you All NeRF graph definitions can be found in `graphs/`. The graph encapsulates all the modules in the NeRF method- from the MLP's to the samplers to the losses and optimizers. All graphs are composed of modules and fields. ### Modules -We can decompose all graphs into respective modules. For instance, we have `optimizers/` which contains modules related to the loss, `renderers/` which contains all rendering modules, `graph/modules/`, which includes samplers and ray generators. Additionally, we have `fields/modules`, which will be discussed below. +We can decompose all graphs into respective modules. For instance, we have {ref}`optimizers` which contains modules related to the loss, {ref}`renderers` which contains all rendering modules, {`graph/modules/`}, which includes samplers and ray generators. Additionally, we have {ref}`field_modules`, which will be discussed below. In general, modules can be thought of as individual component parts of the graph that can be swapped in/out. We provide most of the standard modules, but if you are creating a new NeRF graph, you may have to define new modules. ### Fields -Fields (`fields/`) represents the "space", aka. the radiance field of the NeRF. Here, we define the field as the part of the network that takes in point samples and any other conditioning, and outputs any of the `FieldHeadNames` (`nerf/field_modules/field_heads.py`). +{ref}`fields` represents the "space", aka. the radiance field of the NeRF. Here, we define the field as the part of the network that takes in point samples and any other conditioning, and outputs any of the `FieldHeadNames` (`nerf/field_modules/field_heads.py`). All fields are composed of modules continained within the `fields/` directory (e.g. `fields/modules/` or `fields/occupancy_fields/`). We can think of field modules as modules that actually define or interact with the field. To build a NeRF field, we therefore follow these steps: 1. define any relevant field modules -2. create a new class that extends the `Field` class and use these field modules to compose the full field +2. create a new class that extends the {ref}`fields` base class and use these field modules to compose the full field 3. implement the abstract functions `get_density()` and `get_outputs()`. -``` +```python class NeRFField(Field): """NeRF Field""" @@ -67,7 +67,7 @@ Now that we've gone over what modules and fields are, we are ready to create the To implement the vanilla NeRF, we create a new class that inherits the abstract Graph class. Similar to composing a new field, we can pull from all pre-defined fields and modules and use them to compose a new Graph. We will then need to define the following abstract methods as seen in the skeleton code below. See also `graphs/vanilla_nerf.py` for the full implementation. -``` +```python class NeRFGraph(Graph): """Vanilla NeRF graph""" @@ -111,7 +111,7 @@ class NeRFGraph(Graph): Now that you have the graph and dataset all set up, you'll need to create the config that you pass into our run train routine. Our config system is powered by [Hydra](https://hydra.cc/). All Hydra and machine related arguments are stored in `configs/default_setup.yaml`, as well as the defaults list. To set up the graph config, create a new yaml under `configs/`. -``` +```yaml # configs/vanilla_nerf.yaml defaults: @@ -135,7 +135,7 @@ data: Once you have the config properly set up, you can begin training! To begin the training process, just pass in the name of your new config to the training script: -``` +```bash python scripts/run_train.py --config-name vanilla_nerf ```