def __init__(self, img_path, char_set, model_save_dir, verify=False):
    self.model_save_dir = model_save_dir
    self.img_path = img_path
    self.img_list = os.listdir(img_path)
    if verify:
        self.confirm_image_suffix()
    random.seed(time.time())
    random.shuffle(self.img_list)
    (label, captcha_array) = self.gen_captcha_text_image(self.img_list[0])
    captcha_shape = captcha_array.shape
    captcha_shape_len = len(captcha_shape)
    if (captcha_shape_len == 3):
        (image_height, image_width, channel) = captcha_shape
        self.channel = channel
    elif (captcha_shape_len == 2):
        (image_height, image_width) = captcha_shape
    else:
        raise TrainError('图片转换为矩阵时出错，请检查图片格式')
    self.image_height = image_height
    self.image_width = image_width
    self.max_captcha = len(label)
    self.char_set = char_set
    self.char_set_len = len(char_set)
    print('-->图片尺寸: {} X {}'.format(image_height, image_width))
    print('-->验证码长度: {}'.format(self.max_captcha))
    print('-->验证码共{}类 {}'.format(self.char_set_len, char_set))
    print('-->使用测试集为 {}'.format(img_path))
    self.X = tf.placeholder(tf.float32, [None, (image_height * image_width)])
    self.Y = tf.placeholder(tf.float32, [None, (self.max_captcha * self.char_set_len)])
    self.keep_prob = tf.placeholder(tf.float32)
    self.w_alpha = 0.01
    self.b_alpha = 0.1
    print('>>> Start model test')
    (batch_x, batch_y) = self.get_batch(0, size=100)
    print('>>> input batch images shape: {}'.format(batch_x.shape))
    print('>>> input batch labels shape: {}'.format(batch_y.shape))
def __init__(self, img_path, char_set, model_save_dir, verify=False):
    self.model_save_dir = model_save_dir
    self.img_path = img_path
    self.img_list = os.listdir(img_path)
    if verify:
        self.confirm_image_suffix()
    random.seed(time.time())
    random.shuffle(self.img_list)
    (label, captcha_array) = self.gen_captcha_text_image(self.img_list[0])
    captcha_shape = captcha_array.shape
    captcha_shape_len = len(captcha_shape)
    if (captcha_shape_len == 3):
        (image_height, image_width, channel) = captcha_shape
        self.channel = channel
    elif (captcha_shape_len == 2):
        (image_height, image_width) = captcha_shape
    else:
        raise TrainError('图片转换为矩阵时出错，请检查图片格式')
    self.image_height = image_height
    self.image_width = image_width
    self.max_captcha = len(label)
    self.char_set = char_set
    self.char_set_len = len(char_set)
    print('-->图片尺寸: {} X {}'.format(image_height, image_width))
    print('-->验证码长度: {}'.format(self.max_captcha))
    print('-->验证码共{}类 {}'.format(self.char_set_len, char_set))
    print('-->使用测试集为 {}'.format(img_path))
    self.X = tf.placeholder(tf.float32, [None, (image_height * image_width)])
    self.Y = tf.placeholder(tf.float32, [None, (self.max_captcha * self.char_set_len)])
    self.keep_prob = tf.placeholder(tf.float32)
    self.w_alpha = 0.01
    self.b_alpha = 0.1
    print('>>> Start model test')
    (batch_x, batch_y) = self.get_batch(0, size=100)
    print('>>> input batch images shape: {}'.format(batch_x.shape))
    print('>>> input batch labels shape: {}'.format(batch_y.shape))