# ๐Ÿง  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`. ## ๐Ÿงช Run the API Server (FastAPI) ``` uvicorn app.main:app --reload ``` This starts the API at http://127.0.0.1:8000 You can test it using Swagger UI: http://127.0.0.1:8000/docs ## ๐ŸŽ›๏ธ Run the Gradio Frontend ``` python app.py ``` 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.