Try to use TTA in final submissions to improve score:
Simple example and pseudocode behind tta prediction:
def TTA(x:tc.Tensor,model:nn.Module):
#x.shape=(batch,c,h,w)
if CFG.TTA:
shape=x.shape
# Perform rotations
x=[x,*[tc.rot90(x,k=i,dims=(-2,-1)) for i in range(1,4)]]
x=tc.cat(x,dim=0)
x=model(x)
x=torch.sigmoid(x)
x=x.reshape(4,shape[0],*shape[2:])
# Undo rotations on predicted masks
x=[tc.rot90(x[i],k=-i,dims=(-2,-1)) for i in range(4)]
x=tc.stack(x,dim=0)
# Average results
return x.mean(0)
else :
x=model(x)
x=torch.sigmoid(x)
return x
model = load_model()
for batch in inference_set:
prediction = TTA(batch, model)
Try to use TTA in final submissions to improve score:
Simple example and pseudocode behind tta prediction:
Also, it's already implemented in https://www.kaggle.com/code/r1chardson/vesuvius-challenge-inference-smp:
JUST A REMINDER TO NOT TO FORGOT IT! ALSO TRY HORIZONTAL/VERTICAL FLIPS and both of them