diff options
| -rw-r--r-- | inversion/live.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/inversion/live.py b/inversion/live.py index 9e9c5c3..64f400d 100644 --- a/inversion/live.py +++ b/inversion/live.py @@ -125,9 +125,11 @@ class LerpParam: if self.n.value > 0.5: self.a.randomize() self.direction = -1 + return self.a else: self.b.randomize() self.direction = 1 + return self.b def update(self, dt): if self.direction != 0: @@ -238,6 +240,16 @@ class Interpolator: else: sys.stderr.write('{} not a valid option\n'.format(key)) + def set_category(self, category): + categories = " ".split(category) + label = np.zeros((BATCH_SIZE, N_CLASS,)) + ratio = 1 / len(categories) + target_param = self.lerp_params[payload].switch() + for category in categories: + index = int(category) + label[0, index] = ratio + target_param.assign(label) + def on_step(self, i, dt, sess): for param in self.sin_params.values(): param.update(dt) @@ -250,6 +262,8 @@ class Interpolator: print("Command: {} {}".format(cmd, payload)) if cmd == 'switch' and payload in self.lerp_params: self.lerp_params[payload].switch() + if cmd == 'setCategory': + self.set_category(payload) pass # -------------------------- |
