Skip to content

Commit

Permalink
Merge branch 'MaximIntegratedAI:develop' into regression_test
Browse files Browse the repository at this point in the history
  • Loading branch information
asyatrhl authored Jan 12, 2024
2 parents c9b9c06 + da4387e commit ef93619
Show file tree
Hide file tree
Showing 42 changed files with 1,511 additions and 1,121 deletions.
2 changes: 1 addition & 1 deletion .github/linters/.python-lint
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ignored-classes = ModelProto
max-line-length = 99
[DESIGN]
max-locals=100
max-statements=300
max-statements=350
min-public-methods=1
max-branches=120
max-module-lines=5000
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@
path = distiller
url = https://github.com/MaximIntegratedAI/distiller.git
branch = pytorch-1.8
[submodule "datasets/face_id/facenet_pytorch"]
path = datasets/face_id/facenet_pytorch
url = https://github.com/MaximIntegratedAI/facenet-pytorch.git
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ignored-classes = ModelProto
max-line-length = 99
[DESIGN]
max-locals=100
max-statements=300
max-statements=350
min-public-methods=1
max-branches=120
max-module-lines=5000
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ADI MAX78000/MAX78002 Model Training and Synthesis

November 13, 2023
January 10, 2024

ADI’s MAX78000/MAX78002 project is comprised of five repositories:

Expand Down Expand Up @@ -1534,6 +1534,11 @@ The following table describes the most important command line arguments for `tra
| `--nas` | Enable network architecture search | |
| `--nas-policy` | Define NAS policy in YAML file | `--nas-policy nas/nas_policy.yaml` |
| `--regression` | Select regression instead of classification (changes Loss function, and log output) | |
| `--dr` | Set target embedding dimensionality for dimensionality reduction |`--dr 64` |
| `--scaf-lr` | Initial learning rate for sub-center ArcFace loss optimizer | |
| `--scaf-scale` |Scale hyperparameter for sub-center ArcFace loss | |
| `--scaf-margin` |Margin hyperparameter for sub-center ArcFace loss | |
| `--backbone-checkpoint` |Path to checkpoint from which to load backbone weights | |
| *Display and statistics* | | |
| `--enable-tensorboard` | Enable logging to TensorBoard (default: disabled) | |
| `--confusion` | Display the confusion matrix | |
Expand All @@ -1552,6 +1557,7 @@ The following table describes the most important command line arguments for `tra
| `--summary onnx_simplified` | Export trained model to simplified [ONNX](https://onnx.ai/) file (default name: model.onnx) | |
| `--summary-filename` | Change the file name for the exported model | `--summary-filename mnist.onnx` |
| `--save-sample` | Save data[index] from the test set to a NumPy pickle for use as sample data | `--save-sample 10` |
| `--slice-sample` | For models that require RGB input, when the sample from the dataset has additional channels, slice the sample into 3 channels | |
#### ONNX Model Export
Expand Down Expand Up @@ -3340,6 +3346,8 @@ Additional information about the evaluation kits, and the software development k
[AHB Addresses for MAX78000 and MAX78002](docs/AHBAddresses.md)
[Facial Recognition System](https://github.com/MaximIntegratedAI/ai8x-training/blob/develop/docs/FacialRecognitionSystem.md)
---
Expand Down
Binary file modified README.pdf
Binary file not shown.
76 changes: 75 additions & 1 deletion ai8x_blocks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###################################################################################################
#
# Copyright (C) 2020-2022 Maxim Integrated Products, Inc. All Rights Reserved.
# Copyright (C) 2020-2023 Maxim Integrated Products, Inc. All Rights Reserved.
#
# Maxim Integrated Products, Inc. Default Copyright Notice:
# https://www.maximintegrated.com/en/aboutus/legal/copyrights.html
Expand Down Expand Up @@ -116,6 +116,80 @@ def forward(self, x): # pylint: disable=arguments-differ
return self.resid(y, x)


class ConvResidualBottleneck(nn.Module):
"""
AI8X module based on Residual Bottleneck Layer.
Depthwise convolution is replaced with standard convolution.
This module uses ReLU activation not ReLU6 as the original study suggests [1],
because of MAX7800X capabilities.
Args:
in_channels: number of input channels
out_channels: number of output channels
expansion_factor: expansion_factor
stride: stirde size (default=1)
bias: determines if bias used at non-depthwise layers.
depthwise_bias: determines if bias used at depthwise layers.
References:
[1] https://arxiv.org/pdf/1801.04381.pdf (MobileNetV2)
"""
def __init__(self, in_channels, out_channels, expansion_factor, stride=1, bias=False,
depthwise_bias=False, **kwargs):
super().__init__()
self.stride = stride
hidden_channels = int(round(in_channels * expansion_factor))
if hidden_channels == in_channels:
self.conv1 = ai8x.Empty()
else:
self.conv1 = ai8x.FusedConv2dBNReLU(in_channels, hidden_channels, 1, padding=0,
bias=bias, **kwargs)
if stride == 1:
if depthwise_bias:
self.conv2 = ai8x.FusedConv2dBN(hidden_channels, out_channels, 3,
padding=1, stride=stride,
bias=depthwise_bias, **kwargs)

else:
self.conv2 = ai8x.Conv2d(hidden_channels, out_channels, 3,
padding=1, stride=stride,
bias=depthwise_bias, **kwargs)

else:
if depthwise_bias:
self.conv2 = ai8x.FusedMaxPoolConv2dBN(hidden_channels,
out_channels, 3,
padding=1, pool_size=stride,
pool_stride=stride,
bias=depthwise_bias, **kwargs)

else:
self.conv2 = ai8x.FusedMaxPoolConv2d(hidden_channels,
out_channels, 3,
padding=1, pool_size=stride,
pool_stride=stride,
bias=depthwise_bias, **kwargs)

if (stride == 1) and (in_channels == out_channels):
self.resid = ai8x.Add()
else:
self.resid = self.NoResidual()

class NoResidual(nn.Module):
"""
Does nothing.
"""
def forward(self, *x): # pylint: disable=arguments-differ
"""Forward prop"""
return x[0]

def forward(self, x): # pylint: disable=arguments-differ
"""Forward prop"""
y = self.conv1(x)
y = self.conv2(y)
return self.resid(y, x)


class MBConvBlock(nn.Module):
"""Mobile Inverted Residual Bottleneck Block.
Expand Down
41 changes: 0 additions & 41 deletions datasets/face_id/README.md

This file was deleted.

1 change: 0 additions & 1 deletion datasets/face_id/facenet_pytorch
Submodule facenet_pytorch deleted from 14b312
171 changes: 0 additions & 171 deletions datasets/face_id/gen_vggface2_embeddings.py

This file was deleted.

Loading

0 comments on commit ef93619

Please sign in to comment.