torchdrivesim.rendering.pytorch3d#

PyTorch3D-based renderers, used by default in TorchDriveSim.

Module Contents#

Classes#

RenderingBlend

Blending choices from pytorch3d. May be ignored by other renderer types.

Pytorch3DRendererConfig

Configuration of pytorch3d-based renderer.

Shader2D

Shader that ignores lighting, based on https://github.com/facebookresearch/pytorch3d/issues/84

Pytorch3DRenderer

Renderer based on pytorch3d, using an orthographic projection and a trivial shader.

class torchdrivesim.rendering.pytorch3d.RenderingBlend[source]#

Bases: enum.Enum

Blending choices from pytorch3d. May be ignored by other renderer types. https://pytorch3d.readthedocs.io/en/latest/modules/renderer/blending.html

hard = 'hard'[source]#
soft = 'soft'[source]#
sigmoid = 'sigmoid'[source]#
class torchdrivesim.rendering.pytorch3d.Pytorch3DRendererConfig[source]#

Bases: torchdrivesim.rendering.base.RendererConfig

Configuration of pytorch3d-based renderer.

backend: str = 'pytorch3d'[source]#
differentiable_rendering: RenderingBlend[source]#
class torchdrivesim.rendering.pytorch3d.Shader2D(device='cpu', background_color: Tuple[float, float, float] = (0, 0, 0), blend=RenderingBlend.soft)[source]#

Bases: torch.nn.Module

Shader that ignores lighting, based on https://github.com/facebookresearch/pytorch3d/issues/84

forward(fragments, meshes, **kwargs) torch.Tensor[source]#
class torchdrivesim.rendering.pytorch3d.Pytorch3DRenderer(cfg: Pytorch3DRendererConfig, *args, **kwargs)[source]#

Bases: torchdrivesim.rendering.base.BirdviewRenderer

Renderer based on pytorch3d, using an orthographic projection and a trivial shader. Works on both GPU and CPU, but CPU is very slow.

render_mesh(mesh: torchdrivesim.mesh.BirdviewMesh, res: torchdrivesim.utils.Resolution, cameras: pytorch3d.renderer.FoVOrthographicCameras) torch.Tensor[source]#

Renders a given mesh, producing BxHxWxC tensor image of float RGB values in [0,255] range.

classmethod make_renderer(res, blend, background_color)[source]#