def run(self, shape): init_sampler = self.make_sampler("bach", temperature=FLAGS.temperature) pianorolls, masks = self.blank_slate(shape) pianorolls = init_sampler(pianorolls, masks) masks = lib_sampling.HarmonizationMasker()(shape) gibbs = self.make_sampler("gibbs", masker=lib_sampling.BernoulliMasker(), sampler=self.make_sampler( "independent", temperature=FLAGS.temperature), schedule=lib_sampling.YaoSchedule()) with self.logger.section("context"): context = np.array([ lib_mask.apply_mask(pianoroll, mask) for pianoroll, mask in zip(pianorolls, masks) ]) self.logger.log(pianorolls=context, masks=masks, predictions=context) pianorolls = gibbs(pianorolls, masks) with self.logger.section("result"): self.logger.log(pianorolls=pianorolls, masks=masks, predictions=pianorolls) return pianorolls
def run(self, tuple_in): try: shape, midi_in = tuple_in mroll = self.load_midi_melody(midi_in) except: shape = tuple_in mroll = self.load_midi_melody(None) pianorolls = self.make_pianoroll_from_melody_roll(mroll, shape) masks = lib_sampling.HarmonizationMasker()(pianorolls.shape) gibbs = self.make_sampler("gibbs", masker=lib_sampling.BernoulliMasker(), sampler=self.make_sampler( "independent", temperature=FLAGS.temperature), schedule=lib_sampling.YaoSchedule()) with self.logger.section("context"): context = np.array([ lib_mask.apply_mask(pianoroll, mask) for pianoroll, mask in zip(pianorolls, masks) ]) self.logger.log(pianorolls=context, masks=masks, predictions=context) pianorolls = gibbs(pianorolls, masks) return pianorolls