References
- Transfer Learning with TensorFlow Hub Tutorials https://www.tensorflow.org/tutorials/images/transfer_learning_with_hub
- MobileNet V2 (Lightweight models for use in mobile application): https://arxiv.org/pdf/1801.04381.pdf
- Hands-on Machine Learning with Scikit-Learn, Keras, & TensorFlow
- Chapter 14
- TensorFlow Keras API: https://www.tensorflow.org/api_docs/python/tf/
- TensorFlow Hub API: https://www.tensorflow.org/hub/api_docs/python/hub
Training Image Data with GNN
- Image classification
- Categories:
- AHS students/staff or Not AHS students/staff
- Graduation year (Class-2022)
- Each group’s images can be saved in a directory. The directory name is labeled as the category’s name
- Formatted for TensorFlow Hub (JPG, BMP, PNG, etc).
- Put all image files in a single directory with file format
- <purpose>-<id>-index-<category name>.bmp
- Must be bmp since this step is for GNN
- <purpose> will be:
- T: Training
- V: Validation
- P: Predication
Prepare Image Files
- Size: 224×224 with 3 channels (red, blue, green)
- Save the image file in <purpose>-<id>-index-<category name>.bmp
- 80% for training, 15% for validation, 5% for prediction
- Around 2,000 – 3,000 image files
Spray Image Data to HPCC Cluster
- Spray through ECL Watch as Blob data type
Use GNN Tutorial model (or a similar alternative)
- Two categories: AHS or Not_AHS
Use MobileNet V2 Model
- In a ECL embedded Python module
- Feature_extractor_model = “https://tfhub.dev/google/tf2-preview/mobilenet_v2/feature_vector/4”
- feature_extractor_layer = hub.KerasLayer(
feature_extractor_model, input_shape=(224, 224, 3), trainable=False)
- feature_batch = feature_extractor_layer(image_batch) image_batch will be in the shape of (32, 224, 224, 3). The first “32” is the batch Size
- save the feature_extraor_layer in json string
- In a ECL module
- Create sequential model with input Tensor, feature_extraor_layer json and output KerasLayer
- compile model
- train the model
- validate and predict
- Output loss and accuracy,etc
- Save the model in JSON string
- Save the weights in JSON string
- In a ECL Embedded Python Module
- Restore the model with the model JSON and weights JSON.
- Output model information to the verify
- Convert the model to TensorFlow lite
- Save both original model and lite model
If I am unable to use the pretrained MobileNet V2 model, I will try to manually create it or use something similar
- Reference 3) page 497
- Introduction to build a ResNet-34 model
- Follow the layout there
- Code:
model = keras.models.Sequential()
model.add( keras.layers.Conv2D( 64, 7, strides = 2, input_shape =[ 224, 224, 3], padding =” same”, use_bias = False))
model.add( keras.layers.BatchNormalization())
model.add( keras.layers.Activation(” relu”))
model.add( keras.layers.MaxPool2D( pool_size = 3, strides = 2, padding =” same”))
prev_filters = 64
for filters in [64] * 3 + [128] * 4 + [256] * 6 + [512] * 3:
strides = 1 if filters = = prev_filters else 2 model.add( ResidualUnit( filters, strides = strides)) prev_filters = filters
model.add( keras.layers.GlobalAvgPool2D())
model.add( keras.layers.Flatten())
model.add( keras.layers.Dense( 2, activation =” softmax”))
This is not ideal since there are many filters to be created and added, but it is a valid backup plan.