-
Notifications
You must be signed in to change notification settings - Fork 709
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
Error(s) in loading state_dict for PatchcoreLightning #523
Comments
@ashwinvaidya17 can you have a look at this? It seems to be related to the normalization redesign |
The normalization callback setup is not called before the model state dict loading in |
I'm having a simlar issue, here the runtime error:
And this is the code I'm using:
With weights trained on Colab, and doing inference on CPU. This is the models/patchcore/config.yaml file, almost standard:
|
@alevangel you might have not installed the same anomalib version on colab and locally where your are running your inference |
@alexriedel1 on Colab I'm doing: While on local I'm on the last commit of the main branch, SHA: Those versions are not the same? |
On loading the state dictionary, it looks like the saved model file was trained before using
Where as the model defined for loading the weights is the most recent one using the anomalib/anomalib/models/components/feature_extractors/feature_extractor.py Lines 43 to 49 in bd36919
Are you sure you trained the model with the most recent version of anomalib? |
@alexriedel1 I'm quite sure that I'm on the same commit on both sides: And I'm training on colab with the method: Do you have weights for leather/patchcore trained with the most recent version? So that maybe I can try on my local to see if the problem persists. |
Unfortunately I don't. Can you show the code you are using for loading the trained model? |
This is the full code that I'm using in local:
Also I had to change this line (as stated in this issue):
to: pl_module.load_state_dict(torch.load(self.weights_path, map_location=torch.device('cpu')["state_dict"])
This is also my env:
|
@alexriedel1 actually I think as you that is a version problem, running inferences on Colab seems work:
But I am pretty sure that is the same commit on both side... where is the trick?! :'( |
Hm. can you please show the output of
on both colab and your local machine? |
@alexriedel1 on both sides is |
@alexriedel1 oh gosh! It was a messy with the colab versions, I found the problem where was... In the big block of isntalling libraries I also installed anomalib (while also cloning the git repo), and this created an overlapping in the versions. Now it works :') Thanks!! |
Describe the bug
Running
tools/inference/torch_inference.py
throws:To Reproduce
patchcore/config.yaml
python tools/train.py --config anomalib/models/patchcore/config.yaml
torch_inference
:Additional context
Error is present since commit d6951eb
The text was updated successfully, but these errors were encountered: