def _read_data(self, dataset_root_dir): dataset_dir = self.dataset_dir(dataset_root_dir) positive_file_name = self._positive_file_name(dataset_dir) part_file_name = self._part_file_name(dataset_dir) negative_file_name = self._negative_file_name(dataset_dir) image_list_file_name = self._image_list_file_name(dataset_dir) tensorflow_file_names = [positive_file_name, part_file_name, negative_file_name, image_list_file_name] positive_ratio = 1.0/6 part_ratio = 1.0/6 landmark_ratio = 1.0/6 negative_ratio = 3.0/6 positive_batch_size = int(np.ceil(self._batch_size*positive_ratio)) part_batch_size = int(np.ceil(self._batch_size*part_ratio)) negative_batch_size = int(np.ceil(self._batch_size*negative_ratio)) landmark_batch_size = int(np.ceil(self._batch_size*landmark_ratio)) batch_sizes = [positive_batch_size, part_batch_size, negative_batch_size, landmark_batch_size] self._number_of_samples = 0 for d in tensorflow_file_names: self._number_of_samples += sum(1 for _ in tf.python_io.tf_record_iterator(d)) image_size = self.network_size() tensorflow_dataset = TensorFlowDataset() return(tensorflow_dataset.read_tensorflow_files(tensorflow_file_names, batch_sizes, image_size))
def _read_data(self, dataset_root_dir): dataset_dir = self.dataset_dir(dataset_root_dir) tensorflow_file_name = self._image_list_file_name(dataset_dir) self._number_of_samples = 0 self._number_of_samples = sum(1 for _ in tf.python_io.tf_record_iterator(tensorflow_file_name)) image_size = self.network_size() tensorflow_dataset = TensorFlowDataset() return(tensorflow_dataset.read_tensorflow_file(tensorflow_file_name, self._batch_size, image_size))
def _generate_dataset(self, target_root_dir): tensorflow_dataset = TensorFlowDataset() print('Generating TensorFlow dataset for positive images.') if (not tensorflow_dataset.generate( SimpleFaceDataset.positive_file_name(target_root_dir), target_root_dir, 'positive')): print('Error generating TensorFlow dataset for positive images.') return (False) print('Generated TensorFlow dataset for positive images.') print('Generating TensorFlow dataset for partial images.') if (not tensorflow_dataset.generate( SimpleFaceDataset.part_file_name(target_root_dir), target_root_dir, 'part')): print('Error generating TensorFlow dataset for partial images.') return (False) print('Generated TensorFlow dataset for partial images.') print('Generating TensorFlow dataset for negative images.') if (not tensorflow_dataset.generate( SimpleFaceDataset.negative_file_name(target_root_dir), target_root_dir, 'negative')): print('Error generating TensorFlow dataset for negative images.') return (False) print('Generated TensorFlow dataset for negative images.') print('Generating TensorFlow dataset for landmark images.') if (not tensorflow_dataset.generate( self._image_list_file_name(target_root_dir), target_root_dir, 'image_list')): print('Error generating TensorFlow dataset for landmark images.') return (False) print('Generated TensorFlow dataset for landmark images.') return (True)
def _image_list_file_name(self, dataset_dir): image_list_file_name = TensorFlowDataset.tensorflow_file_name( dataset_dir, 'image_list') return (image_list_file_name)
def _negative_file_name(self, dataset_dir): negative_file_name = TensorFlowDataset.tensorflow_file_name( dataset_dir, 'negative') return (negative_file_name)
def _part_file_name(self, dataset_dir): part_file_name = TensorFlowDataset.tensorflow_file_name( dataset_dir, 'part') return (part_file_name)
def _positive_file_name(self, dataset_dir): positive_file_name = TensorFlowDataset.tensorflow_file_name( dataset_dir, 'positive') return (positive_file_name)
def _generate_dataset(self, target_root_dir): tensorflow_dataset = TensorFlowDataset() if(not tensorflow_dataset.generate(self._image_list_file_name(target_root_dir), target_root_dir, 'image_list')): return(False) return(True)