MCPcopy
hub / github.com/luyishisi/Anti-Anti-Spider / get_verify_batch

Method get_verify_batch

train_model.py:104–119  ·  view source on GitHub ↗
(self, size=50)

Source from the content-addressed store, hash-verified

102 return batch_x, batch_y
103
104 def get_verify_batch(self, size=50):
105 batch_x = np.zeros([size, self.image_height * self.image_width]) # 初始化
106 batch_y = np.zeros([size, self.max_captcha * self.char_set_len]) # 初始化
107
108 verify_images = []
109 for i in range(size):
110 # TODO:
111 verify_images.append(random.choice(self.train_images_list))
112
113 for i, img_name in enumerate(verify_images):
114 # TODO:
115 label, image_array = self.gen_captcha_text_image(self.train_img_path, img_name)
116 image_array = self.convert2gray(image_array) # 灰度化图片
117 batch_x[i, :] = image_array.flatten() / 255 # flatten 转为一维
118 batch_y[i, :] = self.text2vec(label) # 生成 oneHot
119 return batch_x, batch_y
120
121 def train(self):
122 y_pred = self.alexnet_model()

Callers 1

trainMethod · 0.95

Calls 3

convert2grayMethod · 0.80
text2vecMethod · 0.80

Tested by

no test coverage detected