Lightning-AI / Lightning-AI/pytorch-lightning

Add an end-to-end anomaly detection tutorial using PyTorch Lightning

Open
#21,809 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs
Dominant language
Python
Stars
31.4k
Forks
3.8k
Avg merge
6d 7h
Merged PRs (30d)
6

Description

### 📚 Documentation

## Motivation

PyTorch Lightning is widely used for supervised learning tasks, but there is currently no end-to-end tutorial demonstrating anomaly detection.

Anomaly detection is an important application in industrial inspection, healthcare, cybersecurity, and time-series monitoring. A beginner-friendly tutorial would help users understand how Lightning can simplify training and evaluation for these workflows.

## Proposed tutorial

I would like to contribute a tutorial that demonstrates:

- Building an Autoencoder (or Variational Autoencoder) using LightningModule
- Organizing datasets with LightningDataModule
- Training only on normal samples
- Computing reconstruction-error anomaly scores
- Selecting an anomaly threshold using validation data
- Evaluating on normal and anomalous samples
- Logging metrics with Lightning loggers
- Visualizing reconstructed images and anomaly scores

The tutorial would follow Lightning's recommended coding style and be suitable for beginners.

## Possible extensions

Depending on maintainer feedback, the tutorial could later include:

- Callbacks for reconstruction visualization
- TensorBoard logging
- Multiple datasets
- Industrial anomaly detection examples

I'd be happy to implement this if the maintainers think it would be a useful addition.

cc @lantiga

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file, test, or entry point is named. Start by reviewing the repository's recommended tutorial coding style and maintainer feedback, then define a beginner-friendly end-to-end example covering the proposed LightningModule, LightningDataModule, training, threshold selection, evaluation, logging, and visualizations; done means the complete tutorial is clear and runnable.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
documentation, machine-learning
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.