Skip to content

killeress/anomalib-gui

Repository files navigation

🔬 Anomalib GUI

A visual training and inference interface for Anomalib - the deep learning library for anomaly detection.

Python Gradio License

✨ Features

  • 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

📸 Screenshots

Training GUI

🚀 Quick Start

Prerequisites

  • Python 3.8 or higher
  • Anomalib installed

Installation

# Clone this repository
git clone https://github.com/YOUR_USERNAME/anomalib-gui.git
cd anomalib-gui

# Install dependencies
pip install -r requirements.txt

Usage

Training GUI

python training_gui.py

Opens 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

Inference GUI

python inference_gui.py

Opens 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

📁 Dataset Structure

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
        └── ...

⚙️ Configuration

Training Parameters

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

Inference Parameters

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

🔧 Advanced Configuration

Changing the Port

Edit the launch configuration at the bottom of each script:

app.launch(
    server_port=8080,  # Change to your preferred port
)

Generating a Public Link

For temporary external access:

app.launch(
    share=True,
)

📋 Inference Folder Structure

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).

🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

📝 Notes

  • 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

📄 License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

🙏 Acknowledgments

  • 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.

About

Visual training and inference GUI for Anomalib

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages