Skip to content

This is assignment 5 of Deep Learning, a course at Institute of Data Science, National Cheng Kung University. This project aims to utilize deep learning techniques to perform defect classification for AOI images.

Notifications You must be signed in to change notification settings

jayenliao/DL-AOI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deep Learning - HW5: Automated Optical Inspection (AOI)

Author: Jay Liao ([email protected])

This is assignment 5 of Deep Learning, a course at Institute of Data Science, National Cheng Kung University. This project aims to utilize deep learning techniques to perform defect classification for AOI images.

Data

  • Images: please go to the page of the competition on the AIdea here to download raw image files with two folders, ./train_images/ and ./test_images/.

  • File name lists of images: ./train.csv and ./test.txt.

Code

  • main_keras.py: the main program for training a 5-layered CNN with Keras. The following codes demonstrate the model structute.
raw_model = Sequential([
    layers.Conv2D(16, 3, input_shape=(size[0], size[1], 1), padding='same', activation='relu', kernel_regularizer=tf.keras.regularizers.l2(l=0.01)),
    layers.MaxPooling2D(),
    layers.Conv2D(24, 3, padding='same', activation='relu', kernel_regularizer=tf.keras.regularizers.l2(l=0.01)),
    layers.MaxPooling2D(),
    layers.Conv2D(24, 3, padding='same', activation='relu', kernel_regularizer=tf.keras.regularizers.l2(l=0.01)),
    layers.MaxPooling2D(),
    layers.Conv2D(24, 3, padding='same', activation='relu', kernel_regularizer=tf.keras.regularizers.l2(l=0.01)),
    layers.MaxPooling2D(),
    layers.Conv2D(24, 3, padding='same', activation='relu', kernel_regularizer=tf.keras.regularizers.l2(l=0.01)),
    layers.MaxPooling2D(),
    layers.Dropout(0.2),
    layers.Flatten(),
    layers.Dense(32, activation='relu'),
])
  • Source codes for training a 5-layered CNN with Keras:

    • ./aoi_keras/args.py: define the arguments parser

    • ./aoi_keras/trainer.py: class for training, predicting, and evaluating the models

    • ./aoi_keras/load_data.py: functions for loading images with train/val/test splitting

  • main_keras.py: the main program for fine tuning a pretrained ResNet50 model and an EfficientNet-b7 model.

  • Source codes for fine tuning a pretrained ResNet50 model and an EfficientNet-b7 model:

    • ./aoi_torch/args.py: define the arguments parser

    • ./aoi_torch/trainer.py: class for training, predicting, and evaluating the models

    • ./aoi_torch/models.py: define the models.

    • ./aoi_torch/load_data.py: functions for loading images with train/val/test splitting

Folders

  • ./train_images/ should contain 2,528 raw training image files (please go here to download). They will be splitted into three subsets after running the main program (folders ./images_tr/, ./images_va/, and ./images_te/ will be created in torch version).

  • ./test_images/ should contain 10,142 testing image files without ground truth lables (please go here to download). The folder ./images_test/ will be created after running the main program of torch version.

  • ./output_torch/ and ./output_keras/ will contain trained models, model performances, and experiments results after running.

Requirements

numpy
pandas
tqdm
opencv-python==3.4.2.16
matplotlib==3.1.3
torch
keras==2.2.5
tensorflow==2.3.1
tensorflow-gpu==2.3.1

Usage

  1. Clone this repo.
git clone https://github.com/jayenliao/DL-AOI.git
  1. Set up the required packages.
cd DL-AOI
pip3 install -H requirements.txt
  1. Run the experiments.
python3 main_keras.py
python3 main_torch.py

Reference

  1. https://github.com/bentrevett/pytorch-image-classification
  2. https://github.com/pytorch/tutorials
  3. https://github.com/pytorch/examples
  4. https://colah.github.io/posts/2014-10-Visualizing-MNIST/
  5. https://distill.pub/2016/misread-tsne/
  6. https://towardsdatascience.com/visualising-high-dimensional-datasets-using-pca-and-t-sne-in-python-8ef87e7915b
  7. https://github.com/activatedgeek/LeNet-5
  8. https://github.com/ChawDoe/LeNet5-MNIST-PyTorch
  9. https://github.com/kuangliu/pytorch-cifar
  10. https://github.com/akamaster/pytorch_resnet_cifar10
  11. https://sgugger.github.io/the-1cycle-policy.html

About

This is assignment 5 of Deep Learning, a course at Institute of Data Science, National Cheng Kung University. This project aims to utilize deep learning techniques to perform defect classification for AOI images.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages