Source code for iaa_od.utils.load_categories

[docs] def load_categories_dictionary(filepath: str) -> dict[int, str]: """ Load categories from a JSON file and return a dictionary mapping category IDs to names. Parameters: filepath (str): Path to the JSON file containing categories. Returns: dict: A dictionary mapping category IDs to category names. """ import json with open(filepath, 'r') as file: data = json.load(file) return {int(category['id']): category['name'] for category in data['categories']}