-
Notifications
You must be signed in to change notification settings - Fork 14
Using RandStainNA with Resnet18 #3
Copy link
Copy link
Open
Description
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?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels