UNCG-DAISY / tinyCamML

flooding on roadways with TinyML
MIT License
2 stars 1 forks source link

develop binary classification model #2

Closed ebgoldstein closed 2 years ago

ebgoldstein commented 2 years ago

use TF to make classification model ( i.e., a notebook).

ebgoldstein commented 2 years ago

here is a simple transfer learning template: https://github.com/ebgoldstein/Coastal_TF_templates/blob/main/src/Classification.ipynb

ebgoldstein commented 2 years ago

to do:

Bolewitz commented 2 years ago

Committed jupyter notebook, 9b973aa. Curves seem to look okay, but predictions using this model appear to be very wrong. Using gradcam it looks like the features it is picking out are wrong. Sometimes picking out cars or light hitting the lens in flooded images.

image image image

Bolewitz commented 2 years ago

Debugging resources https://distill.pub/2017/feature-visualization/ https://wandb.ai/site/experiment-tracking

ebgoldstein commented 2 years ago
Bolewitz commented 2 years ago

Committed new training and testing notebooks 6d10270, 3306b8f.

This model was trained using images from BF_01, CB_01, and CB_03. Models and this dataset can be found on the Google Drive. Some stats for other models I trained can also be found there.

Some notes and problems:

ebgoldstein commented 2 years ago
  1. great to see that the confusion matrix (and scores) now match the validation curves.. (i.e., model is ~70% right now)
  2. This makes sense:

    Loss and accuracy curves are worse than when I was training with just BF_01 images.

  3. Val accuracy plateauing is ok for now. I do think the next step is to try 'fine-tuning' the whole model, with learning rate set very low as a second step.. look at this example: https://keras.io/guides/transfer_learning/

I suggest that after you 'fine tune' the model, you recommit the notebook, close this issue, and we walk through the quantization steps.. (i.e., don;t worry about W&B for now)..

Bolewitz commented 2 years ago

Recommitted the notebook. a477ede Loaded up the same model, set the layers to trainable, and retrained for 30 epochs with a very low learning rate. The training curves made it seem like the model was not improved after fine tuning. However, the f1 score for both flooded and not flooded improved from the fine tuning. Model testing results after fine tuning:

          precision    recall  f1-score   support

   False       0.87      0.88      0.88      2365
    True       0.79      0.77      0.78      1356

accuracy                           0.84      3721
macro avg      0.83      0.83      0.83      3721
weighted avg   0.84      0.84      0.84      3721

This model has been uploaded to google drive as "mobilenetv2_water_18finetune".