def init_from_storage_write_to_datastore(self,
                                           batch_size=100,
                                           allowed_epsilon=None,
                                           skip_image_ids=None,
                                           max_num_images=None):
    """Initializes dataset batches from the list of images in the datastore.

    Args:
      batch_size: batch size
      allowed_epsilon: list of allowed epsilon or None to use default
      skip_image_ids: list of image ids to skip
      max_num_images: maximum number of images to read
    """
    if allowed_epsilon is None:
      allowed_epsilon = copy.copy(DEFAULT_EPSILON)
    # init dataset batches from data in storage
    self._dataset_batches = {}
    # read all blob names from storage
    images = self._read_image_list(skip_image_ids)
    if max_num_images:
      images = images[:max_num_images]
    for batch_idx, batch_start in enumerate(range(0, len(images), batch_size)):
      batch = images[batch_start:batch_start+batch_size]
      batch_id = DATASET_BATCH_ID_PATTERN.format(batch_idx)
      batch_epsilon = allowed_epsilon[batch_idx % len(allowed_epsilon)]
      self.add_batch(batch_id, {'epsilon': batch_epsilon})
      for image_id, image_path in batch:
        self.add_image(batch_id, image_id,
                       {'dataset_image_id': os.path.basename(image_path)[:-4],
                        'image_path': image_path})
    # write data to datastore
    self.write_to_datastore()
def init_from_storage_write_to_datastore ( self , batch_size = 100 , allowed_epsilon = None , skip_image_ids = None , max_num_images = None ) : if allowed_epsilon is None : allowed_epsilon = copy . copy ( DEFAULT_EPSILON ) self . _dataset_batches = { } images = self . _read_image_list ( skip_image_ids ) if max_num_images : images = images [ : max_num_images ] for batch_idx , batch_start in enumerate ( range ( 0 , len ( images ) , batch_size ) ) : batch = images [ batch_start : batch_start + batch_size ] batch_id = DATASET_BATCH_ID_PATTERN . format ( batch_idx ) batch_epsilon = allowed_epsilon [ batch_idx % len ( allowed_epsilon ) ] self . add_batch ( batch_id , { 'epsilon' : batch_epsilon } ) for image_id , image_path in batch : self . add_image ( batch_id , image_id , { 'dataset_image_id' : os . path . basename ( image_path ) [ : - 4 ] , 'image_path' : image_path } ) self . write_to_datastore ( )
Initializes dataset batches from the list of images in the datastore.

    Args:
      batch_size: batch size
      allowed_epsilon: list of allowed epsilon or None to use default
      skip_image_ids: list of image ids to skip
      max_num_images: maximum number of images to read