def __init__(self, model_capacity='tiny', activation_layer='conv5-maxpool', name='pretrained_crepe', trainable=False): super(PretrainedCREPE, self).__init__(name=name, trainable=trainable) self._model_capacity = model_capacity self._activation_layer = activation_layer spectral_ops.reset_crepe() self._model = crepe.core.build_and_load_model(self._model_capacity) self.frame_length = 1024
def flush(self, step): """Add summaries for each metric and reset the state.""" # Start by logging the metrics result. logging.info('COMPUTING METRICS COMPLETE. FLUSHING ALL METRICS') metrics_str = ' | '.join('{}: {:0.3f}'.format(k, v.result()) for k, v in self.metrics.items()) logging.info(metrics_str) for name, metric in self.metrics.items(): tf.summary.scalar('metrics/{}'.format(name), metric.result(), step) metric.reset_states() spectral_ops.reset_crepe() # Reset CREPE global state
def flush(self): """Output metrics to tensorboard for global step.""" metrics_d = self.get_current_metrics() if self._verbose: logging.info('COMPUTING METRICS COMPLETE. FLUSHING ALL METRICS') metric_keys = ['ld_metric', 'f0_metric', 'f0_outlier_ratio'] metrics_str = ' | '.join( '{}: {:0.3f}'.format(m, metrics_d[m]) for m in metric_keys) logging.info(metrics_str) counts_keys = [ 'f0_gen_trackable_pitch_count', 'f0_gen_pitch_outlier_count', 'f0_gen_untrackable_pitch_count', 'f0_ground_truth_untrackable_pitch_count' ] counts_str = ' | '.join( '{}: {}'.format(c, metrics_d[c]) for c in counts_keys) logging.info(counts_str) summary = tf.Summary() for value_name in [ 'ld_metric', 'f0_metric', 'f0_outlier_ratio', ]: summary.value.add( tag='rt_metrics/' + value_name, simple_value=metrics_d[value_name]) for value_name in [ 'f0_gen_trackable_pitch_count', 'f0_gen_pitch_outlier_count', 'f0_gen_untrackable_pitch_count', 'f0_ground_truth_untrackable_pitch_count' ]: summary.value.add( tag='counts/' + value_name, simple_value=metrics_d[value_name]) self._file_writer.add_summary(summary, self._global_step) self._file_writer.flush() logging.info('Wrote metric summaries for step %s to %s', self._global_step, self._summary_dir) spectral_ops.reset_crepe() # Reset CREPE global state