Skip to the content
PCBKitNew board
2 layers120 × 100 mmPcb 348, 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
10
Nets
6
Pads
80
Tracks, vias
52, 0
Pours
1
Routed
Yes
KiCad
KiCad 9.0 (file 20241229)
Created
13 Mar 2026
Updated
29 May 2026

Overview

Pcb 348 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 10 parts on 6 nets, routed with 52 tracks and 0 vias.

Its parts include 6 ICs, 2 capacitors and 2 resistors.

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

10
QtyValueFootprintReferences
3SOIC-8_3.9x4.9mm_P1.27mmSOIC-8_3.9x4.9mm_P1.27mmU1_1, U2_1, U4_2
2C_Disc_D3.0mm_W1.6mm_P2.50mmC_Disc_D3.0mm_W1.6mm_P2.50mmC4_0, C4_1
2DIP-8_W7.62mmDIP-8_W7.62mmU2_0, U3_0
1R_0603_1608MetricR_0603_1608MetricR0_2
1R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_HorizontalR_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_HorizontalR1_0
1TQFP-32_7x7mm_P0.8mmTQFP-32_7x7mm_P0.8mmU0_0

Questions

How big is the Pcb 348 PCB?

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

What parts does the Pcb 348 use?

10 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 348 KiCad files?

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

Can I use the Pcb 348 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 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
  • 2 layers120 × 100 mmPcb 210, the printed circuit board in 3D

    Pcb 210

    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 layers57 × 55.2 mmLogicAnalyzer, the printed circuit board in 3D

    LogicAnalyzer

    gusmanb/logicanalyzer

    24 channel, 100Msps logic analyzer hardware and software

    10 parts5.1kGPL-3.0
  • 2 layers32.2 × 15.4 mmProtector, the printed circuit board in 3D

    Protector

    byrantech/laptop

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

    10 parts4.3kMIT
  • 2 layers26 × 18 mmConn, the printed circuit board in 3D

    Conn

    yaqwsx/KiKit

    Automation tools for KiCAD

    10 parts2.1kMIT
  • 2 layers44.3 × 30.5 mmLime2-SATA RevA, the printed circuit board in 3D

    Lime2-SATA RevA

    OLIMEX/OLINUXINO

    OLINUXINO is Open Source / Open Hardware, low cost from EUR 24 Linux Industrial grade Single Board Computer capable to operate -25+85C

    10 parts1.5k
  • 2 layers17.8 × 43.2 mmNano Adapter, the printed circuit board in 3D

    Nano Adapter

    VoronDesign/Voron-Hardware

    Cool Hardware designed by the Voron Design group

    10 parts1.1kGPL-3.0
  • 2 layers53.9 × 23.2 mmBuffer, the printed circuit board in 3D

    Buffer

    hoglet67/RGBtoHDMI

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

    10 parts1kGPL-3.0