The foundational event system for `Performer` based on fastai `Callback`s
# Since there would only be one level, easy to track where and how
class ImageClassifierConfiguration(InferenceConfiguration):
def __init__(self, vocab):
self.vocab = vocab
def after_drawn_batch(self, batch): super().after_drawn_batch(batch)
def gather_predictions(self, model, batch):
return model(*batch)
def decoding_values(self, values):
preds = values.argmax(dim=-1)
decoded_preds = [self.vocab[p] for p in preds]
return {"classes":decoded_preds, "probabilities":preds}