def run_on_image(self, image, focal_length=10.0):
    '\n        Args:\n            image (np.ndarray): an image of shape (H, W, C) (in BGR order).\n                This is the format used by OpenCV.\n            focal_length (float): the focal_length of the image\n\n        Returns:\n            predictions (dict): the output of the model.\n        '
    predictions = self.predictor(image)
    image = image[:, :, ::(- 1)]
    imsize = [image.shape[0], image.shape[1]]
    focal_length = ((image.shape[1] / 32) * focal_length)
    K = [focal_length, (image.shape[1] / 2), (image.shape[0] / 2)]
    if ('instances' in predictions):
        instances = predictions['instances'].to(self.cpu_device)
        scores = instances.scores
        boxes = instances.pred_boxes
        labels = instances.pred_classes
        masks = instances.pred_masks
        meshes = Meshes(verts=[mesh[0] for mesh in instances.pred_meshes], faces=[mesh[1] for mesh in instances.pred_meshes])
        pred_dz = (instances.pred_dz[:, 0] * (boxes.tensor[:, 3] - boxes.tensor[:, 1]))
        tc = (pred_dz.abs().max() + 1.0)
        zranges = torch.stack([torch.stack([(tc - (((tc * pred_dz[i]) / 2.0) / focal_length)), (tc + (((tc * pred_dz[i]) / 2.0) / focal_length))]) for i in range(len(meshes))], dim=0)
        Ks = torch.tensor(K).to(self.cpu_device).view(1, 3).expand(len(meshes), 3)
        meshes = transform_meshes_to_camera_coord_system(meshes, boxes.tensor, zranges, Ks, imsize)
        if self.vis_highest_scoring:
            det_ids = [scores.argmax().item()]
        else:
            det_ids = range(len(scores))
        for det_id in det_ids:
            self.visualize_prediction(det_id, image, boxes.tensor[det_id], labels[det_id], scores[det_id], masks[det_id], meshes[det_id])
    return predictions
Args:
    image (np.ndarray): an image of shape (H, W, C) (in BGR order).
        This is the format used by OpenCV.
    focal_length (float): the focal_length of the image

Returns:
    predictions (dict): the output of the model.
def run_on_image(self, image, focal_length=10.0):
    '\n        Args:\n            image (np.ndarray): an image of shape (H, W, C) (in BGR order).\n                This is the format used by OpenCV.\n            focal_length (float): the focal_length of the image\n\n        Returns:\n            predictions (dict): the output of the model.\n        '
    predictions = self.predictor(image)
    image = image[:, :, ::(- 1)]
    imsize = [image.shape[0], image.shape[1]]
    focal_length = ((image.shape[1] / 32) * focal_length)
    K = [focal_length, (image.shape[1] / 2), (image.shape[0] / 2)]
    if ('instances' in predictions):
        instances = predictions['instances'].to(self.cpu_device)
        scores = instances.scores
        boxes = instances.pred_boxes
        labels = instances.pred_classes
        masks = instances.pred_masks
        meshes = Meshes(verts=[mesh[0] for mesh in instances.pred_meshes], faces=[mesh[1] for mesh in instances.pred_meshes])
        pred_dz = (instances.pred_dz[:, 0] * (boxes.tensor[:, 3] - boxes.tensor[:, 1]))
        tc = (pred_dz.abs().max() + 1.0)
        zranges = torch.stack([torch.stack([(tc - (((tc * pred_dz[i]) / 2.0) / focal_length)), (tc + (((tc * pred_dz[i]) / 2.0) / focal_length))]) for i in range(len(meshes))], dim=0)
        Ks = torch.tensor(K).to(self.cpu_device).view(1, 3).expand(len(meshes), 3)
        meshes = transform_meshes_to_camera_coord_system(meshes, boxes.tensor, zranges, Ks, imsize)
        if self.vis_highest_scoring:
            det_ids = [scores.argmax().item()]
        else:
            det_ids = range(len(scores))
        for det_id in det_ids:
            self.visualize_prediction(det_id, image, boxes.tensor[det_id], labels[det_id], scores[det_id], masks[det_id], meshes[det_id])
    return predictions