A visual training and inference interface for Anomalib - the deep learning library for anomaly detection.
- Training GUI - Visual interface for training PatchCore anomaly detection models
- Inference GUI - Batch inference tool for panel/product inspection
- Real-time Logging - Monitor training progress with live console output
- GPU Support - Automatic detection of CUDA, Intel XPU, and Apple MPS
- Tiling Support - Handle large images with configurable tile processing
- Export Options - Save inference results as JSON or CSV
- Python 3.8 or higher
- Anomalib installed
# Clone this repository
git clone https://github.com/YOUR_USERNAME/anomalib-gui.git
cd anomalib-gui
# Install dependencies
pip install -r requirements.txtpython training_gui.pyOpens a web interface at http://localhost:7860 for:
- Configuring dataset path and output directory
- Setting batch size and image dimensions
- Enabling tiling for large images
- Monitoring training progress in real-time
python inference_gui.pyOpens a web interface at http://localhost:7861 for:
- Loading trained models (.pt files)
- Batch processing image folders
- Configuring anomaly threshold
- Exporting results to JSON/CSV
Prepare your dataset in the following structure:
my_dataset/
├── train/ # Normal training images
│ ├── img001.jpg
│ ├── img002.jpg
│ └── ...
└── test/
├── anormal/ # Abnormal test images
│ ├── defect001.jpg
│ └── ...
└── normal/ # Normal test images
├── normal001.jpg
└── ...
| Parameter | Description | Default |
|---|---|---|
| Dataset Path | Root directory of training data | ./my_dataset |
| Output Directory | Where to save the trained model | ./results |
| Batch Size | Training batch size | 8 |
| Image Width | Input image width (pixels) | 256 |
| Image Height | Input image height (pixels) | 256 |
| Enable Tiling | Process large images in tiles | Off |
| Tile Size | Size of each tile (if tiling enabled) | 256 |
| Stride | Tile overlap stride (if tiling enabled) | 128 |
| Parameter | Description | Default |
|---|---|---|
| Model Path | Path to trained model (.pt file) | - |
| Input Folder | Folder containing images to process | - |
| Threshold | Anomaly score threshold (0.0-1.0) | 0.5 |
| Device | Computation device (auto/cpu/cuda) | auto |
Edit the launch configuration at the bottom of each script:
app.launch(
server_port=8080, # Change to your preferred port
)For temporary external access:
app.launch(
share=True,
)For batch inference, organize your images as:
input_folder/
├── 2024-01-01/ # Date folder
│ ├── Item_001/ # Item ID
│ │ ├── image1.jpg
│ │ ├── image2.jpg
│ │ └── ...
│ └── Item_002/
│ └── ...
└── 2024-01-02/
└── ...
Logic: If any image in an item folder is detected as anomalous, the entire item is marked as NG (Not Good).
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Ensure sufficient GPU memory for training (reduce batch size if needed)
- Enabling Tiling increases memory usage; consider lowering batch size
- First run may download pre-trained backbone models
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- Anomalib - The core anomaly detection library
- Gradio - The web interface framework
- PatchCore - The anomaly detection algorithm
Note: This is a community tool built on top of Anomalib. For issues with the core library, please refer to the official Anomalib repository.
