def add_classification_categories(json_object, classes_file):
    """
    Reads the name of classes from the file *classes_file* and adds them to
    the JSON object *json_object*. The function assumes that the first line
    corresponds to output no. 0, i.e. we use 0-based indexing.

    Modifies json_object in-place.

    Args:
    json_object: an object created from a json in the format of the detection API output
    classes_file: the list of classes that correspond to the output elements of the classifier

    Return:
    The modified json_object with classification_categories added. If the field 'classification_categories'
    already exists, then this function is a no-op.
    """

    if ('classification_categories' not in json_object.keys()) or (len(json_object['classification_categories']) == 0):

        # Read the name of all classes
        with open(classes_file, 'rt') as fi:
            class_names = fi.read().splitlines()
            # remove empty lines
            class_names = [cn for cn in class_names if cn.strip()]

        # Create field with name *classification_categories*
        json_object['classification_categories'] = dict()
        # Add classes using 0-based indexing
        for idx, name in enumerate(class_names):
            json_object['classification_categories']['%i'%idx] = name
    else:
        print('WARNING: The input json already contains the list of classification categories.')

    return json_object