ncnn_yolox_flutter

This is a plugin to run YOLOX on ncnn.

Demo

on Android

Real DeviceSimulator

on iOS

Real DeviceSimulator

Stream

How to use

1. Add the YOLOX model to assets

For example, you can use yolox_onnx_to_ncnn.ipynb

Note that you will need to manually modify the model.


If you want to use yolox_tiny, you can find it in example/assets/yolox.


Don't forget to add the model of assets to your pubspec.yaml.

flutter:
  assets:
    - assets/yolox/

2. Load the model

final ncnn = NcnnYolox();

ncnn.initYolox(
  modelPath: 'assets/yolox/yolox.bin',
  paramPath: 'assets/yolox/yolox.param',
);

3. Get the result

/// When using image file
/// **Exif Orientation is ignored**
_results = ncnn.detect(
  imagePath: "path",
);

/// When using image pixels
_results = ncnn.detect(
  pixels: image.pixels,
  pixelFormat: PixelFormat.bgra,
  width: image.width,
  height: image.height,
);

Please check example/lib for specific usage.

How to set up for using custom ncnn and custom YOLOX model

1. Build ncnn

See build_ncnn.yaml for details.

If you want pre-built ncnn, look at the URL of the Releases referenced in these files. Such as this https://github.com/KoheiKanagu/ncnn_yolox_flutter/releases/download/x.y.z/ncnn-android.zip

2. Download ncnn

The library is a binary file, so it is not packaged in the repository. The ncnn libraries for iOS and Android are CMake and Cocoapods, downloaded from Github Releases.

The ncnn library zip you are downloading is the artifact of build_ncnn.yaml. Change the URL if you want.


If you do not want to download the ncnn library, remove the process of downloading the zip. Then install the ncnn library manually.

Please refer to the comments in these files.

3. Change the parameters of YOLOX

Change ios/Classes/yolox.cpp if you want.

For example, if you want to change the size of the input image, change YOLOX_TARGET_SIZE.

Alternatively, you can change the ncnn::Net yolox; in the void initYolox(char *modelPath, char *paramPath) method.


The original yolox.cpp is ncnn/yolox.cpp at 20220216 ยท Tencent/ncnn.

Libraries

kanna_rotate_device_orientation_type
kanna_rotate_results
kanna_rotate_type
models
ncnn_yolox
ncnn_yolox_flutter
pixel_channel
pixel_format
yolox_results
yolox_results_painter