def _compile_results(ground, predicted, annotation):
  """Compute genre-wise and overall accuracies.

  Args:
    ground: Ground-truth labels (numpy array).
    predicted: Predicted labels (numpy array).
    annotation: Annotations (list of strings).

  Returns:
    results: Dict with keys for each non-'None' genre in annotation, and one
      key for 'overall'. Values are accuracies.
  """
  correct = {'overall': 0}
  count = {'overall': 0}
  for ii in range(ground.shape[0]):
    if annotation[ii] and annotation[ii] not in correct:
      correct[annotation[ii]] = 0
      count[annotation[ii]] = 0
    if annotation[ii]: count[annotation[ii]] += 1
    count['overall'] += 1
    if ground[ii] == predicted[ii]:
      if annotation[ii]: correct[annotation[ii]] += 1
      correct['overall'] += 1

  results = {}
  for k in correct:
    results[k] = float(correct[k]) / count[k]

  return results