class_docstr: Helper class to store data about images generated by attacks.
docstr: Clips results of attack and copy it to directory with all images.
  
  Args:
    attack_name: name of the attack.
    is_targeted: if True then attack is targeted, otherwise non-targeted.
docstr_tok: ["Clips","results","of","attack","and","copy","it","to","directory","with","all","images",".","Args",":","attack_name",":","name","of","the","attack",".","is_targeted",":","if","True","then","attack","is","targeted",",","otherwise","non-targeted","."]
code: def clip_and_copy_attack_outputs(self, attack_name, is_targeted):
      """Clips results of attack and copy it to directory with all images.
  
      Args:
        attack_name: name of the attack.
        is_targeted: if True then attack is targeted, otherwise non-targeted.
      """
      if is_targeted:
          self._targeted_attack_names.add(attack_name)
      else:
          self._attack_names.add(attack_name)
      attack_dir = os.path.join(
          self.targeted_attacks_output_dir
          if is_targeted
          else self.attacks_output_dir,
          attack_name,
      )
      for fname in os.listdir(attack_dir):
          if not (fname.endswith(".png") or fname.endswith(".jpg")):
              continue
          image_id = fname[:-4]
          if image_id not in self.dataset_max_clip:
              continue
          image_max_clip = self.dataset_max_clip[image_id]
          image_min_clip = self.dataset_min_clip[image_id]
          adversarial_image = np.array(
              Image.open(os.path.join(attack_dir, fname)).convert("RGB")
          )
          clipped_adv_image = np.clip(
              adversarial_image, image_min_clip, image_max_clip
          )
          output_basename = "{0:08d}".format(self._output_image_idx)
          self._output_image_idx += 1
          self._output_to_attack_mapping[output_basename] = (
              attack_name,
              is_targeted,
              image_id,
          )
          if is_targeted:
              self._targeted_attack_image_count += 1
          else:
              self._attack_image_count += 1
          Image.fromarray(clipped_adv_image).save(
              os.path.join(
                  self.all_adv_examples_dir, output_basename + ".png"
              )
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import argparse
  import csv
  import json
  import os
  import subprocess
  import numpy
  from PIL import Image
label_desc: Use image node_id 3 for calling the AttacksOutput obj's underlying member method code with example usage: obj.clip_and_copy_attack_outputs(attack_name, is_targeted) without return types