-
Notifications
You must be signed in to change notification settings - Fork 68
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
model-zoo error about Breast density classification execute reasoning #606
Comments
It may due to the torchvision you imported mismatches the bundle'v version. |
thank you, It's the version. Reasoning is good for now。 |
Hi @shihzenq , for algorithm side questions, I would suggest to ask the bundle author: Hi @vikashg , could you provide some information here? Thanks! |
@yiheng-wang-nv thank you |
Hi @shihzenq, |
hello, My question is as follows
I have downloaded model.pth from the address。
code:
`import glob
import os
import torch
import matplotlib.pyplot as plt
from PIL import Image
from torchvision import transforms
from torchvision.models import inception_v3
from monai.bundle import download, load
data_dir = 'breast_density_classification/sample_data'
test_images = sorted(glob.glob(os.path.join(data_dir, "A", "*.jpg")))
preprocess = transforms.Compose([
transforms.Resize((299, 299)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
model_path = "breast_density_classification/models/model.pth"
model = inception_v3(pretrained=False, aux_logits=False, num_classes=4).to(device)
state_dict = torch.load(model_path, map_location=device)
model.load_state_dict(state_dict)
model.eval()
for img_path in test_images:
img = Image.open(img_path).convert('RGB')
img_tensor = preprocess(img).unsqueeze(0).to(device)
error:
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for Inception3:
Missing key(s) in state_dict: "Conv2d_1a_3x3.conv.weight", "Conv2d_1a_3x3.bn.weight",
This error indicates that the loaded state_dict does not match the defined InceptionV3 model. Did I do something wrong.
This is an urgent problem. thank you
The text was updated successfully, but these errors were encountered: