def _count_near_pp(x):
    """Counts objects close to the camera."""
    # Threshold removes ~half of the objects.
    # Count distribution:

    # Location feature contains (x, y, z) in meters w.r.t. the camera.
    close_objects = tf.where(x['objects']['location'][:, 2] < 25)
    label = tf.math.minimum(tf.size(close_objects), 8)
    return {'image': x['image'], 'label': label}
Counts objects close to the camera.
clip_benchmark/clip_benchmark/datasets/kitti.py