Basic_CNNs_TensorFlow2

by calmisential

A tensorflow2 implementation of some basic CNNs(MobileNetV1/V2/V3, EfficientNet, ResNeXt, InceptionV...

311 Stars 106 Forks Last release: Not found MIT License 84 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

BasicCNNsTensorFlow2

A tensorflow2 implementation of some basic CNNs.

Networks included:

Other networks

For AlexNet and VGG, see : https://github.com/calmisential/TensorFlow2.0ImageClassification
For InceptionV3, see : https://github.com/calmisential/TensorFlow2.0InceptionV3
For ResNet, see : https://github.com/calmisential/TensorFlow2.0
ResNet

Train

  1. Requirements:
  2. Python >= 3.6
  3. Tensorflow >= 2.3.0rc1
  4. To train the network on your own dataset, you can put the dataset under the folder original dataset, and the directory should look like this:
    |——original dataset
    |——class_name_0
    |——class_name_1
    |——class_name_2
    |——class_name_3
    
  5. Run the script split_dataset.py to split the raw dataset into train set, valid set and test set. The dataset directory will be like this:
    |——dataset
    |——train
        |——class_name_1
        |——class_name_2
        ......
        |——class_name_n
    |——valid
        |——class_name_1
        |——class_name_2
        ......
        |——class_name_n
    |—-test
        |——class_name_1
        |——class_name_2
        ......
        |——class_name_n
    
  6. Run to_tfrecord.py to generate tfrecord files.
  7. Change the corresponding parameters in config.py.
  8. Run train.py to start training.
    If you want to train the EfficientNet, you should change the IMAGEHEIGHT and IMAGEWIDTH to resolution in the params, and then run train.py to start training. ## Evaluate Run evaluate.py to evaluate the model's performance on the test dataset.

Different input image sizes for different neural networks

      <td>SqueezeNet</td>
      <td align="center">SqueezeNet</td>
      <td align="center">(224 * 224)</td>

 <tr align="center">
      <td rowspan="4">DenseNet</td>
      <td>DenseNet_121</td>
      <td>(224 * 224)</td>
 </tr>
 <tr align="center">
      <td>DenseNet_169</td>
      <td>(224 * 224)</td>
 </tr>
 <tr align="center">
      <td>DenseNet_201</td>
      <td>(224 * 224)</td>
 </tr>
 <tr align="center">
      <td>DenseNet_269</td>
      <td>(224 * 224)</td>
 </tr>
 <tr align="center">
      <td>ShuffleNetV2</td>
      <td>ShuffleNetV2</td>
      <td>(224 * 224)</td>
 </tr>
 <tr align="center">
      <td rowspan="5">ResNet</td>
      <td>ResNet_18</td>
      <td>(224 * 224)</td>
 </tr>
 <tr align="center">
      <td>ResNet_34</td>
      <td>(224 * 224)</td>
 </tr>
 <tr align="center">
      <td>ResNet_50</td>
      <td>(224 * 224)</td>
 </tr>
 <tr align="center">
      <td>ResNet_101</td>
      <td>(224 * 224)</td>
 </tr>
 <tr align="center">
      <td>ResNet_152</td>
      <td>(224 * 224)</td>
 </tr>
Type Neural Network Input Image Size (height * width)
MobileNet MobileNet_V1 (224 * 224)
MobileNet_V2 (224 * 224)
MobileNet_V3 (224 * 224)
EfficientNet EfficientNet(B0~B7) /
ResNeXt ResNeXt50 (224 * 224)
ResNeXt101 (224 * 224)
SEResNeXt SEResNeXt50 (224 * 224)
SEResNeXt101 (224 * 224)
Inception InceptionV4 (299 * 299)
Inception_ResNet_V1 (299 * 299)
Inception_ResNet_V2 (299 * 299)
SE_ResNet SE_ResNet_50 (224 * 224)
SE_ResNet_101 (224 * 224)
SE_ResNet_152 (224 * 224)

References

  1. MobileNet_V1: Efficient Convolutional Neural Networks for Mobile Vision Applications
  2. MobileNet_V2: Inverted Residuals and Linear Bottlenecks
  3. MobileNet_V3: Searching for MobileNetV3
  4. EfficientNet: EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks
  5. The official code of EfficientNet: https://github.com/tensorflow/tpu/tree/master/models/official/efficientnet
  6. ResNeXt: Aggregated Residual Transformations for Deep Neural Networks
  7. InceptionV4/InceptionResNetV1/InceptionResNet_V2: Inception-v4, Inception-ResNet and the Impact of Residual Connectionson Learning
  8. The official implementation of InceptionV4: https://github.com/tensorflow/models/blob/master/research/slim/nets/inceptionv4.py
  9. The official implementation of InceptionResNetV2: https://github.com/tensorflow/models/blob/master/research/slim/nets/inceptionresnetv2.py
  10. SENet: Squeeze-and-Excitation Networks
  11. SqueezeNet: SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and <0.5MB model size
  12. DenseNet: Densely Connected Convolutional Networks
  13. https://zhuanlan.zhihu.com/p/37189203
  14. ShuffleNetV2: ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design
  15. https://zhuanlan.zhihu.com/p/48261931
  16. ResNet: Deep Residual Learning for Image Recognition

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.