def __init__(self, input_file_path, images_per_batch=50, train_percentage=0.8, max_sample_records=1000): self.input_file_path = input_file_path folders = os.listdir(self.input_file_path) folders = sanitize_data_folders(folders) self.train_folders, self.test_folders = Dataset.train_test_split( folders) self.train_percentage = train_percentage self.max_sample_records = max_sample_records self.train_metadata_summaries, self.train_metadata = summarize_metadata( self.input_file_path, self.train_folders) self.train_folder_weights = self.get_folder_weights(self.train_folders) self.test_metadata_summaries, self.test_metadata = summarize_metadata( self.input_file_path, self.test_folders) self.test_folder_weights = self.get_folder_weights(self.test_folders) self.images_per_batch = images_per_batch self.images_per_epoch = int( self.train_metadata_summaries['image_count'] * self.train_percentage) self.batches_per_epoch = int(self.images_per_epoch / self.images_per_batch) self.samples_per_epoch = int(self.images_per_epoch / self.max_sample_records)
def __init__(self,input_file_path,images_per_batch=50,train_percentage=0.8, max_sample_records=1000): self.input_file_path = input_file_path folders = os.listdir(self.input_file_path) folders = sanitize_data_folders(folders) self.train_percentage = train_percentage self.train_folders, self.test_folders = self.train_test_split(folders) self.max_sample_records = max_sample_records self.train_metadata_summaries, self.train_metadata = summarize_metadata(self.input_file_path,self.train_folders) self.train_folder_weights = self.get_folder_weights(self.train_folders) self.test_metadata_summaries, self.test_metadata = summarize_metadata(self.input_file_path, self.test_folders) self.test_folder_weights = self.get_folder_weights(self.test_folders) self.images_per_batch = images_per_batch self.images_per_epoch = self.train_metadata_summaries['image_count'] self.batches_per_epoch = int(self.images_per_epoch / self.images_per_batch) self.samples_per_epoch = int(self.images_per_epoch / self.max_sample_records)
def __init__(self,input_file_path,images_per_batch=50,images_per_sample=3000,train_percentage=0.8): self.input_file_path = input_file_path folders = os.listdir(input_file_path) self.train_folders, self.test_folders = self.train_test_split(folders) metadata_summaries = summarize_metadata(input_file_path) self.train_percentage = train_percentage self.images_per_batch = images_per_batch self.images_per_sample = images_per_sample self.images_per_epoch = int(metadata_summaries['image_count'] * self.train_percentage) self.samples_per_epoch = int(self.images_per_epoch / self.images_per_sample)
def get_folder_weights(self,folders): folder_weights = {} metadata_summaries, folder_metadata = summarize_metadata(self.input_file_path, include_folders=folders) images_processed = 0 for folder, metadata in folder_metadata.items(): upper_bound = images_processed + metadata['image_count'] folder_weights[folder] = {'lower_bound': images_processed, 'upper_bound': upper_bound, 'weight': metadata['image_count'] / metadata_summaries['image_count']} images_processed = upper_bound return folder_weights
def get_folder_weights(self, folders): folder_weights = {} metadata_summaries, folder_metadata = summarize_metadata( self.input_file_path, include_folders=folders) images_processed = 0 for folder, metadata in folder_metadata.items(): upper_bound = images_processed + metadata['image_count'] folder_weights[folder] = { 'lower_bound': images_processed, 'upper_bound': upper_bound, 'weight': metadata['image_count'] / metadata_summaries['image_count'] } images_processed = upper_bound return folder_weights