Skip to content

Problem with model classification of Mimic CXR #156

Open
@danielemolino

Description

@danielemolino

Hi! Thank you so much for your amazing works.

I need to use your trained model for a project. In order to understand how to use the code, I've tried to evaluate the weights densenet121-res224-all on the official test split of the Mimic CXR-JPEG.

But I'm getting terrible performances, so I'm pretty sure I'm doing something wrong, but I can't find out what it is.

Here is an example of how I'm making the predictions:

import torch
import torchvision
import torchxrayvision as xrv

# Check if CUDA is available and set device
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

# Define transformations
transforms = torchvision.transforms.Compose([
    xrv.datasets.XRayCenterCrop(),
    xrv.datasets.XRayResizer(224)
])

# No data augmentation for evaluation
data_aug = None

# Load the dataset
dataset = xrv.datasets.MIMIC_Dataset(
    imgpath="/mimer/NOBACKUP/groups/naiss2023-6-336/dmolino/TestSet_Mimic",
    csvpath="labels_test.csv",  # The original file with only test split rows
    metacsvpath="metadata_test.csv",
    transform=transforms,
    data_aug=data_aug,
    unique_patients=False,
    views=["PA", "AP"]
)

# Create a DataLoader
dataloader = torch.utils.data.DataLoader(dataset, batch_size=64, shuffle=False)

# Load the model with the specified weights
model = xrv.models.DenseNet(weights="densenet121-res224-all")
model.to(device)
model.eval()

# Make predictions
for batch in dataloader:
    with torch.no_grad():
        im = batch.to(device)
        outputs = model(im)
        pred = outputs.cpu().detach().numpy()
        # Process predictions as needed

I get for every class (the one which are part of the Mimic Split) an Auc of almost 0.5. Any idea on there is the mistake?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions