def create_classification_imageset(folder, image_size=None, image_count=None, add_unbalanced_category=False):
    if image_size is None:
        image_size = IMAGE_SIZE
    if image_count is None:
        image_count = IMAGE_COUNT

    # Stores the relative path of each image of the dataset
    paths = defaultdict(list)

    config = [
            ('red-to-right', 0, 0,   image_count),
            ('green-to-top', 1, 90,  image_count),
            ('blue-to-left', 2, 180, image_count),
            ]

    if add_unbalanced_category:
        config.append( ('blue-to-bottom', 2, 270, image_count/2) )

    for class_name, pixel_index, rotation, image_count in config:
        os.makedirs(os.path.join(folder, class_name))

        colors = np.linspace(200, 255, image_count)
        for i, color in enumerate(colors):
            pixel = [0, 0, 0]
            pixel[pixel_index] = color
            pil_img = _create_gradient_image(image_size, (0, 0, 0), pixel, rotation)
            img_path = os.path.join(class_name, str(i) + '.png')
            pil_img.save(os.path.join(folder, img_path))
            paths[class_name].append(img_path)

    return paths
Can the garbage collector clean up a cycle with traits objects?
dataset/ETHPy150Open NVIDIA/DIGITS/digits/dataset/images/classification/test_imageset_creator.py/create_classification_imageset--crossover with--dataset/ETHPy150Open enthought/traits/traits/tests/test_trait_cycle.py/TestCase._simple_cycle_helper