FastDeploy簡介
FastDeploy是一款全場景、易用靈活、極致高效的AI推理部署工具, 支持云邊端部署。提供超過 160+Text,Vision, Speech和跨模態模型開箱即用的部署體驗,并實現端到端的推理性能優化。包括 物體檢測、字符識別(OCR)、人臉、人像扣圖、多目標跟蹤系統、NLP、Stable Difussion文圖生成、TTS 等幾十種任務場景,滿足開發者多場景、多硬件、多平臺的產業部署需求。
準備工作本文的FastDeploy適配過程需要準備如下:·凌蒙派-RK3568開發板(即需FastDeploy適配的設備終端)·Ubuntu(即建立于虛擬機的Linux編譯環境)目前,我已將FastDeploy適配到凌蒙派開發板上,可用于目標檢測、人臉檢測、人臉識別、人臉對齊、圖像分割、OCR等領域,這將大大提高凌蒙派開發板在邊緣計算方面的能力。
編譯步驟
我們推薦在PC上進行交叉編譯(即在Ubuntu進行交叉編譯)。
git clone https://github.com/PaddlePaddle/FastDeploy.gitcd FastDeploy# 如果您使用的是develop分支輸入以下命令git checkout developmkdir build && cd buildcmake .. -DCMAKE_C_COMPILER=/home/zbc/opt/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc \-DCMAKE_CXX_COMPILER=/home/zbc/opt/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++ \-DCMAKE_TOOLCHAIN_FILE=./../cmake/toolchain.cmake \-DTARGET_ABI=arm64 \-DENABLE_ORT_BACKEND=OFF \-DENABLE_RKNPU2_BACKEND=ON \-DENABLE_VISION=ON \-DRKNN2_TARGET_SOC=RK356X \-DCMAKE_INSTALL_PREFIX=${PWD}/fastdeploy-0.0.0make -j12make install
目標檢測模型速度表
為了方便大家選擇最適合自己的模型,我們選取了目前最流行的幾個模型,并整理了模型速度表供大家快速瀏覽。以下測試速度均為端到端的速度。
Demo演示
FastDeploy提供了統一的接口,可以快速的切換模型,這里以Yolov5為例子,展示如何在凌蒙派RK3568上進行目標檢測。
編寫代碼
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.//// Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at//// http://www.apache.org/licenses/LICENSE-2.0//// Unless required by applicable law or agreed to in writing, software// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.// See the License for the specific language governing permissions and// limitations under the License.#include "fastdeploy/vision.h"void RKNPU2Infer(const std::string& model_file, const std::string& image_file) {auto option = fastdeploy::RuntimeOption();option.UseRKNPU2();auto format = fastdeploy::RKNN;auto model = fastdeploy::RKYOLOV5(model_file, option,format);auto im = cv::imread(image_file);fastdeploy::DetectionResult res;fastdeploy::TimeCounter tc;tc.Start();if (!model.Predict(im, &res)) {std::cerr << "Failed to predict." << std::endl;return;}auto vis_im = fastdeploy::VisDetection(im, res,0.5);tc.End();tc.PrintInfo("RKYOLOV5 in RKNN");std::cout << res.Str() << std::endl;cv::imwrite("vis_result.jpg", vis_im);std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;}int main(int argc, char* argv[]) {if (argc < 3) {std::cout<< "Usage: infer_demo path/to/model_dir path/to/image run_option, ""e.g ./infer_model ./picodet_model_dir ./test.jpeg"<< std::endl;return -1;}RKNPU2Infer(argv[1], argv[2]);return 0;}
編譯代碼
# 編譯mkdir buildcd buildcmake .. -DFASTDEPLOY_INSTALL_DIR=${PWD}/../fastdeploy-0.0.0make -j4# 下載圖片wgethttps://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg# 運行./infer_rkyolov5 ../Model/yolov5-s-relu/yolov5s_relu_tk2_RK356X_i8.rknn./000000014439.jpg
展示結果
輸入圖片
輸出圖片
-
AI
+關注
關注
87文章
31490瀏覽量
269896 -
開發板
+關注
關注
25文章
5121瀏覽量
97976
發布評論請先 登錄
相關推薦
評論