organmnist3d / data_description.md
blueyo0's picture
Upload folder using huggingface_hub
cff4b89 verified

Introduction

Predict the category of each given 3D Abdominal CT image by selecting the most appropriate one from the 11 available classes. 0 class-1 1 class-2 2 class-3 3 class-4 4 class-5 5 class-6 6 class-7 7 class-8 8 class-9 9 class-10 10 class-11

Example Prediction Code

# Load best model and predict on test set
test_transforms = Compose(
    [
        LoadImaged(keys=["image"]),
        EnsureChannelFirstd(keys=["image"]),
        ScaleIntensityd(keys=["image"]),
    ]
)
test_ds = Dataset(data=test_df.to_dict(orient="records"), transform=test_transforms)
test_loader = DataLoader(test_ds, batch_size=1, shuffle=False, num_workers=4)
predictions = []
with torch.no_grad():
    for test_data in test_loader:
        test_images = test_data["image"].to(device)
        test_outputs = model(test_images)
        test_outputs = torch.argmax(test_outputs, dim=1)
        predictions.extend(test_outputs.cpu().numpy())

# Save predictions
submission_df = pd.DataFrame({"Id": test_df["Id"], "class": predictions})
submission_df.to_csv("./working/submission.csv", index=False)