Skip to the content
PCBKitNew board
2 layers120 × 100 mmPcb 352, the printed circuit board in 3D

This repository implements Spatial PaDiM (Patch Distribution Modeling) for anomaly detection on printed circuit boards (PCBs) using photometric (multi-illumination) image stacks.

Size
120 × 100 mm
Copper layers
2
Thickness
1.6 mm
Parts
6
Nets
3
Pads
25
Tracks, vias
20, 0
Pours
1
Routed
Yes
KiCad
KiCad 9.0 (file 20241229)
Created
13 Mar 2026
Updated
29 May 2026

Overview

Pcb 352 is an open-source printed circuit board by simone-ingvild, from the simone-ingvild/AnomalyDetection repository on GitHub, published under the GPL-3.0 licence. It is a 2-layer board of 120 × 100 mm with 6 parts on 3 nets, routed with 20 tracks and 0 vias.

Its parts include 3 resistors, 2 ICs and 1 connector.

README

README.md

PCB Anomaly Detection (Spatial PaDiM with Photometric Inputs)

Authors: Rikke Aa. Boysen, Simone I. Lebech, Andreas S. From
Supervisor: Jakob Wilm
Course: Semester Project (Advanced Robotics) Programme: M.Sc. in Advanced Robot Technology
Institution: University of Southern Denmark (SDU)
Semester: 2nd Semester, M.Sc. in Advanced Robot Technology, Spring 2026

This repository implements Spatial PaDiM (Patch Distribution Modeling) for anomaly detection on printed circuit boards (PCBs) using photometric (multi-illumination) image stacks. The framework supports synthetic photometric datasets with 24 fixed illumination directions by default and provides tools for dataset generation, model training, experimentation, and evaluation.

Key Features

  • Inputs consist of grayscale photometric image stacks (24 illumination directions by default, resulting in 24 input channels). Binary illumination masks are not included in the input representation.
  • Anomaly detection is based on a Spatial PaDiM approach. A modified ResNet-18 feature extractor processes multi-channel inputs, feature embeddings are collected at each spatial location, and a Gaussian distribution with Ledoit-Wolf covariance regularization is fitted per spatial position.
  • Evaluation is performed using spatial Mahalanobis distances with top-k aggregation to produce PCB-level anomaly scores and corresponding ROC/AUC metrics.

Repository Status

This README reflects the current implementation. Model training is performed through src/train.py or src/run_experiment.py, dataset generation through src/experiment.py, and evaluation through src/evaluate.py.


Installation

  1. Clone the repository.
  2. Install the required dependencies:
bash
pip install -r requirements.txt

Note: The project was developed using recent Python and PyTorch versions. Ensure that the installed PyTorch build is compatible with your CUDA version or CPU environment.


Dataset Structure

The dataset should be organized as follows:

text
dataset/
├── normal/
│   ├── pcb001/
│   │   ├── image01.png
│   │   ├── ...
│   │   └── image24.png
│   └── ...
└── anomaly/
    ├── pcb101/
    │   ├── image01.png
    │   ├── ...
    │   └── image24.png
    └── ...

Each PCB sample is stored in a separate folder containing 24 grayscale images, one for each illumination direction. By default, image files are expected to follow the naming convention image01.png through image24.png (see src/dataset.py and src/experiment.py).


Synthetic Dataset Generation

The synthetic data generator creates photometric image stacks using the illumination directions specified in src/blenderproc/lights_export.csv.

bash
python src/experiment.py --num_normal 50 --num_anomaly 50

This command generates the dataset/normal/ and dataset/anomaly/ directories along with the corresponding PCB samples.


Model Training

Single Configuration

To train a model using the default configuration:

bash
python src/train.py

The script invokes src.anomaly_model.train() using a predefined configuration suitable for quick experimentation.

Experiment Sweeps

For systematic parameter studies, use:

bash
python src/run_experiment.py

This script executes multiple PaDiM configurations by varying parameters such as feature_dim, topk_ratio, and use_patches. Results are written to the experiment_logs/ directory.


Model Evaluation

Trained models can be evaluated using:

bash
python src/evaluate.py --model_path "src/Training output/padim_model.pth" --save_heatmaps

Evaluation outputs, including CSV files, performance plots, and anomaly heatmaps, are saved to the training output directory specified by TRAINING_OUTPUT_DIR (src/Training output by default).


Repository Overview

src/dataset.py

