def make_color_balance(dataPath='./thor_DB_msdn.json'):
    print('-- make_color_balance --')
    with open(dataPath, 'r') as f:
        DB = json.load(f)
    idx_for_unique_cls = {}
    len_for_unique_cls = {}
    for (idx, data) in enumerate(DB):
        color_counts = {}
        for obj in data['objects']:
            if (obj['color'] in color_counts):
                color_counts[obj['color']] += 1
            else:
                color_counts[obj['color']] = 1
        values = np.array(list(color_counts.values()))
        if (sum((values > 0)) == 1):
            unique_cls = values.argmax()
            cls = list(color_counts.keys())[unique_cls]
            if (cls in idx_for_unique_cls):
                idx_for_unique_cls[cls].append(idx)
                len_for_unique_cls[cls] += values.max()
            else:
                idx_for_unique_cls[cls] = [idx]
                len_for_unique_cls[cls] = values.max()
    for (k, v) in len_for_unique_cls.items():
        print(((k + ': ') + str(v)))
def make_color_balance(dataPath='./thor_DB_msdn.json'):
    print('-- make_color_balance --')
    with open(dataPath, 'r') as f:
        DB = json.load(f)
    idx_for_unique_cls = {}
    len_for_unique_cls = {}
    for (idx, data) in enumerate(DB):
        color_counts = {}
        for obj in data['objects']:
            if (obj['color'] in color_counts):
                color_counts[obj['color']] += 1
            else:
                color_counts[obj['color']] = 1
        values = np.array(list(color_counts.values()))
        if (sum((values > 0)) == 1):
            unique_cls = values.argmax()
            cls = list(color_counts.keys())[unique_cls]
            if (cls in idx_for_unique_cls):
                idx_for_unique_cls[cls].append(idx)
                len_for_unique_cls[cls] += values.max()
            else:
                idx_for_unique_cls[cls] = [idx]
                len_for_unique_cls[cls] = values.max()
    for (k, v) in len_for_unique_cls.items():
        print(((k + ': ') + str(v)))