-
Notifications
You must be signed in to change notification settings - Fork 1
/
renderer.py
33 lines (25 loc) · 765 Bytes
/
renderer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import torch
from pytorch3d.renderer import (
PointsRasterizationSettings,
PointsRasterizer,
PointsRenderer,
AlphaCompositor
)
# setup
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
# point renderer
def point_renderer(cameras, image_size, radius=0.005, points_per_pixel=50, background=[0, 0, 0]):
raster_settings = PointsRasterizationSettings(
image_size=image_size,
radius=radius,
points_per_pixel=points_per_pixel
)
rasterizer = PointsRasterizer(
cameras=cameras,
raster_settings=raster_settings
)
renderer = PointsRenderer(
rasterizer=rasterizer,
compositor=AlphaCompositor(background_color=background)
)
return renderer.to(device)