Exemplo n.º 1
0
meanShape = np.load("../data/meanFaceShape.npz")["meanShape"]

# print(meanShape.shape)  (68,2)
'''
commonSet = ImageServer(initialization='box')
commonSet.PrepareData(commonSetImageDirs, commonSetBoundingBoxFiles, meanShape, 0, 1000, False)
commonSet.LoadImages()
commonSet.CropResizeRotateAll()
commonSet.imgs = commonSet.imgs.astype(np.float32)
commonSet.NormalizeImages(trainSet) #去均值,除以标准差
# commonSet.NormalizeImages()
commonSet.Save(datasetDir, "commonSet.npz")


challengingSet = ImageServer(initialization='box')
challengingSet.PrepareData(challengingSetImageDirs, challengingSetBoundingBoxFiles, meanShape, 0, 1000, False)
challengingSet.LoadImages()
challengingSet.CropResizeRotateAll()
challengingSet.imgs = challengingSet.imgs.astype(np.float32)
challengingSet.NormalizeImages() #去均值,除以标准差
challengingSet.Save(datasetDir, "challengingSet.npz")
'''
w300Set = ImageServer(initialization='box')
w300Set.PrepareData(w300SetImageDirs, w300SetBoundingBoxFiles, meanShape, 0,
                    1000, False)
w300Set.LoadImages()
w300Set.CropResizeRotateAll()
w300Set.imgs = w300Set.imgs.astype(np.float32)
w300Set.NormalizeImages(trainSet)  #去均值,除以标准差
w300Set.Save(datasetDir, "w300Set.npz")
Exemplo n.º 2
0
    "../data/images/300W/01_Indoor/", "../data/images/300W/02_Outdoor/"
]
w300SetBoundingBoxFiles = [
    "../data/boxes300WIndoor.pkl", "../data/boxes300WOutdoor.pkl"
]

datasetDir = "../data/"

meanShape = np.load("../data/meanFaceShape.npz")["meanShape"]

commonSet = ImageServer(initialization='box')
commonSet.PrepareData(commonSetImageDirs, commonSetBoundingBoxFiles, meanShape,
                      0, 1000, False)
commonSet.LoadImages()
commonSet.CropResizeRotateAll()
commonSet.imgs = commonSet.imgs.astype(np.float32)
commonSet.Save(datasetDir, "commonSet.npz")

challengingSet = ImageServer(initialization='box')
challengingSet.PrepareData(challengingSetImageDirs,
                           challengingSetBoundingBoxFiles, meanShape, 0, 1000,
                           False)
challengingSet.LoadImages()
challengingSet.CropResizeRotateAll()
challengingSet.imgs = challengingSet.imgs.astype(np.float32)
challengingSet.Save(datasetDir, "challengingSet.npz")

w300Set = ImageServer(initialization='box')
w300Set.PrepareData(w300SetImageDirs, w300SetBoundingBoxFiles, meanShape, 0,
                    1000, False)
w300Set.LoadImages()
]
boundingBoxFiles = [
    "../data/py3boxesLFPWTrain.pkl", "../data/py3boxesHelenTrain.pkl",
    "../data/py3boxesAFW.pkl"
]

datasetDir = "../data/"

meanShape = np.load("../data/meanFaceShape.npz")["meanShape"]

print("Load trainSet")
trainSet = ImageServer(initialization='rect')  #相当于没有用bbx做训练,直接用的特征点截取框
trainSet.PrepareData(
    imageDirs, None, meanShape, 100, 100000, True
)  #准备好图片名list,对应图片landmark的list,和对应图片的bbx的list,和meanshape。令我疑惑的是,startIdx=100,nImgs=100000,,300W数据集可没有那么多图片
trainSet.LoadImages()  #读取图片,并对每张图调整好meanShape
trainSet.GeneratePerturbations(10, [0.2, 0.2, 20, 0.25])  #位移0.2,旋转20度,放缩+-0.25
# import pdb; pdb.set_trace()
trainSet.NormalizeImages()  #去均值,除以标准差
trainSet.Save(datasetDir)  #保存成字典形式,key为'imgs','initlandmarks','gtlandmarks'

print("Load validationSet")
validationSet = ImageServer(initialization='box')
validationSet.PrepareData(imageDirs, boundingBoxFiles, meanShape, 0, 100,
                          False)
validationSet.LoadImages()
validationSet.CropResizeRotateAll()
# import pdb; pdb.set_trace()
validationSet.imgs = validationSet.imgs.astype(np.float32)
validationSet.NormalizeImages(trainSet)
validationSet.Save(datasetDir)