duan8/mobilenet/mobilenetv2
Phoenix b671024a27
Add Ghostnet && Fix object destruction order in APIToModel function to avoid undefined behavior (#1581)
* add ghostnet

* add ghostnet

* add ghostnetV1&ghostnetV2

* Fix object destruction order in APIToModel function to avoid undefined behavior

* Fix pre-commit errors in ghostnet/README.md

* Fix pre-commit errors

* Fix pre-commit errors in mobilenetV3

* Add a noqa marker in mobilenet py files
2024-10-09 18:48:03 +08:00
..
CMakeLists.txt Add Ghostnet && Fix object destruction order in APIToModel function to avoid undefined behavior (#1581) 2024-10-09 18:48:03 +08:00
logging.h Add Ghostnet && Fix object destruction order in APIToModel function to avoid undefined behavior (#1581) 2024-10-09 18:48:03 +08:00
mobilenet_v2.cpp Add Ghostnet && Fix object destruction order in APIToModel function to avoid undefined behavior (#1581) 2024-10-09 18:48:03 +08:00
mobilenet_v2.py Add Ghostnet && Fix object destruction order in APIToModel function to avoid undefined behavior (#1581) 2024-10-09 18:48:03 +08:00
README.md Add: AlexNet, MobileNetV3, DenseNet121 Python Network Definition API (#512) 2021-04-28 13:39:55 +08:00

mobilenet v2

MobileNetV2 architecture from "MobileNetV2: Inverted Residuals and Linear Bottlenecks" https://arxiv.org/abs/1801.04381.

For the Pytorch implementation, you can refer to pytorchx/mobilenet

Following tricks are used in this mobilenet,

  • Relu6 is used in mobilenet v2. We use Relu6(x) = Relu(x) - Relu(x-6) in tensorrt.
  • Batchnorm layer, implemented by scale layer.
// 1. generate mobilenet.wts from [pytorchx/mobilenet](https://github.com/wang-xinyu/pytorchx/tree/master/mobilenet)

// 2. put mobilenet.wts into tensorrtx/mobilenet

// 3. build and run

cd tensorrtx/mobilenet/mobilenetv2

mkdir build

cd build

cmake ..

make

sudo ./mobilenet -s   // serialize model to plan file i.e. 'mobilenet.engine'

sudo ./mobilenet -d   // deserialize plan file and run inference

// 4. see if the output is same as pytorchx/mobilenet

TensorRT Python API

# 1. generate mobilenetv2.wts from [pytorchx/mobilenet](https://github.com/wang-xinyu/pytorchx/tree/master/mobilenet)

# 2. put mobilenetv2.wts into tensorrtx/mobilenet/mobilenetv2

# 3. install Python dependencies (tensorrt/pycuda/numpy)

cd tensorrtx/mobilenet/mobilenetv2

python mobilenet_v2.py -s   // serialize model to plan file i.e. 'mobilenetv2.engine'
python mobilenet_v2.py -d   // deserialize plan file and run inference

# 4. see if the output is same as pytorchx/mobilenet