summaryrefslogtreecommitdiff
path: root/cli/app/search
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-01-11 00:23:46 +0100
committerJules Laplace <julescarbon@gmail.com>2020-01-11 00:23:46 +0100
commit179f98c949dbeeb383d152e46610dd6789616231 (patch)
treee48ce022dfd09b06520a46bcf50a46a64ed68c6d /cli/app/search
parentb280b3b837b205e9283c0444bdb28bc2aa4e48ad (diff)
upload video script
Diffstat (limited to 'cli/app/search')
-rw-r--r--cli/app/search/live.py6
-rw-r--r--cli/app/search/search_dense.py16
-rw-r--r--cli/app/search/video.py6
3 files changed, 14 insertions, 14 deletions
diff --git a/cli/app/search/live.py b/cli/app/search/live.py
index b09575d..4c66873 100644
--- a/cli/app/search/live.py
+++ b/cli/app/search/live.py
@@ -374,6 +374,8 @@ class Listener:
interpolator.build()
self.rpc_client.send_status('processing', True)
tag = "biggan_" + timestamp()
+ path_out = os.path.join(app_cfg.RESULTS_DIR, tag)
+ os.makedirs(path_out, exist_ok=True)
dt = 1 / FPS
for i in range(99999):
if i == 0:
@@ -386,12 +388,10 @@ class Listener:
print("Exiting...")
break
if (i % 100) == 0 or i == 1:
- # print(gen_images.shape)
print("Step {}. Generation time: {:.2f}s".format(i, time.time() - gen_time))
out_img = vs.data2pil(gen_images[0])
if out_img is not None:
- # save image
- #if out_img.resize_before_sending:
+ out_img.save(os.path.join(path_out, "image_{:5d}.png".format(i)), format='png')
img_to_send = out_img.resize((256, 256), Image.BICUBIC)
meta = {
'i': i,
diff --git a/cli/app/search/search_dense.py b/cli/app/search/search_dense.py
index 3719de6..ac67d07 100644
--- a/cli/app/search/search_dense.py
+++ b/cli/app/search/search_dense.py
@@ -240,18 +240,18 @@ def find_dense_embedding_for_images(params):
feat_loss += tf.reduce_mean(feat_square_diff) * 0.25
img_feat_err += tf.reduce_mean(feat_square_diff, axis=1) * 0.25
- # gen_feat = gen_feat_ex["InceptionV3/Conv2d_3b_1x1"]
- # target_feat = target_feat_ex["InceptionV3/Conv2d_3b_1x1"]
- # feat_square_diff = tf.reshape(tf.square(gen_feat - target_feat), [BATCH_SIZE, -1])
- # feat_loss += tf.reduce_mean(feat_square_diff) * 0.25
- # img_feat_err += tf.reduce_mean(feat_square_diff, axis=1) * 0.25
-
- gen_feat = gen_feat_ex["InceptionV3/Mixed_6a"]
- target_feat = target_feat_ex["InceptionV3/Mixed_6a"]
+ gen_feat = gen_feat_ex["InceptionV3/Conv2d_3b_1x1"]
+ target_feat = target_feat_ex["InceptionV3/Conv2d_3b_1x1"]
feat_square_diff = tf.reshape(tf.square(gen_feat - target_feat), [BATCH_SIZE, -1])
feat_loss += tf.reduce_mean(feat_square_diff) * 0.25
img_feat_err += tf.reduce_mean(feat_square_diff, axis=1) * 0.25
+ # gen_feat = gen_feat_ex["InceptionV3/Mixed_6a"]
+ # target_feat = target_feat_ex["InceptionV3/Mixed_6a"]
+ # feat_square_diff = tf.reshape(tf.square(gen_feat - target_feat), [BATCH_SIZE, -1])
+ # feat_loss += tf.reduce_mean(feat_square_diff) * 0.25
+ # img_feat_err += tf.reduce_mean(feat_square_diff, axis=1) * 0.25
+
gen_feat = gen_feat_ex["InceptionV3/Mixed_7a"]
target_feat = target_feat_ex["InceptionV3/Mixed_7a"]
feat_square_diff = tf.reshape(tf.square(gen_feat - target_feat), [BATCH_SIZE, -1])
diff --git a/cli/app/search/video.py b/cli/app/search/video.py
index d8e3f3f..14d84b4 100644
--- a/cli/app/search/video.py
+++ b/cli/app/search/video.py
@@ -19,7 +19,7 @@ def export_video(fp_frames, fps=30):
call(cmd)
shutil.rmtree(os.path.join(app_cfg.DIR_OUTPUTS, fp_frames))
-def export_video_final(fp_frames, fps=25):
+def export_video_final(fp_frames, fp_out, fps=25):
print("Exporting video...")
cmd = [
'/home/lens/bin/ffmpeg',
@@ -33,8 +33,8 @@ def export_video_final(fp_frames, fps=25):
'-vf', 'fps=25',
'-pix_fmt', 'yuv420p',
'-s', '512x512',
- os.path.join(app_cfg.DIR_RENDERS, fp_frames + '.mp4')
+ fp_out
]
# print(' '.join(cmd))
call(cmd)
- # shutil.rmtree(os.path.join(app_cfg.DIR_OUTPUTS, fp_frames))
+ return fp_out