From cf3c740fe781346b95a499e9d79e2a6489355e30 Mon Sep 17 00:00:00 2001 From: nihui Date: Fri, 21 Jul 2023 07:19:39 +0800 Subject: [PATCH] update cli.md for export ncnn model (#3846) --- docs/usage/cli.md | 3 ++- examples/tutorial.ipynb | 2 +- ultralytics/engine/exporter.py | 14 +++++++------- ultralytics/nn/autobackend.py | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/docs/usage/cli.md b/docs/usage/cli.md index dccbb77..74fde4c 100644 --- a/docs/usage/cli.md +++ b/docs/usage/cli.md @@ -179,6 +179,7 @@ i.e. `format='onnx'` or `format='engine'`. | [TF Edge TPU](https://coral.ai/docs/edgetpu/models-intro/) | `edgetpu` | `yolov8n_edgetpu.tflite` | ✅ | | [TF.js](https://www.tensorflow.org/js) | `tfjs` | `yolov8n_web_model/` | ✅ | | [PaddlePaddle](https://github.com/PaddlePaddle) | `paddle` | `yolov8n_paddle_model/` | ✅ | +| [ncnn](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n_ncnn_model/` | ✅ | --- @@ -224,4 +225,4 @@ like `imgsz=320` in this example: ```bash yolo copy-cfg yolo cfg=default_copy.yaml imgsz=320 - ``` \ No newline at end of file + ``` diff --git a/examples/tutorial.ipynb b/examples/tutorial.ipynb index aa9b2b6..33cd084 100644 --- a/examples/tutorial.ipynb +++ b/examples/tutorial.ipynb @@ -468,7 +468,7 @@ "| [TensorFlow Edge TPU](https://coral.ai/docs/edgetpu/models-intro/) | `edgetpu` | `yolov8n_edgetpu.tflite` |\n", "| [TensorFlow.js](https://www.tensorflow.org/js) | `tfjs` | `yolov8n_web_model/` |\n", "| [PaddlePaddle](https://github.com/PaddlePaddle) | `paddle` | `yolov8n_paddle_model/` |\n", - "| [NCNN](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n_ncnn_model/` |\n" + "| [ncnn](https://github.com/Tencent/ncnn) | `ncnn` | `yolov8n_ncnn_model/` |\n" ], "metadata": { "id": "nPZZeNrLCQG6" diff --git a/ultralytics/engine/exporter.py b/ultralytics/engine/exporter.py index 889e56d..7811e1b 100644 --- a/ultralytics/engine/exporter.py +++ b/ultralytics/engine/exporter.py @@ -16,7 +16,7 @@ TensorFlow Lite | `tflite` | yolov8n.tflite TensorFlow Edge TPU | `edgetpu` | yolov8n_edgetpu.tflite TensorFlow.js | `tfjs` | yolov8n_web_model/ PaddlePaddle | `paddle` | yolov8n_paddle_model/ -NCNN | `ncnn` | yolov8n_ncnn_model/ +ncnn | `ncnn` | yolov8n_ncnn_model/ Requirements: $ pip install ultralytics[export] @@ -89,7 +89,7 @@ def export_formats(): ['TensorFlow Edge TPU', 'edgetpu', '_edgetpu.tflite', True, False], ['TensorFlow.js', 'tfjs', '_web_model', True, False], ['PaddlePaddle', 'paddle', '_paddle_model', True, True], - ['NCNN', 'ncnn', '_ncnn_model', True, True], ] + ['ncnn', 'ncnn', '_ncnn_model', True, True], ] return pandas.DataFrame(x, columns=['Format', 'Argument', 'Suffix', 'CPU', 'GPU']) @@ -258,7 +258,7 @@ class Exporter: f[9], _ = self.export_tfjs() if paddle: # PaddlePaddle f[10], _ = self.export_paddle() - if ncnn: # NCNN + if ncnn: # ncnn f[11], _ = self.export_ncnn() # Finish @@ -401,14 +401,14 @@ class Exporter: return f, None @try_export - def export_ncnn(self, prefix=colorstr('NCNN:')): + def export_ncnn(self, prefix=colorstr('ncnn:')): """ - YOLOv8 NCNN export using PNNX https://github.com/pnnx/pnnx. + YOLOv8 ncnn export using PNNX https://github.com/pnnx/pnnx. """ - check_requirements('git+https://github.com/Tencent/ncnn.git' if ARM64 else 'ncnn') # requires NCNN + check_requirements('git+https://github.com/Tencent/ncnn.git' if ARM64 else 'ncnn') # requires ncnn import ncnn # noqa - LOGGER.info(f'\n{prefix} starting export with NCNN {ncnn.__version__}...') + LOGGER.info(f'\n{prefix} starting export with ncnn {ncnn.__version__}...') f = Path(str(self.file).replace(self.file.suffix, f'_ncnn_model{os.sep}')) f_ts = str(self.file.with_suffix('.torchscript')) diff --git a/ultralytics/nn/autobackend.py b/ultralytics/nn/autobackend.py index 6a8e387..4a47f03 100644 --- a/ultralytics/nn/autobackend.py +++ b/ultralytics/nn/autobackend.py @@ -264,7 +264,7 @@ class AutoBackend(nn.Module): metadata = w.parents[1] / 'metadata.yaml' elif ncnn: # ncnn LOGGER.info(f'Loading {w} for ncnn inference...') - check_requirements('git+https://github.com/Tencent/ncnn.git' if ARM64 else 'ncnn') # requires NCNN + check_requirements('git+https://github.com/Tencent/ncnn.git' if ARM64 else 'ncnn') # requires ncnn import ncnn as pyncnn net = pyncnn.Net() net.opt.num_threads = os.cpu_count()