Advertisement
Guest User

Suspicious diffgan changes

a guest
Nov 18th, 2020
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.11 KB | None | 0 0
  1. -def _transform_imagnet_image(image, target_image_shape, crop_method, seed, random_flip):
  2. +def _transform_imagnet_image(image, target_image_shape, crop_method, seed):
  3.    """Preprocesses ImageNet images to have a target image shape.
  4.  
  5.    Args:
  6. @@ -473,28 +469,10 @@ def _transform_imagnet_image(image, target_image_shape, crop_method, seed, rando
  7.      begin = tf.cast(begin, tf.int32)
  8.      begin = tf.concat([begin, [0]], axis=0)  # Add channel dimension.
  9.      image = tf.slice(image, begin, [size, size, 3])
  10. -  elif crop_method == "zoomed":
  11. -    shape = tf.shape(image)
  12. -    h, w = shape[0], shape[1]
  13. -    size = tf.minimum(h, w)
  14. -    begin, size, _ = tf.image.sample_distorted_bounding_box(
  15. -        [size, size, shape[2]],
  16. -        tf.zeros([0, 0, 4], tf.float32),
  17. -        aspect_ratio_range=[1.0, 1.0],
  18. -        area_range=[0.5, 1.0],
  19. -        use_image_if_no_bounding_boxes=True,
  20. -        seed=seed)
  21. -    begin = tf.cast([h - size[0], w - size[1], 0], tf.int32) // 2
  22. -    image = tf.slice(image, begin, size)
  23. -    # Unfortunately, the above operation loses the depth-dimension. So we need
  24. -    # to restore it the manual way.
  25. -    image.set_shape([None, None, target_image_shape[-1]])
  26.    elif crop_method != "none":
  27.      raise ValueError("Unsupported crop method: {}".format(crop_method))
  28.    image = tf.image.resize_images(
  29.        image, [target_image_shape[0], target_image_shape[1]])
  30. -  if random_flip:
  31. -    image = tf.image.random_flip_left_right(image, seed=seed)
  32.    image.set_shape(target_image_shape)
  33.    return image
  34.  
  35. diff --git a/DiffAugment-biggan-imagenet/compare_gan/eval_gan_lib.py b/DiffAugment-biggan-imagenet/compare_gan/eval_gan_lib.py
  36. index cb7af7d..aa84e59 100644
  37. --- a/DiffAugment-biggan-imagenet/compare_gan/eval_gan_lib.py
  38. +++ b/DiffAugment-biggan-imagenet/compare_gan/eval_gan_lib.py
  39. @@ -93,7 +93,7 @@ def _update_bn_accumulators(sess, generated, num_accu_examples):
  40.  
  41.  
  42.  def evaluate_tfhub_module(module_spec, eval_tasks, use_tpu,
  43. -                          num_averaging_runs, update_bn_accumulators=True, use_tags=True):
  44. +                          num_averaging_runs):
  45.    """Evaluate model at given checkpoint_path.
  46.  
  47.    Args:
  48. @@ -129,7 +129,7 @@ def evaluate_tfhub_module(module_spec, eval_tasks, use_tpu,
  49.          generator = hub.Module(
  50.              module_spec,
  51.              name="gen_module",
  52. -            tags={"gen", "bs{}".format(batch_size)} if use_tags else None)
  53. +            tags={"gen", "bs{}".format(batch_size)})
  54.          logging.info("Generator inputs: %s", generator.get_input_info_dict())
  55.          z_dim = generator.get_input_info_dict()["z"].get_shape()[1].value
  56.          z = z_generator(shape=[batch_size, z_dim])
  57. @@ -153,7 +153,7 @@ def evaluate_tfhub_module(module_spec, eval_tasks, use_tpu,
  58.        tf.global_variables_initializer().run()
  59.  
  60.  
  61. -      if update_bn_accumulators and _update_bn_accumulators(sess, generated, num_accu_examples=204800):
  62. +      if _update_bn_accumulators(sess, generated, num_accu_examples=204800):
  63.          saver = tf.train.Saver()
  64.          save_path = os.path.join(module_spec, "model-with-accu.ckpt")
  65.          checkpoint_path = saver.save(
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement