def make_img(self, x, l, s, num_lm, random=0): if random == 0: lm = Variable(xp.clip(l.data, 0, 1)) sm = Variable(xp.clip(s.data, 0, 1)) else: eps = xp.random.normal(0, 1, size=l.data.shape).astype(xp.float32) epss = xp.random.normal(0, 1, size=s.data.shape).astype(xp.float32) sm = xp.clip((s.data + xp.sqrt(self.var) * epss), 0, 1).astype(xp.float32) lm = xp.clip(l.data + eps * xp.sqrt(self.vars), 0, 1) sm = Variable(sm) lm = Variable(lm.astype(xp.float32)) if self.use_gpu: xm = make_sampled_image.generate_xm_rgb_gpu(lm.data, sm.data, x, num_lm, g_size=self.gsize) else: xm = make_sampled_image.generate_xm_rgb(lm.data, sm.data, x, num_lm, g_size=self.gsize) return xm, lm, sm
def make_img(self, x, l, num_lm, random=0): if random == 0: lm = Variable(xp.clip(l.data, 0, 1)) else: eps = xp.random.normal(0, 1, size=l.data.shape).astype(xp.float32) lm = xp.clip(l.data + eps * xp.sqrt(self.vars), 0, 1) lm = Variable(lm.astype(xp.float32)) if self.use_gpu: xm = make_sampled_image.generate_xm_const_size_gpu( lm.data, self.gsize, x.data, num_lm, g_size=self.gsize, img_size=self.img_size) else: xm = make_sampled_image.generate_xm_const_size( lm.data, self.gsize, x.data, num_lm, g_size=self.gsize, img_size=self.img_size) return xm, lm
def reconstruct_audio(compressed, reference): power = xp.sqrt(xp.power(compressed, 1 / 0.3))[:, 0, :, :] power = chainer.cuda.to_cpu(power).T reference = chainer.cuda.to_cpu(reference).T reference = reference[:, :, 0, :] + reference[:, :, 1, :] * 1j phase = np.exp(1.0j * np.angle(reference)) stft = power * phase return stft
def make_img(self, x, l, num_lm, random=0): s = xp.log10(xp.ones((1, 1)) * self.gsize / self.img_size) + 1 sm = xp.repeat(s, num_lm, axis=0) if random == 0: lm = Variable(xp.clip(l.data, 0, 1)) else: eps = xp.random.normal(0, 1, size=l.data.shape).astype(xp.float32) lm = xp.clip(l.data + eps * xp.sqrt(self.vars), 0, 1) lm = Variable(lm.astype(xp.float32)) if self.use_gpu: xm = make_sampled_image.generate_xm_rgb_gpu(lm.data, sm, x, num_lm, g_size=self.gsize) else: xm = make_sampled_image.generate_xm_rgb(lm.data, sm, x, num_lm, g_size=self.gsize) return xm, lm