Implements the PCBAnomalyDataset class responsible for loading photometric image stacks. Optional preprocessing steps include CLAHE enhancement and patch extraction.

src/experiment.py

Contains the synthetic PCB generation pipeline, including surface generation and photometric rendering through render_photometric_images().

src/anomaly_model.py

Implements the modified ResNet-18 feature extractor, Spatial PaDiM training (manual_padim_train), and inference (manual_padim_predict). Trained models are stored as padim_model.pth within the experiment output directory.

src/run_experiment.py

Provides automated execution of multiple experimental configurations and records results in the experiment_logs/ directory.

src/evaluate.py

Loads trained checkpoints and computes evaluation metrics such as ROC and Precision–Recall curves while generating qualitative visualizations.


Limitations

  • Inputs consist of multi-channel grayscale photometric image stacks (24 channels by default). Binary illumination masks are not incorporated into the input representation.
  • The framework implements Spatial PaDiM using Gaussian feature distributions and Mahalanobis distance-based anomaly scoring. Reconstruction-based methods such as autoencoders are not included.
  • Some evaluation routines assume that backbone parameters are available in the saved checkpoint. When using custom checkpoints, verify compatibility between src/anomaly_model.py and src/evaluate.py.

Dependencies

The required packages are listed in requirements.txt.

Core dependencies include:

  • PyTorch (torch)
  • TorchVision (torchvision)
  • NumPy (numpy)
  • Pandas (pandas)
  • Matplotlib (matplotlib)
  • Scikit-learn (scikit-learn)

Parts

6
QtyValueFootprintReferences
2R_0603_1608MetricR_0603_1608MetricR1_0, R1_1
1DIP-8_W7.62mmDIP-8_W7.62mmU2_1
1PinHeader_1x03_P2.54mm_VerticalPinHeader_1x03_P2.54mm_VerticalJ1_2
1R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_HorizontalR_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_HorizontalR0_0
1SOIC-8_3.9x4.9mm_P1.27mmSOIC-8_3.9x4.9mm_P1.27mmU2_0

Questions

How big is the Pcb 352 PCB?

It measures 120 × 100 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Pcb 352 use?

6 parts. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Pcb 352 KiCad files?

From the simone-ingvild/AnomalyDetection repository on GitHub, at the commit this page was made from: the board is KiCad/PCB/pcb_352.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.

Can I use the Pcb 352 design in my own project?

Its repository publishes it under the GPL-3.0 licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).

More from simone-ingvild/AnomalyDetection

