ncnn_yolox_flutter

这是一个在ncnn上运行YOLOX的插件。

演示

在Android上

真实设备 模拟器

在iOS上

真实设备 模拟器

Stream

如何使用

1. 将YOLOX模型添加到assets

例如,您可以使用 yolox_onnx_to_ncnn.ipynb

请注意,您需要手动修改模型。


如果您想使用yolox_tiny,可以在 example/assets/yolox 中找到。


别忘了将assets中的模型添加到您的 pubspec.yaml 中。

flutter:
  assets:
    - assets/yolox/

2. 加载模型

final ncnn = NcnnYolox();

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

3. 获取结果

/// 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,
);

有关具体用法,请查看 example/lib

如何设置以使用自定义ncnn和自定义YOLOX模型

1. 构建ncnn

有关详细信息,请参阅 build_ncnn.yaml

如果您想要预构建的ncnn,请查看这些文件中引用的Releases的URL。
例如,这个 https://github.com/KoheiKanagu/ncnn_yolox_flutter/releases/download/x.y.z/ncnn-android.zip

2. 下载ncnn

该库是二进制文件,因此未包含在存储库中。
iOS和Android的ncnn库是通过CMake和Cocoapods从Github Releases下载的。

您下载的ncnn库zip是 build_ncnn.yaml 的产物。如果您愿意,可以更改URL。


如果您不想下载ncnn库,请移除下载zip的过程。
然后手动安装ncnn库。

请参考这些文件中的注释。

3. 更改YOLOX的参数

如果您愿意,可以更改 ios/Classes/yolox.cpp

例如,如果您想更改输入图像的大小,请更改 YOLOX_TARGET_SIZE

或者,您可以在 void initYolox(char *modelPath, char *paramPath) 方法中更改 ncnn::Net yolox;


原始的 yolox.cppncnn/yolox.cpp at 20220216 · Tencent/ncnn

GitHub

查看 Github