Siamese网络
就是两个共享参数的CNN。每次的输入是一对图像+1个label,共3个值。注意label=0或1(又称正负样本),表示输入的两张图片match(匹配、同一个人)或no-match(不匹配、非同一人)
数据采用的是AT&T人脸数据。共40个人,每个人有10张脸。数据下载:AT&T
import os
root = '/datasets/att_faces/'
txt_root = './datasets/train.txt'
train_batch_size = 32
train_number_epochs = 30
def convert(train=True):
if(train):
f=open(txt_root, 'w')
data_path= root
if(not os.path.exists(data_path)):
os.makedirs(data_path)
for i in range(40):
for j in range(10):
img_path = data_path+'s'+str(i+1)+'/'+str(j+1)+'.pgm'
f.write(img_path+' '+str(i)+'\n')
f.close()
if __name__ == '__main__':
convert(train=True)
生成结果:
存储结构:
参考:https://blog.csdn.net/weixin_44791964/article/details/107343394
https://www.cnblogs.com/king-lps/p/8342452.html