diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-01-21 14:51:12 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-01-21 14:51:12 +0100 |
| commit | de61064981ab1643a450935e3055b871a69426ea (patch) | |
| tree | 64b5b668f5a87f1d83b76266e5fb8cfcf9a0323c /cli/app/search/search_class.py | |
| parent | b503a0b47c5f85e380fa4ab24deed2420456ae5f (diff) | |
tf min
Diffstat (limited to 'cli/app/search/search_class.py')
| -rw-r--r-- | cli/app/search/search_class.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cli/app/search/search_class.py b/cli/app/search/search_class.py index ccb10cd..970d25f 100644 --- a/cli/app/search/search_class.py +++ b/cli/app/search/search_class.py @@ -113,7 +113,7 @@ def find_nearest_vector(sess, generator, opt_fp_in, opt_dims, out_images, out_la ## normalize the Y encoding # normalized_labels = tf.nn.l2_normalize(input_y) # tf.reduce_mean(tf.abs(encoding - gen_encoding)) - normalized_labels = input_y / tf.reduce_max(input_y) + normalized_labels = input_y / tf.min(1.0, tf.reduce_max(input_y)) normalized_alpha = tf.compat.v1.placeholder(dtype=np.float32, shape=()) clip_labels = tf.assign(input_y, normalized_labels * (1 - normalized_alpha) + input_y * normalized_alpha) @@ -164,7 +164,7 @@ def find_nearest_vector(sess, generator, opt_fp_in, opt_dims, out_images, out_la train_step_z = tf.train.AdamOptimizer(z_lr).minimize(loss, var_list=[input_z], name='AdamOpterZ') train_step_y = tf.train.AdamOptimizer(y_lr).minimize(loss, var_list=[input_y], name='AdamOpterY') - target_im, fp_frames, fn_base = load_target_image(opt_fp_in) + target_im, fp_frames, fn_base = load_target_image(opt_fp_in, opt_video) # crop image and convert to format for next script phi_target_for_inversion = resize_and_crop_image(target_im, 512) @@ -216,13 +216,14 @@ def find_nearest_vector(sess, generator, opt_fp_in, opt_dims, out_images, out_la out_latent[index] = z_guess return fp_frames -def load_target_image(opt_fp_in): +def load_target_image(opt_fp_in, opt_video): print("Loading {}".format(opt_fp_in)) fn = os.path.basename(opt_fp_in) fn_base, ext = os.path.splitext(fn) fp_frames = "frames_{}_{}".format(fn_base, timestamp()) fp_frames_fullpath = join(app_cfg.DIR_OUTPUTS, fp_frames) print("Output to {}".format(fp_frames_fullpath)) - os.makedirs(fp_frames_fullpath, exist_ok=True) + if opt_video: + os.makedirs(fp_frames_fullpath, exist_ok=True) target_im = imread(opt_fp_in) return target_im, fp_frames, fn_base |
