File size: 1,875 Bytes
b100e1c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Defaults for eval.py.
#
# You must also include a binding for MODEL.
#
# Required to be set:
#
# - TASK_PREFIX
# - TASK_FEATURE_LENGTHS
# - CHECKPOINT_PATH
# - EVAL_OUTPUT_DIR
#
# Commonly overridden options:
#
# - DatasetConfig.split
# - DatasetConfig.batch_size
# - DatasetConfig.use_cached
# - RestoreCheckpointConfig.mode
# - PjitPartitioner.num_partitions

from __gin__ import dynamic_registration

import __main__ as eval_script
from mt3 import preprocessors
from mt3 import tasks
from mt3 import vocabularies
from t5x import partitioning
from t5x import utils

# Must be overridden
TASK_PREFIX = %gin.REQUIRED
TASK_FEATURE_LENGTHS = %gin.REQUIRED
CHECKPOINT_PATH = %gin.REQUIRED
EVAL_OUTPUT_DIR = %gin.REQUIRED

# Number of velocity bins: set to 1 (no velocity) or 127
NUM_VELOCITY_BINS = %gin.REQUIRED
VOCAB_CONFIG = @vocabularies.VocabularyConfig()
vocabularies.VocabularyConfig.num_velocity_bins = %NUM_VELOCITY_BINS

# Program granularity: set to 'flat', 'midi_class', or 'full'
PROGRAM_GRANULARITY = %gin.REQUIRED
preprocessors.map_midi_programs.granularity_type = %PROGRAM_GRANULARITY

TASK_SUFFIX = 'test'
tasks.construct_task_name:
  task_prefix = %TASK_PREFIX
  vocab_config = %VOCAB_CONFIG
  task_suffix = %TASK_SUFFIX

eval_script.evaluate:
  model = %MODEL  # imported from separate gin file
  dataset_cfg = @utils.DatasetConfig()
  partitioner = @partitioning.PjitPartitioner()
  restore_checkpoint_cfg = @utils.RestoreCheckpointConfig()
  output_dir = %EVAL_OUTPUT_DIR

utils.DatasetConfig:
  mixture_or_task_name = @tasks.construct_task_name()
  task_feature_lengths = %TASK_FEATURE_LENGTHS
  split = 'eval'
  batch_size = 32
  shuffle = False
  seed = 42
  use_cached = True
  pack = False
  use_custom_packing_ops = False

partitioning.PjitPartitioner.num_partitions = 1

utils.RestoreCheckpointConfig:
  path = %CHECKPOINT_PATH
  mode = 'specific'