示例#1
0
def PointDistributionModel(imgFolder):
    '''LOAD IMAGES'''
    path_to_lfpw = Path(imgFolder)
    training_shapes = []
    for lg in print_progress(
            mio.import_landmark_files(path_to_lfpw / '*.pts', verbose=True)):
        training_shapes.append(lg['all'])
    '''TRAIN PDM MODEL'''
    shape_model = OrthoPDM(training_shapes, max_n_components=None)
    '''MODIFY PARAMETERS'''
    shape_model.n_active_components = 20
    shape_model.n_active_components = 0.95
    return shape_model
示例#2
0
    for i in range(len(labels)):
        landmarks_dataset[i] = string_array_to_np_array(labels.iloc[i])

    return landmarks_dataset


# input
dataset_csv_path = "/disk1/ofirbartal/Projects/Dataset/GANeratedHands_Release/dataset_csv/test_dataset.csv"

landmarks = process_csv_input(dataset_csv_path)

start = time.time()
# PDM
training_shapes = [PointCloud(l) for l in landmarks]
shape_model = OrthoPDM(training_shapes, max_n_components=None)
shape_model.n_active_components = 0.95
end = time.time()
# shape_model = import_pickle(Path('pdm_weights.pkl'))
print(shape_model)
print("PDM Training Time: {}s".format(end - start))
export_pickle(shape_model, Path('test_pdm_weights.pkl'), overwrite=True)

# shape_model.set_target(result_landmarks) # project the target
# shape_model.target # the projected target

# draw
#create canvas on which the triangles will be visualized
# canvas = np.full([400,400], 255).astype('uint8')

#convert to 3 channel RGB for fun colors!
# canvas = cv2.cvtColor(canvas,cv2.COLOR_GRAY2RGB)