Skip to content

Commit

Permalink
fix(bop): Cleansup pyrender in single-proc mode
Browse files Browse the repository at this point in the history
  • Loading branch information
cornerfarmer committed Oct 22, 2024
1 parent 3d95ac8 commit 788b7c1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion blenderproc/python/writer/BopWriterUtility.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ def write_bop(output_dir: str, target_objects: Optional[List[MeshObject]] = None
if pool is not None:
pool.close()
pool.join()

else:
# Make sure the renderer get destroyed
_BopWriterUtility._pyrender_cleanup()


def bop_pose_to_pyrender_coordinate_system(cam_R_m2c: np.ndarray, cam_t_m2c: np.ndarray) -> np.ndarray:
Expand Down Expand Up @@ -553,6 +555,16 @@ def _pyrender_init(ren_width: int, ren_height: int, trimesh_objects: Dict[int, t
metallicFactor=0.2, roughnessFactor=0.8, doubleSided=True)
dataset_objects[key] = pyrender.Mesh.from_trimesh(mesh=trimesh_objects[key], material=material)

@staticmethod
def _pyrender_cleanup():
""" Cleans up global renderer
This is only necessary when not using multiprocessing,.
"""
global renderer, renderer_large, dataset_objects
del renderer
del renderer_large
del dataset_objects

@staticmethod
def _calc_gt_masks_iteration(annotation_scale: float, K: np.ndarray, delta: float, dist_im: np.ndarray, chunk_dir: str, im_id: int, gt_data: Tuple[int, Dict[str, int]]):
Expand Down

0 comments on commit 788b7c1

Please sign in to comment.