PadimSharp brings the power of Padim (Patch Distribution Modeling) to the C# ecosystem.
Now you can train and detect anomalies entirely in C# โ no Python needed!
๐ฏ Perfect for industrial inspection, quality control, and visual anomaly detection tasks.
- Pure C# implementation โ Train and run inference seamlessly in .NET
- No external dependencies like Python or PyTorch
- Tested on MVTec โ Proven performance on real-world anomaly detection benchmarks
- Built-in localization โ See exactly where anomalies occur
// Train on normal images Config config = new Config(); BaseModel model = new BaseModel(config); model.Train(); // Detect anomalies on new images (bool predictGood, torch.Tensor image) = model.Predict(predictImagePath);
- โ Train on custom datasets with normal samples only
- โ Fast inference suitable for real-time applications
- โ Pixelโlevel anomaly localization
- โ Works with standard .NET image libraries (TorchSharp, etc.)
We've validated PadimSharp on the MVTec Anomaly Detection dataset โ achieving reliable detection and localization across multiple object and texture categories.
Here's a real detection example from our MVTec tests:
| Original Image | Predicted Anomaly Mask |
|---|---|
![]() |
![]() |
The model successfully identifies the anomalous region with pixel-level precision.
We welcome contributions! Feel free to open issues or PRs to improve performance, documentation, or compatibility.
Say goodbye to Pythonโbased anomaly detection pipelines. Hello, PadimSharp. ๐

