From 6e96d6198f5a7726e135ebae5228646ca8a22f2e Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 16 Jan 2020 02:22:03 +0100 Subject: less crazy iterations... and sorting --- cli/app/search/json.py | 4 ++-- cli/app/search/search_dense.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'cli/app/search') diff --git a/cli/app/search/json.py b/cli/app/search/json.py index ea70fd6..c50d716 100644 --- a/cli/app/search/json.py +++ b/cli/app/search/json.py @@ -16,7 +16,7 @@ def make_params_latent(tag): "out_dataset": os.path.join(app_cfg.DIR_INVERSES, tag, "dataset.latent.hdf5"), "inv_layer": "latent", "decay_lr": True, - "inv_it": 15000, + "inv_it": 5000, "generator_path": "https://tfhub.dev/deepmind/biggan-512/2", "attention_map_layer": "Generator_2/attention/Softmax:0", "pre_trained_latent": False, @@ -68,7 +68,7 @@ def make_params_dense(tag, folder_id): "dataset": os.path.join(app_cfg.DIR_INVERSES, tag, "dataset.latent.hdf5"), "inv_layer": "Generator_2/G_Z/Reshape:0", "decay_lr": False, - "inv_it": 15000, + "inv_it": 5000, "generator_path": "https://tfhub.dev/deepmind/biggan-512/2", "attention_map_layer": "Generator_2/attention/Softmax:0", "pre_trained_latent": True, diff --git a/cli/app/search/search_dense.py b/cli/app/search/search_dense.py index 6fba70d..066d946 100644 --- a/cli/app/search/search_dense.py +++ b/cli/app/search/search_dense.py @@ -327,20 +327,20 @@ def find_dense_embedding_for_images(params, opt_tag="inverse_" + timestamp(), op sample_labels = in_file['ytrain'][()] sample_fns = in_file['fn'][()] NUM_IMGS = sample_images.shape[0] # number of images to be inverted. + INFILL_IMGS = NUM_IMGS print("Number of images: {}".format(NUM_IMGS)) print("Batch size: {}".format(BATCH_SIZE)) def sample_images_gen(): - for i in range(int(NUM_IMGS / BATCH_SIZE)): + for i in range(int(INFILL_IMGS / BATCH_SIZE)): i_1, i_2 = i*BATCH_SIZE, (i+1)*BATCH_SIZE yield sample_images[i_1:i_2], sample_labels[i_1:i_2] image_gen = sample_images_gen() sample_latents = in_file['latent'] def sample_latent_gen(): - for i in range(int(NUM_IMGS / BATCH_SIZE)): + for i in range(int(INFILL_IMGS / BATCH_SIZE)): i_1, i_2 = i*BATCH_SIZE, (i+1)*BATCH_SIZE yield sample_latents[i_1:i_2] latent_gen = sample_latent_gen() - INFILL_IMGS = NUM_IMGS while INFILL_IMGS % BATCH_SIZE != 0: REMAINDER = 1 # BATCH_SIZE - (NUM_IMGS % BATCH_SIZE) INFILL_IMGS += REMAINDER @@ -444,7 +444,9 @@ def find_dense_embedding_for_images(params, opt_tag="inverse_" + timestamp(), op for i in range(BATCH_SIZE): out_i = out_pos + i if out_i >= NUM_IMGS: + print("{} >= {}, skipping...".format(out_i, NUM_IMGS)) continue + print("{}: {}".format(out_i, sample_fn)) sample_fn, ext = os.path.splitext(sample_fns[out_i]) image = Image.fromarray(images[i]) fp = BytesIO() -- cgit v1.2.3-70-g09d2