AiModelResultRadianceFieldExtensions
Helpers & Utilities · AiDotNet.NeuralRadianceFields.Extensions
Model-specific inference extensions on AiModelResult for the
radiance-field family (NeRF, InstantNGP, GaussianSplatting). Fixes #1836.
How It Works
Model is internal by design (IP protection —
same reason model save/load is license-gated). Consumers outside the AiDotNet assembly can’t
retrieve the trained model from BuildAsync’s return, so previously the only way to call
radiance-field-specific inference (RenderImage, RenderRays, QueryField)
was to keep a raw reference to the model passed to ConfigureModel — fragile under
factories, callbacks, or DeepCopy.
These extension methods live in the same assembly as AiModelResult
so they access the internal Model property directly. Callers just add
using AiDotNet.NeuralRadianceFields.Extensions; and the family-specific inference methods
appear on the result.
Beyond industry standard. Reference facades (PyTorch skorch, Keras wrappers) either force
everything through a generic Predict OR expose the raw model publicly. Neither is great:
generic Predict loses model-specific inference (rendering a camera view, sampling from a
diffusion model, generating text) and public model exposure defeats IP protection. Namespaced
extensions give the best of both: hidden model + discoverable domain-specific inference.
Methods
| Method | Summary |
|---|---|
Task<Tensor<T>> RenderImageAsync(AiModelResult<T, TInput, TOutput> result, Vector<T> cameraPosition, Matrix<T> cameraRotation, int imageWidth, int imageHeight, T focalLength, CancellationToken cancellationToken) |
Async variant of RenderImage for orbit-trajectory renders where the caller wants to render many frames in parallel without blocking. |
Tensor<T> RenderImage(AiModelResult<T, TInput, TOutput> result, Vector<T> cameraPosition, Matrix<T> cameraRotation, int imageWidth, int imageHeight, T focalLength) |
Renders a full RGB image by casting rays from the camera and volume-rendering through the radiance field. |
Tensor<T> RenderRays(AiModelResult<T, TInput, TOutput> result, Tensor<T> rayOrigins, Tensor<T> rayDirections, int numSamples, T nearBound, T farBound) |
Renders rays through the radiance field using volume rendering. |
Tensor<T>[] RenderImageBatch(AiModelResult<T, TInput, TOutput> result, IEnumerable<ValueTuple<Vector<T>, Matrix<T>, int, int, T>> views) |
Batched variant that renders N views in parallel using the .NET thread pool. |
ValueTuple<Tensor<T>, Tensor<T>> QueryField(AiModelResult<T, TInput, TOutput> result, Tensor<T> positions, Tensor<T> viewingDirections) |
Queries the raw radiance field at 3D positions (returns per-point RGB + density without volume rendering). |