def get_num_objects(tree):
    """ Get number of objects in an image.

    Args:
        tree: Tree element of xml file.

    Returns: Number of objects.

    """
    num_obj = 0

    for e in tree.iter():
        if e.tag == 'object':
            num_obj = num_obj + 1

    return num_obj