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

Using RandStainNA with Resnet18 #3

Open
SaraAlthubaiti opened this issue Jun 16, 2023 · 0 comments
Open

Using RandStainNA with Resnet18 #3

SaraAlthubaiti opened this issue Jun 16, 2023 · 0 comments

Comments

@SaraAlthubaiti
Copy link

Hello all,

Thanks for sharing this nice work. I tried to use RandStainNA on whole slide images and as a model I used resnet18 (pre-trained) but it gave:

RuntimeError: Given groups=1, weight of size [64, 3, 7, 7], expected input[16, 224, 224, 3] to have 3 channels, but got 224 channels instead

And this is what I used:

transforms_list = [
        transforms.Resize((224, 224)),
        RandStainNA(yaml_file='/kaggle/input/kaggleinputdatasetmine/CRC_LAB_randomTrue_n0.yaml', std_hyper=-0.3, probability=1.0,distribution='normal', is_train=True)
    ]
    
transform = transforms.Compose(transforms_list)

# I used 16 as a batch size

And for the model, I changed last layer based on the number of classes I have (3 classes):

# Load pre-trained ResNet-18 model
model = models.resnet18(pretrained=True)

# Replace the last fully connected layer to match the number of classes
num_ftrs = model.fc.in_features
model.fc = nn.Linear(num_ftrs, 3)

model = model.to(device)

And the error happen when I call the model:

---> 73 outputs = model(image)

Can you help me to solve that, please?

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

1 participant