Non-Beginner Discussion

Okay, good news.

By using this little guy’s help:

I managed to build my callback:

class VisualisePredictions1(Callback):
    "Visualize predictions"
    order = ProgressCallback.order+1
    def after_epoch(self, **kwargs):
        if not self.learn.training:
            with torch.no_grad(): 
                preds = self.learn.pred[0]
                preds = preds.detach().cpu()
                preds=TensorRawImage(preds) # My tensor
                preds = self.dls.after_batch.decode(preds)
                show_raw_image(preds) # My function

Which works nicely.

image

So now I’m a little asking for more help and guidance:

When calling self.learn.pred I can get only a specific image. The returned item has a shape of [1x3xHxW]
Where 3 stands for the number of channels, and 1 stands for the number of predicted items.

I tried to select another index out of the valid batch, but it returned an error “It’s not subscriptible” or so.

How can I choose the pred of a specific batch in the valid dataset?

Thanks

1 Like