summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2019-12-18 23:53:33 +0100
committerJules Laplace <julescarbon@gmail.com>2019-12-18 23:53:33 +0100
commit559966019c005175169ed5a68edce9ce8acc0785 (patch)
tree9931fb264c3c7a74f66e3ff76b34af94bebf34ac
parent20b9de678860a20ba7eae69b2b7843456fc08e32 (diff)
parent284d899063fb9401414e302e21966d1ac1b7c0ff (diff)
merge
-rw-r--r--inversion/live.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/inversion/live.py b/inversion/live.py
index 3ca7717..4e42703 100644
--- a/inversion/live.py
+++ b/inversion/live.py
@@ -50,7 +50,7 @@ def sin(opts, key, shape):
noise = lerp(opts, key + '_noise', shape)
scale = InterpolatorParam(name=key + '_scale')
time = opts['global']['time'].variable
- out = tf.sin(time + noise) * scale
+ out = tf.sin(time + noise) * scale.variable
opts[key] = {
'scale': scale,
}
@@ -60,7 +60,7 @@ def lerp(opts, key, shape):
a = InterpolatorParam(name=key + '_a', shape=shape)
b = InterpolatorParam(name=key + '_b', shape=shape)
n = InterpolatorParam(name=key + '_n')
- out = a * (1 - n) + b * n
+ out = a.variable * (1 - n.variable) + b.variable * n.variable
opts[key] = {
'a': a,
'b': b,
@@ -89,16 +89,15 @@ class Interpolator:
'time': InterpolatorParam(name='t', value=time.time())
},
}
- self.t = time.time()
def build(self):
lerp_z = lerp(self.opts, 'latent', [BATCH_SIZE, Z_DIM])
sin_z = sin(self.opts, 'sin_z', [BATCH_SIZE, Z_DIM])
lerp_label = lerp(self.opts, 'label', [BATCH_SIZE, N_CLASS])
- self.opts['threshold'] = InterpolatorParam('threshold', value=1.0)
+ self.opts['truncation'] = InterpolatorParam('truncation', value=1.0)
gen_in = {}
- gen_in['threshold'] = self.opts['threshold'].variable
+ gen_in['truncation'] = self.opts['truncation'].variable
gen_in['z'] = lerp_z + sin_z
gen_in['y'] = lerp_label
gen_img = generator(gen_in, signature=gen_signature)
@@ -124,14 +123,14 @@ class Interpolator:
def set_value(self, key, value):
self.opts[key].assign(value).eval(session=sess)
- def on_step(i):
+ def on_step(self, i):
gen_time = time.time()
self.opts['global']['time'].assign(gen_time).eval(session=sess)
gen_images = sess.run(self.gen_img)
print("Generation time: {:.1f}s".format(time.time() - gen_time))
return gen_images
- def run(cmd, payload):
+ def run(self, cmd, payload):
# do things like create a new B and interpolate to it
pass