isomapPCA.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:FaceAnalysis 作者: ElliotSalisbury 项目源码 文件源码
def trainPCA(dstFolder, BATCH_SIZE = 50):
    ipca = IncrementalPCA(n_components=10, batch_size=BATCH_SIZE)

    for batch_isomaps_path in glob.glob(os.path.join(dstFolder, "*_isomaps_centered.p")):
        batch_num = int(os.path.basename(batch_isomaps_path).split("_")[0])

        isomaps = pickle.load(open(batch_isomaps_path, "rb"))

        # remove the illumination and count channel
        isomaps_just_color = isomaps[:,:,:,1:3]

        #flatten to data
        X = isomaps_just_color.reshape(isomaps_just_color.shape[0], -1)  # ,isomaps_just_color.shape[3])

        ipca.partial_fit(X)

    with open(os.path.join(dstFolder, "pca.p"), "wb") as file:
        pickle.dump(ipca, file)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号