--- title: Anomaly Detection Demo emoji: ๐Ÿง  colorFrom: indigo colorTo: pink sdk: gradio sdk_version: "4.27.0" app_file: app.py pinned: false --- # ๐Ÿง  Anomaly Detection as a Service A minimalistic anomaly detection microservice powered by an autoencoder trained on MNIST-style grayscale images. This project provides both a backend API and a Gradio web interface to analyze images and identify abnormal patterns. ## ๐Ÿš€ Features - ๐Ÿงช **FastAPI** backend for anomaly score prediction - ๐ŸŽ›๏ธ **Gradio** frontend with drag-and-drop image testing - ๐Ÿ”ฅ Visual output includes anomaly score, reconstruction, and heatmap - โš™๏ธ Pretrained autoencoder (trained on MNIST digit-style grayscale images) - ๐Ÿงฐ Easily extendable to new datasets and model architectures ## โš™๏ธ Setup 1. Install dependencies: ``` pip install -r requirements.txt ``` 2. (Optional) Train the model from scratch: ``` python src/train.py ``` By default, the model will be saved to `models/autoencoder_mnist.pth`. Then in `model_config.py` set `model_path`. ## ๐ŸŽ›๏ธ Run the Gradio Frontend ``` python app.py ``` This starts the API at http://0.0.0.0:7860 This launches an interactive browser interface for: - Uploading images - Viewing anomaly scores - Seeing reconstructions and heatmaps side-by-side ## ๐Ÿ“ Notes - Input images must be grayscale, 28ร—28 pixels. - To adapt to a custom dataset, modify src/train.py accordingly and retrain. - The project is meant for educational/demo purposes and not intended for production deployment.