summaryrefslogtreecommitdiff
path: root/cli/app
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-01-17 11:16:18 +0100
committerJules Laplace <julescarbon@gmail.com>2020-01-17 11:16:18 +0100
commit41718ee65026ff651a067de570b443db29f7a9cc (patch)
tree18ffdaefcf7e8d17c67d030f5700f5b3169938ad /cli/app
parent6608d8c5c64096bd0a4e4a225b412cb82b1325d8 (diff)
logging timing
Diffstat (limited to 'cli/app')
-rw-r--r--cli/app/search/live.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/cli/app/search/live.py b/cli/app/search/live.py
index 7d6e692..99c339f 100644
--- a/cli/app/search/live.py
+++ b/cli/app/search/live.py
@@ -412,6 +412,11 @@ class Listener:
tag = "biggan_" + timestamp()
path_out = os.path.join(app_cfg.DIR_RESULTS, tag)
os.makedirs(path_out, exist_ok=True)
+ gen_time_total = 0
+ to_pil_time_total = 0
+ save_time_total = 0
+ resize_time_total = 0
+ send_time_total = 0
for i in range(99999):
if i == 0:
print("Loading network...")
@@ -419,21 +424,40 @@ class Listener:
print("Processing!")
gen_time = time.time()
gen_images = interpolator.on_step(i, self.sess)
+ if i == 0:
+ continue
+ gen_time_total += time.time() - gen_time
+
if gen_images is None:
print("Exiting...")
break
+
if (i % 100) == 0 or i == 1:
print("Step {}. Generation time: {:.2f}s".format(i, time.time() - gen_time))
+
+ to_pil_time = time.time()
out_img = vs.data2pil(gen_images[0])
+ to_pil_time_total += time.time() - to_pil_time
+
if out_img is not None:
+ save_time = time.time()
out_img.save(os.path.join(path_out, "frame_{:05d}.png".format(i)), format='png')
+ save_time_total += time.time() - save_time
+
+ resize_time = time.time()
img_to_send = out_img.resize((256, 256), Image.BICUBIC)
+ resize_time_total += time.time() - resize_time
+
meta = {
'i': i,
'sequence_i': i,
'skip_i': 0,
'sequence_len': 99999,
}
+ send_time = time.time()
self.rpc_client.send_pil_image("frame_{:05d}.png".format(i+1), meta, img_to_send, 'jpg')
+ send_time_total += time.time() - send_time
+ if (i % 100) == 0 or i == 1:
+ print("gen: {:2f}, pil: {:2f}, save: {:2f}, resize: {:2f}, send: {:2f}".format(gen_time_total / i, to_pil_time_i / i, save_time_total / i, resize_time_total / i, send_time_total / i))
self.rpc_client.send_status('processing', False)
self.sess.close()