12
  • 2 layers120 × 100 mmPcb 472, the printed circuit board in 3D

    Pcb 472

    simone-ingvild/AnomalyDetection

    This repository implements Spatial PaDiM (Patch Distribution Modeling) for anomaly detection on printed circuit boards (PCBs) using photometric (multi-illumination) image stacks.

    14 partsGPL-3.0
  • 2 layers120 × 100 mmPcb 500, the printed circuit board in 3D

    Pcb 500

    simone-ingvild/AnomalyDetection

    This repository implements Spatial PaDiM (Patch Distribution Modeling) for anomaly detection on printed circuit boards (PCBs) using photometric (multi-illumination) image stacks.

    14 partsGPL-3.0
  • 2 layers120 × 100 mmPcb 596, the printed circuit board in 3D

    Pcb 596

    simone-ingvild/AnomalyDetection

    This repository implements Spatial PaDiM (Patch Distribution Modeling) for anomaly detection on printed circuit boards (PCBs) using photometric (multi-illumination) image stacks.

    13 partsGPL-3.0
  • 2 layers120 × 100 mmPcb 107, the printed circuit board in 3D

    Pcb 107

    simone-ingvild/AnomalyDetection

    This repository implements Spatial PaDiM (Patch Distribution Modeling) for anomaly detection on printed circuit boards (PCBs) using photometric (multi-illumination) image stacks.

    12 partsGPL-3.0
  • 2 layers120 × 100 mmPcb 176, the printed circuit board in 3D

    Pcb 176

    simone-ingvild/AnomalyDetection

    This repository implements Spatial PaDiM (Patch Distribution Modeling) for anomaly detection on printed circuit boards (PCBs) using photometric (multi-illumination) image stacks.

    12 partsGPL-3.0
  • 2 layers120 × 100 mmPcb 019, the printed circuit board in 3D

    Pcb 019

    simone-ingvild/AnomalyDetection

    This repository implements Spatial PaDiM (Patch Distribution Modeling) for anomaly detection on printed circuit boards (PCBs) using photometric (multi-illumination) image stacks.

    11 partsGPL-3.0
  • 2 layers120 × 100 mmPcb 236, the printed circuit board in 3D

    Pcb 236

    simone-ingvild/AnomalyDetection

    This repository implements Spatial PaDiM (Patch Distribution Modeling) for anomaly detection on printed circuit boards (PCBs) using photometric (multi-illumination) image stacks.

    11 partsGPL-3.0
  • 2 layers120 × 100 mmPcb 044, the printed circuit board in 3D

    Pcb 044

    simone-ingvild/AnomalyDetection

    This repository implements Spatial PaDiM (Patch Distribution Modeling) for anomaly detection on printed circuit boards (PCBs) using photometric (multi-illumination) image stacks.

    10 partsGPL-3.0
  • 2 layers120 × 100 mmPcb 348, the printed circuit board in 3D

    Pcb 348

    simone-ingvild/AnomalyDetection

    This repository implements Spatial PaDiM (Patch Distribution Modeling) for anomaly detection on printed circuit boards (PCBs) using photometric (multi-illumination) image stacks.

    10 partsGPL-3.0
  • 2 layers120 × 100 mmPcb 516, the printed circuit board in 3D

    Pcb 516

    simone-ingvild/AnomalyDetection

    This repository implements Spatial PaDiM (Patch Distribution Modeling) for anomaly detection on printed circuit boards (PCBs) using photometric (multi-illumination) image stacks.

    10 partsGPL-3.0
  • 2 layers120 × 100 mmPcb 006, the printed circuit board in 3D

    Pcb 006

    simone-ingvild/AnomalyDetection

    This repository implements Spatial PaDiM (Patch Distribution Modeling) for anomaly detection on printed circuit boards (PCBs) using photometric (multi-illumination) image stacks.

    9 partsGPL-3.0
  • 2 layers120 × 100 mmPcb 128, the printed circuit board in 3D

    Pcb 128

    simone-ingvild/AnomalyDetection

    This repository implements Spatial PaDiM (Patch Distribution Modeling) for anomaly detection on printed circuit boards (PCBs) using photometric (multi-illumination) image stacks.

    9 partsGPL-3.0

Similar boards

  • 2 layers18.5 × 11.1 mmSwitch, the printed circuit board in 3D

    Switch

    byrantech/laptop

    anyon_e, a highly integrated, high end, open source laptop. Attempt the impossible.

    6 parts4.3kMIT
  • 2 layers14.6 × 33 mmBrain board SD Card 1, the printed circuit board in 3D

    Brain board SD Card 1

    rusefi/rusefi

    rusefi - GPL internal combustion engine control unit

    6 parts1.2k
  • 2 layers9 × 9 mmDpoint, the printed circuit board in 3D

    Dpoint

    Jcparkyn/dpoint

    Open-source digital stylus using camera tracking and inertial measurements

    6 parts1.1kMIT
  • 2 layers51.5 × 16.6 mmMicroswitchXY Endstop, the printed circuit board in 3D

    MicroswitchXY Endstop

    VoronDesign/Voron-Hardware

    Cool Hardware designed by the Voron Design group

    6 parts1.1kGPL-3.0
  • 2 layers21.9 × 76.7 mmAmiga External, the printed circuit board in 3D

    Amiga External

    hoglet67/RGBtoHDMI

    Bare-metal Raspberry Pi project that provides pixel-perfect sampling of Retro Computer RGB/YUV video and conversion to HDMI

    6 parts1kGPL-3.0
  • 2 layers88.9 × 50.8 mmBusinesscard, the printed circuit board in 3D

    Businesscard

    hackclub/OnBoard

    💡 Join 1,000 teenagers and make your first PCB with a $100 grant!

    6 parts915
  • 2 layers20.3 × 15.2 mmL0 RGB led, the printed circuit board in 3D

    L0 RGB led

    Luos-io/luos_engine

    Open-source and real-time orchestrator for cyber-physical-systems, to easily design, test and deploy embedded applications and digital twins.

    6 parts546MIT
  • 2 layers9 × 3.6 mmOpticalEncoder, the printed circuit board in 3D

    OpticalEncoder

    adamb314/ServoProject

    Getting the most out of your hobby servo

    6 parts545