-
Notifications
You must be signed in to change notification settings - Fork 714
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
[Bug]: Unable to initialize model #1877
Comments
Can you show the full code you ran? It is a bit hard to find out the problem from |
Thank you for your efforts! Open the file: anomalib/src/anomalib/models/components/filters/blur.py |
Thanks OneBugMaker. Faced same issue. Resolved. |
Describe the bug
problem
When I tried to initialize the model in anomalib, an error occurred. This happened during the initialization phase without any further operations. Both "Padim" and "Patchcore" encountered the same issue. The detailed error message is as follows:
RuntimeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_21240\545706316.py in <cell line: 1>()
----> 1 model = Padim()
D:\ML\0-PHD2\27_IDD\MyIDD\new_19_14_42\anomalib\src\anomalib\models\image\padim\lightning_model.py in init(self, backbone, layers, pre_trained, n_features)
48 super().init()
49
---> 50 self.model: PadimModel = PadimModel(
51 backbone=backbone,
52 pre_trained=pre_trained,
D:\ML\0-PHD2\27_IDD\MyIDD\new_19_14_42\anomalib\src\anomalib\models\image\padim\torch_model.py in init(self, layers, backbone, pre_trained, n_features)
99 self.idx: torch.Tensor
100 self.loss = None
--> 101 self.anomaly_map_generator = AnomalyMapGenerator()
102
103 self.gaussian = MultiVariateGaussian()
D:\ML\0-PHD2\27_IDD\MyIDD\new_19_14_42\anomalib\src\anomalib\models\image\padim\anomaly_map.py in init(self, sigma)
24 super().init()
25 kernel_size = 2 * int(4.0 * sigma + 0.5) + 1
---> 26 self.blur = GaussianBlur2d(kernel_size=(kernel_size, kernel_size), sigma=(sigma, sigma), channels=1)
27
28 @staticmethod
D:\ML\0-PHD2\27_IDD\MyIDD\new_19_14_42\anomalib\src\anomalib\models\components\filters\blur.py in init(self, sigma, channels, kernel_size, normalize, border_type, padding)
66 self.kernel = normalize_kernel2d(self.kernel)
67 self.kernel.unsqueeze_(0).unsqueeze_(0)
---> 68 print(self.kernel.shape, self.channels)
69 self.kernel = self.kernel.expand(self.channels, -1, -1, -1)
70 self.kernel = self.kernel.expand(self.channels, -1, -1, -1)
RuntimeError: expand(torch.FloatTensor{[1, 1, 1, 33, 33]}, size=[1, -1, -1, -1]): the number of sizes provided (4) must be greater or equal to the number of dimensions in the tensor (5)
environment
python==3.10.0
torch==2.1.0+cu121
anomalib==1.1.0dev
Dataset
MVTec
Model
PatchCore
Steps to reproduce the behavior
When I tried to initialize the model in anomalib, an error occurred.
This happened during the initialization phase without any further operations.
Both "Padim" and "Patchcore" encountered the same issue.
OS information
OS information:
Expected behavior
Resolve this bug and successfully use Padim and Patchcore models
Screenshots
Pip/GitHub
GitHub
What version/branch did you use?
No response
Configuration YAML
i do not know
Logs
i do not know
Code of Conduct
The text was updated successfully, but these errors were encountered: