def train_model(train_data, target_path, extracted_pixels_by_mean_shape, mean_shape): regressors = [] for i in range(Cascades): curr_regr = Regressor(mean_shape, extracted_pixels_by_mean_shape) curr_regr.train(train_data) regressors.append(curr_regr) print("Finished regressor number 1") with open(target_path, 'wb') as target: pickle.dump(regressors, target)