MyoQuant-SDH-Model / README.md
Corentin
Model Card and tensorboard
0245482
|
raw
history blame
5.08 kB
metadata
license: agpl-3.0
tags:
  - image
  - keras
  - myology
  - biology
  - histology
  - muscle
  - cells
  - fibers
  - myopathy
  - SDH
  - myoquant
  - classification
  - mitochondria
datasets:
  - corentinm7/MyoQuant-SDH-Data
metrics:
  - accuracy
library_name: keras
model-index:
  - name: MyoQuant-SDH-Resnet50V2
    results:
      - task:
          type: image-classification
          name: Image Classification
        dataset:
          type: corentinm7/MyoQuant-SDH-Data
          name: MyoQuant SDH Data
          split: test
        metrics:
          - type: accuracy
            value: 0.9285
            name: Test Accuracy

Model description

This is the model card for the SDH Model used by the MyoQuant tool.

Intended uses & limitations

It's intended to allow people to use, improve and verify the reproducibility of our MyoQuant tool. The SDH model is used to classify SDH stained muscle fiber with abnormal mitochondria profile.

Training and evaluation data

It's trained on the corentinm7/MyoQuant-SDH-Data, avaliable on HuggingFace Dataset Hub.

Training procedure

This model was trained using the ResNet50V2 model architecture in Keras.
All images have been resized to 256x256 using the tf.image.resize() function from Tensorflow.
Data augmentation was included as layers before ResNet50V2.
Full model code:

data_augmentation = tf.keras.Sequential([
  layers.Resizing(256, 256, interpolation="bilinear", crop_to_aspect_ratio=True, input_shape=(None, None, 3)),
  layers.Rescaling(scale=1./127.5, offset=-1),
  RandomBrightness(factor=0.2, value_range=(-1.0, 1.0)), # Not avaliable in tensorflow 2.8
  layers.RandomContrast(factor=0.2),
  layers.RandomFlip("horizontal_and_vertical"),
  layers.RandomRotation(0.3, fill_mode="constant"),
  layers.RandomZoom(.2, .2, fill_mode="constant"),
  layers.RandomTranslation(0.2, .2,fill_mode="constant"),

])
model = models.Sequential()
model.add(data_augmentation)
model.add(
    ResNet50V2(
    include_top=False,
    input_shape=(256,256,3),
    pooling="avg",
  )
)
model.add(layers.Flatten())
model.add(layers.Dense(2, activation='softmax'))
_________________________________________________________________
 Layer (type)                Output Shape              Param #
=================================================================
 sequential (Sequential)     (None, 256, 256, 3)       0

 resnet50v2 (Functional)     (None, 2048)              23564800

 flatten (Flatten)           (None, 2048)              0

 dense (Dense)               (None, 2)                 4098

=================================================================
Total params: 23,568,898
Trainable params: 23,523,458
Non-trainable params: 45,440
_________________________________________________________________

We used a ResNet50V2 pre-trained on ImageNet as a starting point and trained the model using an EarlyStopping with a value of 20 (i.e. if validation loss doesn't improve after 20 epoch, stop the training and roll back to the epoch with lowest val loss.)
Class imbalance was handled by using the class_-weight attribute during training. It was calculated for each class as (1/n. elem of the class) * (n. of all training elem / 2) giving in our case: {0: 0.6593016912165849, 1: 2.069349315068493}

Training hyperparameters

The following hyperparameters were used during training:

  • optimizer: Adam
  • Learning Rate Schedule: ReduceLROnPlateau(monitor='val_loss', factor=0.2, patience=5, min_lr=MIN_LR with START_LR = 1e-5 and MIN_LR = 1e-7
  • Loss Function: SparseCategoricalCrossentropy
  • Metric: Accuracy

Training Curve

Plot of the accuracy vs epoch and loss vs epoch for training and validation set. Training Curve

Test Results

Results for accuracy metrics on the test split of the corentinm7/MyoQuant-SDH-Data dataset.

105/105 - 15s - loss: 0.1618 - accuracy: 0.9285 - 15s/epoch - 140ms/step
Test data results:
0.928528904914856

How to Import the Model

To import this model as it was trained in Tensorflow 2.8 on Google Colab, RandomBrightness layer had to be added by hand (it was only introduced in Tensorflow 2.10.). So you will need to download the random_brightness.py fille in addition to the model.
Then the model can easily be imported in Tensorflow/Keras using:

from .random_brightness import *
model_sdh = keras.models.load_model(
    "model.h5", custom_objects={"RandomBrightness": RandomBrightness}
)