GithubHelp home page GithubHelp logo

matthewng3416 / axi_pcb_defect_detection Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chinthysl/axi_pcb_defect_detection

0.0 0.0 0.0 4.11 MB

This repo contains data pre-processing, classification and defect detection methodologies for images from Advance XRay Inspection from multi-layer PCB boards. Proprietary AXI image dataset is not included in this repo. Users can use their own datasets on top of the OOP data extraction layer and neural network models implemented here.

License: MIT License

Python 100.00%

axi_pcb_defect_detection's Introduction

AXI_PCB_defect_detection

This repo contains data pre-processing, classification and defect detection methodologies for images from Advance XRay Inspection from multi-layer PCB boards. Please go through our research paper if you need more details and be kind enough to Cite it if you are going to use this implementation.

Details of the proprietory dataset

  • Distinct .jpg images including all slices – 32377
  • Distinct ROIs with labels – 92208
  • PCB types – 17
  • Distinct XRay board views – 8063
  • Views containing correct ROIs – 6112, Views containing incorrect ROIs – 1951
  • Slices per XRay board view (slices per physical solder joint) – 3, 4, 5, 6
  • Number of solder joints – 22872
  • Correct joints – 15613, Incorrect joints – 7259
  • Correct-square solder joints – 14672
  • missing - 1496, short - 5605, insufficient - 4691 normal - 2880
  • 3 sliced joints - 5471, 4 sliced joints - 8590, 5 sliced joints - 97, 6 sliced joints - 277

Special Notes:

  • A single XRay board view has multiple ROIs marked.
  • A single defective ROI(solder joint) can have multiple defect labels.
  • If a XRay view contains one incorrect ROI, all solder joints in that view are considered as incorrect.

General Guidelines for contributors

  • Please add your data folders into the ignore file until DVC is setup
  • Don't do git add --all. Please be aware of what you commit.

Project file structure

├── non_defective_xml_files/        # put xml labels for non defective rois here
├── original_dataset/               # put two image folders and PTH2_reviewed.csv inside this
├── board_view.py                   # python class for a unique PCB BoardView
├── constants.py                    # constant values for the project
├── incorrect_roi_images.p          # this file contains file names of all incorrect rois
├── main.py                         # script for creating objects and run ROI concatenation
├── solder_joint.py                 # python class for a unique PCB SolderJoint
├── solder_joint_container.py       # python class containing all BoardView and SolderJoint objs
├── solder_joint_container_obj.p    # saved pickle obj for SolderJointContainer class
└── utils_basics.py                 # helper functions

Code explanation

solder_joint.py

+-----------------------------------------------------------------------+
|                           SolderJoint                                 |
+-----------------------------------------------------------------------+
|+ self.component_name                                                  |
|+ self.defect_id                                                       |
|+ self.defect_name                                                     |
|+ self.roi                                                             |
|+ self.is_square                                                       |
|+ self.slice_dict                                                      |
+-----------------------------------------------------------------------+
|+__init__(self, component_name, defect_id, defect_name, roi)           |
|+add_slice(self, slice_id, file_location)                              |
|+concat_first_four_slices_and_resize(self, width, height)              |
+-----------------------------------------------------------------------+
  • add_slice(self, slice_id, file_location):

    This method will add the slice id and corresponding image location of that slice to the self.slice_dict.

  • concat_first_four_slices_and_resize(self, width, height):

    In this method only 1st 4 slices from ids 0,1,2,3 are concatenated in a 2d square shape. Concatenated 2d image and the label of the joint is returned. You have to catch them in SolderJointContainer object and save to disk accordingly.

    If you want to write a new method of channel concatenation please modify this method. (For an example, if you want to generate gray scale image per slice and concatenate them as a pickle or numpy file)

board_view.py

+-----------------------------------------------------------------------+
|                           BoardView                                   |
+-----------------------------------------------------------------------+
|+ self.view_identifier                                                 |
|+ self.is_incorrect_view                                               |
|+ self.solder_joint_dict                                               |
|+ self.slice_dict                                                      |
+-----------------------------------------------------------------------+
|+__init__(self, view_identifier)                                       |
|+add_solder_joint(self, component, defect_id, defect_name, roi)        |
|+add_slice(self, file_location)                                        |
|+add_slices_to_solder_joints(self)                                     |
+-----------------------------------------------------------------------+
  • This class contains all the SolderJoint objects and all the slices details regarding that board view of the PCB.

solder_joint_container.py

+-----------------------------------------------------------------------+
|                           SolderJointContainer                        |
+-----------------------------------------------------------------------+
|+ self.board_view_dict                                                 |
|+ self.new_image_name_mapping_dict                                     |
|+ self.csv_details_dict                                                |
|+ self.incorrect_board_view_ids                                        |
+-----------------------------------------------------------------------+
|+__init__(self)                                                        |
|+mark_all_images_with_rois(self)                                       |
|+load_non_defective_rois_to_container(self)                            |
|+find_flag_incorrect_roi_board_view_objs(self)                         |
|+save_concat_images_first_four_slices(self, width=128, height=128)     |
|+print_container_details(self)                                         |
|+write_csv_defect_roi_images(self)                                     |
+-----------------------------------------------------------------------+
  • save_concat_images_first_four_slices(self, width=128, height=128):

    In this method only 1st 4 slices from ids 0,1,2,3 are concatenated in a 2d square shape. Concatenated 2d image and the label of the joints returned from the SolderJoint object is saved to the disk accordingly.

    If you want to write a new method of channel concatenation please modify this method.

main.py

SolderJointContainer object is created inside this script. Then using that object we can call the required method to generate concatenated images.

DVC integration

This section will explains about setting up the data version controlling and storage for the project. Data version control is integrated in this project. You can simple train any model by changing parameters of the neural network models. After training you'll see changes in data folders. DVC commit those changes followed by a git commit. Trained models and data will be tracked by a local DVC storage.

axi_pcb_defect_detection's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.