Esempio n. 1
0
    def fetch_attacks_data(self):
        """Initializes data necessary to execute attacks.

        This method could be called multiple times, only first call does
        initialization, subsequent calls are noop.
        """
        if self.attacks_data_initialized:
            return
        # init data from datastore
        self.submissions.init_from_datastore()
        self.dataset_batches.init_from_datastore()
        self.adv_batches.init_from_datastore()
        # copy dataset locally
        if not os.path.exists(LOCAL_DATASET_DIR):
            os.makedirs(LOCAL_DATASET_DIR)
        eval_lib.download_dataset(
            self.storage_client,
            self.dataset_batches,
            LOCAL_DATASET_DIR,
            os.path.join(LOCAL_DATASET_COPY, self.dataset_name, "images"),
        )
        # download dataset metadata
        self.read_dataset_metadata()
        # mark as initialized
        self.attacks_data_initialized = True
Esempio n. 2
0
  def fetch_attacks_data(self):
    """Initializes data necessary to execute attacks.

    This method could be called multiple times, only first call does
    initialization, subsequent calls are noop.
    """
    if self.attacks_data_initialized:
      return
    # init data from datastore
    self.submissions.init_from_datastore()
    self.dataset_batches.init_from_datastore()
    self.adv_batches.init_from_datastore()
    # copy dataset locally
    if not os.path.exists(LOCAL_DATASET_DIR):
      os.makedirs(LOCAL_DATASET_DIR)
    eval_lib.download_dataset(self.storage_client, self.dataset_batches,
                              LOCAL_DATASET_DIR,
                              os.path.join(LOCAL_DATASET_COPY,
                                           self.dataset_name, 'images'))
    # download dataset metadata
    self.read_dataset_metadata()
    # mark as initialized
    self.attacks_data_initialized = True