Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to do TTA in classification problem ? #18

Open
xiaoerlaigeid opened this issue Aug 25, 2021 · 2 comments
Open

How to do TTA in classification problem ? #18

xiaoerlaigeid opened this issue Aug 25, 2021 · 2 comments

Comments

@xiaoerlaigeid
Copy link

No description provided.

@talhaanwarch
Copy link

import ttach as tta
transforms = tta.Compose(
    [
        tta.HorizontalFlip(),
        tta.VerticalFlip(),
        tta.Rotate90(angles=[0, 90,180]),
    ]
)

tta_model = tta.ClassificationTTAWrapper(model, transforms)


model.cuda().eval()
labels,preds=[],[]
with torch.no_grad():
    for batch in loader:
        image,label=batch
        pred=tta_model(image.cuda())
        pred=torch.argmax(pred,dim=1).detach().cpu().numpy()
        labels.append(label.cpu().numpy())
        preds.append(pred)

@puneeshkhanna
Copy link

One quick doubt when we do TTA, are we also predicting on original image and the predictions probs are mean of original image + the augmented images based upon the transforms ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants