Skip to content

๐Ÿ”Œ This repository contains a Python project for PCB Image Segmentation using Multi-UNet, a neural network architecture. The project includes code for training the model on a custom dataset of PCB images, generating image masks for each class, and predicting the classes of new images. The results of the model are provided in the form of example ima

Notifications You must be signed in to change notification settings

pinguinonice/pcb_analysis

Repository files navigation

PCB Image Segmentation using Multi-UNet

This is a Python project for PCB Image Segmentation using Multi-UNet. In this project, we have used Multi-UNet architecture to segment PCB images into background, IC and PCB classes. We have used a dataset of PCB images from https://zenodo.org/record/3886553 to train the model and generated image masks for each class. We have also provided a prediction script to predict the classes of new images.

my captionmy captionmy caption

Yolo IC detection

Ground Truth Prediction
cvl_pcb_dslr_1-pcb2-rec4_annotated.jpg cvl_pcb_dslr_1-pcb2-rec4.jpg

Requirements

To run the code, you need to have the following Python packages installed:

  • numpy
  • keras
  • sklearn
  • opencv-python
  • matplotlib
  • patchify

You can install these packages using pip:

pip install numpy keras sklearn opencv-python matplotlib patchify

Dataset

We have used a custom dataset of PCB images for training and validation. The dataset contains images of size 256x256 with three classes - background, IC and PCB. The dataset is divided into training and validation sets.

You can download the dataset from this link.

Usage

Training

To train the model, run the train_unet.py script. Before running the script, make sure to set the following variables in the script:

  • r: Number of rows for patches
  • c: Number of columns for patches
  • size_x: Size of patches (width)
  • size_y: Size of patches (height)
  • n_input_band: Number of input bands
  • n_classes: Number of classes to segment

The script will generate patches from the input images and train the model on those patches. The trained model will be saved in the weights directory.

Prediction

To predict the classes of new images, run the predict_pcb.py script. Before running the script, make sure to set the following variable in the script:

  • path_weights: Path to the trained model weights file

The script will load the model, predict the classes of new images and display the input image, predicted mask and ground truth mask for each image.

Results

Here are some example results of the model: Left: Prediction, Middel: Groundtruth, Right: Input

my captionmy captionmy caption

my captionmy captionmy caption

my captionmy captionmy caption

YoloV3 Object Detection

Ground Truth vs. Predictions for PCB Images

Ground Truth Images

Ground Truth Prediction
cvl_pcb_dslr_1-pcb2-rec4_annotated.jpg cvl_pcb_dslr_1-pcb2-rec4.jpg
cvl_pcb_dslr_1-pcb4-rec2_annotated.jpg cvl_pcb_dslr_1-pcb4-rec2.jpg
cvl_pcb_dslr_1-pcb8-rec1_annotated.jpg cvl_pcb_dslr_1-pcb8-rec1.jpg
cvl_pcb_dslr_2-pcb26-rec1_annotated.jpg cvl_pcb_dslr_2-pcb26-rec1.jpg
cvl_pcb_dslr_2-pcb28-rec2_annotated.jpg cvl_pcb_dslr_2-pcb28-rec2.jpg
cvl_pcb_dslr_2-pcb37-rec1_annotated.jpg cvl_pcb_dslr_2-pcb37-rec1.jpg
cvl_pcb_dslr_3-pcb48-rec2_annotated.jpg cvl_pcb_dslr_3-pcb48-rec2.jpg
cvl_pcb_dslr_3-pcb49-rec4_annotated.jpg cvl_pcb_dslr_3-pcb49-rec4.jpg

About

๐Ÿ”Œ This repository contains a Python project for PCB Image Segmentation using Multi-UNet, a neural network architecture. The project includes code for training the model on a custom dataset of PCB images, generating image masks for each class, and predicting the classes of new images. The results of the model are provided in the form of example ima

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages