Author: Jay Liao (re6094028@gs.ncku.edu.tw)
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.
-
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
.
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
-
-
./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.
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
- Clone this repo.
git clone https://github.com/jayenliao/DL-AOI.git
- Set up the required packages.
cd DL-AOI
pip3 install -H requirements.txt
- Run the experiments.
python3 main_keras.py
python3 main_torch.py
- https://github.com/bentrevett/pytorch-image-classification
- https://github.com/pytorch/tutorials
- https://github.com/pytorch/examples
- https://colah.github.io/posts/2014-10-Visualizing-MNIST/
- https://distill.pub/2016/misread-tsne/
- https://towardsdatascience.com/visualising-high-dimensional-datasets-using-pca-and-t-sne-in-python-8ef87e7915b
- https://github.com/activatedgeek/LeNet-5
- https://github.com/ChawDoe/LeNet5-MNIST-PyTorch
- https://github.com/kuangliu/pytorch-cifar
- https://github.com/akamaster/pytorch_resnet_cifar10
- https://sgugger.github.io/the-1cycle-policy.html