import json


def translate_classes(classes, json_file):
    """
    Convert torch model outputs to human-readable categories

    Parameters
    ----------
    classes : array-like
        Numerical class output of the neural network
    json_file : str
        Path to json file with category/class mapping

    Returns
    -------
    list
        List of strings with human-readable predicted classes
    """

    with open(json_file, 'r') as f:
        category_mapper = json.load(f)
    classes = list(map(str, classes))
    names = list(map(category_mapper.get, classes))
    names = [x if x is not None else 'name not available' for x in names]

    return names