You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have successfully trained a Padim model using the images size of 256x256 and the tiling size of 224x224. Then, I converted it to a pytorch model. When I started inference using pytorch inferencer, it throwed an error:
Traceback (most recent call last):
File "/app/infer.py", line 8, in <module>
out = model1.forward(input.cuda())
File "/app/anomalib/src/anomalib/deploy/inferencers/torch_inferencer.py", line 223, in forward
return self.model(image)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1536, in _call_impl
return forward_call(*args, **kwargs)
File "/app/anomalib/src/anomalib/deploy/export.py", line 86, in forward
return self.model(batch)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1536, in _call_impl
return forward_call(*args, **kwargs)
File "/app/anomalib/src/anomalib/models/image/padim/torch_model.py", line 147, in forward
output = self.anomaly_map_generator(
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1536, in _call_impl
return forward_call(*args, **kwargs)
File "/app/anomalib/src/anomalib/models/image/padim/anomaly_map.py", line 133, in forward
return self.compute_anomaly_map(embedding, mean, inv_covariance, image_size=image_size)
File "/app/anomalib/src/anomalib/models/image/padim/anomaly_map.py", line 101, in compute_anomaly_map
score_map = self.compute_distance(
File "/app/anomalib/src/anomalib/models/image/padim/anomaly_map.py", line 45, in compute_distance
delta = (embedding - mean).permute(2, 0, 1)
RuntimeError: The size of tensor a (4096) must match the size of tensor b (65536) at non-singleton dimension 2
It seems that the exported models, neither ckpt nor pt file contains the tiling information, which leads to the shape mismatch.
Dataset
Folder
Model
PADiM
Steps to reproduce the behavior
train a Padim model using any datasets with the tiling size of 224x224 and the image size of 256x256
convert to a pytorch model using anomalib cli: anomalib export --model Padim --export_type torch --ckpt_path /app/out/weights/lightning/model.ckpt --default_root_dir /app/out
run the script provided below:
import torch
from anomalib.deploy.inferencers.torch_inferencer import TorchInferencer
# change the path to your model
model_path = '/app/out/weights/torch/model.pt'
model1 = TorchInferencer(model_path)
input = torch.rand(1,3,512,512)
out = model1.forward(input.cuda())
OS information
the latest commit in the main branch
Expected behavior
it should run without errors
Screenshots
No response
Pip/GitHub
GitHub
What version/branch did you use?
main
Configuration YAML
n/a
Logs
as described above
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
Describe the bug
I have successfully trained a Padim model using the images size of 256x256 and the tiling size of 224x224. Then, I converted it to a pytorch model. When I started inference using pytorch inferencer, it throwed an error:
It seems that the exported models, neither ckpt nor pt file contains the tiling information, which leads to the shape mismatch.
Dataset
Folder
Model
PADiM
Steps to reproduce the behavior
anomalib export --model Padim --export_type torch --ckpt_path /app/out/weights/lightning/model.ckpt --default_root_dir /app/out
OS information
the latest commit in the main branch
Expected behavior
it should run without errors
Screenshots
No response
Pip/GitHub
GitHub
What version/branch did you use?
main
Configuration YAML
n/a
Logs
Code of Conduct
The text was updated successfully, but these errors were encountered: