Module audiocraft.grids.musicgen.musicgen_pretrained_32khz_eval
Evaluation with objective metrics for the pretrained MusicGen models. This grid takes signature from the training grid and runs evaluation-only stage.
When running the grid for the first time, please use: REGEN=1 dora grid musicgen.musicgen_pretrained_32khz_eval and re-use the REGEN=1 option when the grid is changed to force regenerating it.
Note that you need the proper metrics external libraries setup to use all the objective metrics activated in this grid. Refer to the README for more information.
Functions
def eval(launcher, batch_size: int = 32, eval_melody: bool = False)-
Expand source code
def eval(launcher, batch_size: int = 32, eval_melody: bool = False): opts = { 'dset': 'audio/musiccaps_32khz', 'solver/musicgen/evaluation': 'objective_eval', 'execute_only': 'evaluate', '+dataset.evaluate.batch_size': batch_size, '+metrics.fad.tf.batch_size': 16, } # chroma-specific evaluation chroma_opts = { 'dset': 'internal/music_400k_32khz', 'dataset.evaluate.segment_duration': 30, 'dataset.evaluate.num_samples': 1000, 'evaluate.metrics.chroma_cosine': True, 'evaluate.metrics.fad': False, 'evaluate.metrics.kld': False, 'evaluate.metrics.text_consistency': False, } # binary for FAD computation: replace this path with your own path metrics_opts = { 'metrics.fad.tf.bin': '/data/home/jadecopet/local/usr/opt/google-research' } opt1 = {'generate.lm.use_sampling': True, 'generate.lm.top_k': 250, 'generate.lm.top_p': 0.} opt2 = {'transformer_lm.two_step_cfg': True} sub = launcher.bind(opts) sub.bind_(metrics_opts) # base objective metrics sub(opt1, opt2) if eval_melody: # chroma-specific metrics sub(opt1, opt2, chroma_opts)