在Tensorflow使用CNN神经网络进行图像分类的时候,常常会面对,识别图像和网络训练的维度不同问题,记录一转换图像维度代码。
IMAGE_HEIGHT = 60
IMAGE_WIDTH = 160
char_set = number
CHAR_SET_LEN = len(char_set)
text2, image2 = gen_captcha_text_and_image()
text="kyb5"
image = cv2.imread("../data/image1.png")
f = plt.figure()
ax = f.add_subplot(111)
ax.text(0.1, 0.9,text, ha='center', va='center', transform=ax.transAxes)
plt.imshow(image)
plt.show()
image=image.transpose(0,1,2)
image=cv2.resize(image,(IMAGE_WIDTH,IMAGE_HEIGHT))
f = plt.figure()
ax = f.add_subplot(111)
ax.text(0.1, 0.9, text, ha='center', va='center', transform=ax.transAxes)
plt.imshow(image)
plt.show()
print(image.shape)
MAX_CAPTCHA = len(text)
print("-------------------------")
print(image2.shape)
print(text2)