MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / SMPLRenderer

Class SMPLRenderer

detrsmpl/core/renderer/torch3d_renderer/smpl_renderer.py:21–278  ·  view source on GitHub ↗

Render SMPL(X) with different render choices.

Source from the content-addressed store, hash-verified

19
20
21class SMPLRenderer(BaseRenderer):
22 """Render SMPL(X) with different render choices."""
23 def __init__(self,
24 resolution: Tuple[int, int] = None,
25 device: Union[torch.device, str] = 'cpu',
26 output_path: Optional[str] = None,
27 return_tensor: bool = False,
28 alpha: float = 1.0,
29 out_img_format: str = '%06d.png',
30 read_img_format: str = None,
31 render_choice='mq',
32 frames_folder: Optional[str] = None,
33 plot_kps: bool = False,
34 vis_kp_index: bool = False,
35 final_resolution: Tuple[int, int] = None,
36 **kwargs) -> None:
37 super(BaseRenderer, self).__init__()
38
39 self.device = device
40 self.resolution = resolution
41 self.render_choice = render_choice
42 self.output_path = output_path
43 self.frames_folder = frames_folder
44 self.plot_kps = plot_kps
45 self.vis_kp_index = vis_kp_index
46 self.read_img_format = read_img_format
47 self.out_img_format = out_img_format
48 self.final_resolution = final_resolution
49 self.return_tensor = return_tensor
50 if output_path is not None:
51 if check_path_suffix(output_path, ['.mp4', '.gif']):
52 self.temp_path = osp.join(
53 Path(output_path).parent,
54 Path(output_path).name + '_output_temp')
55 mmcv.mkdir_or_exist(self.temp_path)
56 print('make dir', self.temp_path)
57 else:
58 self.temp_path = output_path
59
60 self.image_renderer = build_renderer(
61 dict(device=device, resolution=resolution, **kwargs))
62
63 if plot_kps:
64 self.alpha = max(min(0.8, alpha), 0.1)
65 self.joints_renderer = build_renderer(
66 dict(type='pointcloud',
67 resolution=resolution,
68 device=device,
69 radius=0.008))
70 else:
71 self.alpha = max(min(1.0, alpha), 0.1)
72 """
73 Render Mesh for SMPL and SMPL-X. For function render_smpl.
74 2 modes: mesh render with different quality and palette,
75 or silhouette render.
76
77 Args:
78 resolution (Iterable[int]): (height, width of render images)

Callers 1

render_smplFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected