def __init__(self, character_folders, num_classes, train_num, test_num):
    self.character_folders = character_folders
    self.num_classes = num_classes
    self.train_num = train_num
    self.test_num = test_num
    class_folders = random.sample(self.character_folders, self.num_classes)
    labels = np.array(range(len(class_folders)))
    labels = dict(zip(class_folders, labels))
    samples = dict()
    self.train_roots = []
    self.test_roots = []
    for c in class_folders:
        temp = [os.path.join(c, x) for x in os.listdir(c)]
        samples[c] = random.sample(temp, len(temp))
        random.shuffle(samples[c])
        self.train_roots += samples[c][:train_num]
        self.test_roots += samples[c][train_num:(train_num + test_num)]
    self.train_labels = [labels[self.get_class(x)] for x in self.train_roots]
    self.test_labels = [labels[self.get_class(x)] for x in self.test_roots]
def __init__(self, character_folders, num_classes, train_num, test_num):
    self.character_folders = character_folders
    self.num_classes = num_classes
    self.train_num = train_num
    self.test_num = test_num
    class_folders = random.sample(self.character_folders, self.num_classes)
    labels = np.array(range(len(class_folders)))
    labels = dict(zip(class_folders, labels))
    samples = dict()
    self.train_roots = []
    self.test_roots = []
    for c in class_folders:
        temp = [os.path.join(c, x) for x in os.listdir(c)]
        samples[c] = random.sample(temp, len(temp))
        random.shuffle(samples[c])
        self.train_roots += samples[c][:train_num]
        self.test_roots += samples[c][train_num:(train_num + test_num)]
    self.train_labels = [labels[self.get_class(x)] for x in self.train_roots]
    self.test_labels = [labels[self.get_class(x)] for x in self.test_roots]