|
|
--- |
|
|
language: |
|
|
- en |
|
|
license: mit |
|
|
library_name: pytorch |
|
|
tags: |
|
|
- autoencoder |
|
|
- anomaly-detection |
|
|
- computer-vision |
|
|
- manufacturing |
|
|
- onnx |
|
|
- openvino |
|
|
- edge-ai |
|
|
pipeline_tag: image-classification |
|
|
base_model: custom/autoencoder |
|
|
datasets: |
|
|
- custom |
|
|
metrics: |
|
|
- reconstruction-error |
|
|
--- |
|
|
|
|
|
# Anomaly Detection Model β Edge AI for Casting Defect Inspection |
|
|
|
|
|
## Overview |
|
|
The **Anomaly Detection Model** is an **autoencoder-based anomaly detection system** fine-tuned for industrial **casting defect inspection**. It identifies whether a metal casting image is *normal (OK)* or *defective* by reconstructing input images and analyzing reconstruction errors. |
|
|
|
|
|
This model is designed for **Edge AI deployment**, optimized via **ONNX** and **OpenVINO IR** formats to run efficiently on low-power Intel edge devices. |
|
|
|
|
|
--- |
|
|
|
|
|
## Model Details |
|
|
- **Architecture:** Convolutional Autoencoder |
|
|
- **Framework:** PyTorch |
|
|
- **Training Objective:** Minimize reconstruction loss (MSE) for normal samples |
|
|
- **Optimization:** ONNX and OpenVINO IR export for edge inference |
|
|
- **Task:** Unsupervised anomaly detection |
|
|
- **Domain:** Industrial visual inspection |
|
|
|
|
|
--- |
|
|
|
|
|
## Repository Structure |
|
|
``` |
|
|
βββ casting_autoencoder.pth # Trained PyTorch model |
|
|
βββ casting_autoencoder.onnx # ONNX export |
|
|
βββ model.bin # OpenVINO IR model (bin) |
|
|
βββ model.xml # OpenVINO IR model (xml) |
|
|
βββ model_card.yaml |
|
|
βββ requirements.txt # Dependencies |
|
|
βββ inference.py # inference code |
|
|
βββ README.md # Model card (this file) |
|
|
``` |
|
|
|
|
|
--- |
|
|
|
|
|
## Dataset |
|
|
**Dataset:** Casting Product Image Dataset (Kaggle) |
|
|
- **Classes:** Defective / Normal |
|
|
- **Modality:** Grayscale industrial images |
|
|
- **Training Strategy:** Only *normal* samples used for training the autoencoder. |
|
|
|
|
|
--- |
|
|
|
|
|
## Key Configuration Parameters |
|
|
|
|
|
- **Image Size**: 304Γ304 pixels |
|
|
- **Batch Size**: 32 |
|
|
- **Learning Rate**: 1e-3 |
|
|
- **Epochs**: 10 |
|
|
- **Loss Function**: MSE Loss |
|
|
- **Optimizer**: Adam |
|
|
|
|
|
|
|
|
## Model Outputs |
|
|
|
|
|
The training script generates: |
|
|
|
|
|
- `casting_autoencoder.pth` - PyTorch model weights |
|
|
- `casting_autoencoder.onnx` - ONNX export for deployment |
|
|
- Calibrated anomaly threshold based on defective samples |
|
|
|
|
|
|
|
|
## Anomaly Detection Process |
|
|
|
|
|
1. **Training Phase**: Model learns to reconstruct normal casting images |
|
|
2. **Threshold Calibration**: Uses defective samples to determine optimal threshold |
|
|
3. **Inference**: Images with reconstruction error > threshold are flagged as defective |
|
|
|
|
|
## Performance |
|
|
|
|
|
- **Final Training Loss**: 0.0005 |
|
|
- **Suggested Threshold**: 0.0004 |
|
|
- **Model Type**: Unsupervised anomaly detection |
|
|
- **Architecture**: Convolutional Autoencoder |
|
|
|
|
|
|
|
|
## Applications |
|
|
|
|
|
This model is designed for: |
|
|
|
|
|
- Quality control in metal casting manufacturing |
|
|
- Real-time defect detection on production lines |
|
|
- Automated visual inspection systems |
|
|
- Edge deployment in industrial environments |
|
|
|
|
|
|
|
|
## Model Features |
|
|
|
|
|
- **Unsupervised Learning**: Trained only on normal samples |
|
|
- **Real-time Capable**: Optimized for edge deployment |
|
|
- **ONNX Compatible**: Ready for production deployment |
|
|
- **Automatic Thresholding**: Self-calibrating anomaly detection |
|
|
- **Industrial Grade**: Tested on real manufacturing data |
|
|
|
|
|
|
|
|
## Technical Details |
|
|
|
|
|
The model uses a symmetric encoder-decoder architecture with: |
|
|
|
|
|
- Stride-2 convolutions for downsampling |
|
|
- Transposed convolutions for upsampling |
|
|
- ReLU activation in hidden layers |
|
|
- Sigmoid output activation for pixel reconstruction. |
|
|
|
|
|
--- |
|
|
|
|
|
## Export & Deployment |
|
|
| Format | Purpose | |
|
|
|---------|----------| |
|
|
| `.pth` | Original PyTorch model | |
|
|
| `.onnx` | Framework-independent inference | |
|
|
| `.xml` / `.bin` | OpenVINO IR format for edge devices | |
|
|
|
|
|
**Edge Optimization:** Model converted and optimized using `openvino.convert_model()`. |
|
|
|
|
|
|
|
|
--- |
|
|
|
|
|
## Intended Use |
|
|
- Automated visual inspection for manufacturing/QA systems. |
|
|
- Real-time edge deployment in industrial environments. |
|
|
|
|
|
**Not recommended for:** |
|
|
- Non-industrial datasets. |
|
|
- Scenarios with significant domain drift (e.g., lighting changes or non-casting objects). |
|
|
|
|
|
--- |
|
|
|
|
|
## Limitations |
|
|
- Accuracy depends on lighting and background consistency. |
|
|
- Model trained primarily on grayscale casting images. |
|
|
- Thresholds for anomaly detection must be tuned for specific deployment environments. |
|
|
|
|
|
--- |
|
|
|
|
|
## License |
|
|
This project is released under the MIT License. |
|
|
|
|
|
--- |
|
|
|
|
|
## Author |
|
|
**Arunima Surendran** |
|
|
Applied AI Engineer |
|
|
[GitHub Repository](https://github.com/arunimakanavu/anomalydetectionmodel) |
|
|
|
|
|
--- |
|
|
|