Fast batch 3D rendering for TorchRL environments using Panda3D. Try the CartPole demo in Colab to get started.
pip install git+https://github.com/dolphin-in-a-coma/pybatchrender.gitFrom source:
pip install -e .Optional extras:
pip install "pybatchrender[images]" # For saving frames
pip install "pybatchrender[cuda]" # For CUDA interop (Linux/Windows with NVIDIA)With pre-made environments:
import pybatchrender as pbr
env = pbr.envs.make("CartPole-v0", num_scenes=256)
td = env.reset()
for step in range(100):
td["action"] = env.action_spec.rand()
td = env.step(td)
td = td["next"]Render simple scene:
from pybatchrender import PBRConfig, PBRRenderer
cfg = PBRConfig(num_scenes=4, tile_resolution=(64, 64), offscreen=True)
renderer = PBRRenderer(cfg)
renderer.add_camera()
renderer.add_light()
renderer.add_node('models/box', instances_per_scene=1, shared_across_scenes=True)
renderer.setup_environment()
img_batch = renderer.step(return_pixels=True)
print(img_batch.shape) # torch.Size([4, 3, 64, 64])MIT