Basic Usage¶
After installing Dr.TVAM, a drtvam command-line tool is available to run an
optimization from a configuration file. You can download an example
configuration file with its associated
target shape to get started.
This configuration file is a JSON file that specifies the optical setup, and the optimization parameters, whose entries we outline below. After defining it, running the optimization is as simple as:
drtvam path/to/config.json
This will run the optimization and save the results in the directory specified in the configuration file, or in the directory containing the configuration file if no output directory is specified.
Any entry in the JSON configuration file can be overridden by using the
-Dkey=value optional argument. For example, if we were to override the
number of optimization steps and the output directory, we could run:
drtvam path/to/config.json -Dn_steps=100 -Doutput=path/to/output
This script will try to run on the GPU if possible, and fall back to the CPU if not. If you want to speficy a particular backend, you can use the --backend <backend> command-line option, where <backend> can either be llvm (CPU) or cuda (GPU). For example, to run on the CPU, you can use:
drtvam path/to/config.json --backend llvm
Configuration syntax¶
The JSON configuration must contain a number of dictionary entries, specifying various aspects of the optimization:
Key |
Type |
Description |
|---|---|---|
|
Dictionary |
Contains parameters relative to the resin and its container. See the vial section for more details. |
|
Dictionary |
Contains parameters relative to the projection system. See the Projectors section for more details. |
|
Dictionary |
Contains parameters relative to the sensor, which defines where the
absporption measurements are taken. See the Sensors section for
more details. In particular, one can specify the resolution of the
sensor in the nested |
|
Dictionary |
Contains the path to the target shape (e.g. |
Other entries are optional:
Key |
Type |
Description |
|---|---|---|
|
Dictionary |
Which loss should be used, with the syntax |
|
Dictionary |
Contains the choice of optimizer. Defaults to L-BFGS. |
|
|
The number of optimization steps. Defaults to 40. |
|
|
How many light paths are drawn per projector pixel in the forward evaluation of the model. Defaults to 4. |
|
|
How many light paths are drawn per projector pixel in the
backpropagation of the model. Defaults to |
|
|
How many light paths are drawn per projector pixel when evaluating the final results. Defaults to 16. |
|
|
Maximum number of scattering events (surface or medium) computed before ending a path. For purely absorptive media, a value of 3 is often sufficient. Defaults to 6. |
|
|
Same as |
|
|
Light paths can be ended stochastically using “Russian Roulette” after this depth. Defaults to 6, i.e. it is disabled by default. |
|
|
Same as |
|
|
Print duration, in seconds. This defines the total exposure time. Defaults to 1 sec. |
|
|
When optimizing patterns for a scattering medium, it is useful to run the first few iterations with scattering disabled, and then enable it. This flag enables this option. Defaults to False. |
|
|
Determines whether our surface-aware discretization should be used, or a simple discretization to a binary occupancy grid instead. Defaults to False. |
|
|
If enabled, the Radon transform of the target object will first be computed, and then all projector pixels where it has value 0 will be disabled. This can significantly speed up the optimization for objects not covering the entire projection surface. Defaults to False. |
|
|
The output directory where the results will be saved. If not specified, the results will be saved in the directory containing this file. |
Limitations¶
This command-line interface is meant to be a simple way to run an optimization, and therefore allows limited flexibility regarding the possible optimizations. For more advanced usage, we recommend setting your own optimization pipeline using the Python API directly. Please refer to the Tutorials section for more information.