diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000000..0506e524fa
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,178 @@
+---
+Language: Cpp
+# BasedOnStyle: LLVM
+AccessModifierOffset: -1
+AlignAfterOpenBracket: Align
+AlignArrayOfStructures: None
+AlignConsecutiveMacros: None
+AlignConsecutiveAssignments: None
+AlignConsecutiveBitFields: None
+AlignConsecutiveDeclarations: None
+AlignEscapedNewlines: Right
+AlignOperands: Align
+AlignTrailingComments: true
+AllowAllArgumentsOnNextLine: true
+AllowAllConstructorInitializersOnNextLine: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortEnumsOnASingleLine: true
+AllowShortBlocksOnASingleLine: Never
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: All
+AllowShortLambdasOnASingleLine: All
+AllowShortIfStatementsOnASingleLine: Never
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: MultiLine
+AttributeMacros:
+ - __capability
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+ AfterCaseLabel: false
+ AfterClass: false
+ AfterControlStatement: Never
+ AfterEnum: false
+ AfterFunction: false
+ AfterNamespace: false
+ AfterObjCDeclaration: false
+ AfterStruct: false
+ AfterUnion: false
+ AfterExternBlock: false
+ BeforeCatch: false
+ BeforeElse: false
+ BeforeLambdaBody: false
+ BeforeWhile: false
+ IndentBraces: false
+ SplitEmptyFunction: true
+ SplitEmptyRecord: true
+ SplitEmptyNamespace: true
+BreakBeforeBinaryOperators: None
+BreakBeforeConceptDeclarations: true
+BreakBeforeBraces: Attach
+BreakBeforeInheritanceComma: false
+BreakInheritanceList: BeforeColon
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: false
+BreakConstructorInitializers: BeforeColon
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: true
+ColumnLimit: 80
+CommentPragmas: '^ IWYU pragma:'
+CompactNamespaces: false
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DeriveLineEnding: true
+DerivePointerAlignment: false
+DisableFormat: false
+EmptyLineAfterAccessModifier: Never
+EmptyLineBeforeAccessModifier: LogicalBlock
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: true
+ForEachMacros:
+ - foreach
+ - Q_FOREACH
+ - BOOST_FOREACH
+IfMacros:
+ - KJ_IF_MAYBE
+IncludeBlocks: Preserve
+IncludeCategories:
+ - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
+ Priority: 2
+ SortPriority: 0
+ CaseSensitive: false
+ - Regex: '^(<|"(gtest|gmock|isl|json)/)'
+ Priority: 3
+ SortPriority: 0
+ CaseSensitive: false
+ - Regex: '.*'
+ Priority: 1
+ SortPriority: 0
+ CaseSensitive: false
+IncludeIsMainRegex: '(Test)?$'
+IncludeIsMainSourceRegex: ''
+IndentAccessModifiers: false
+IndentCaseLabels: false
+IndentCaseBlocks: false
+IndentGotoLabels: true
+IndentPPDirectives: None
+IndentExternBlock: AfterExternBlock
+IndentRequires: false
+IndentWidth: 2
+IndentWrappedFunctionNames: false
+InsertTrailingCommas: None
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+LambdaBodyIndentation: Signature
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBinPackProtocolList: Auto
+ObjCBlockIndentWidth: 2
+ObjCBreakBeforeNestedBlockParam: true
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakAssignment: 2
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+PenaltyIndentedWhitespace: 0
+PointerAlignment: Left
+PPIndentWidth: -1
+ReferenceAlignment: Pointer
+ReflowComments: true
+ShortNamespaceLines: 1
+SortIncludes: CaseSensitive
+SortJavaStaticImport: Before
+SortUsingDeclarations: true
+SpaceAfterCStyleCast: false
+SpaceAfterLogicalNot: false
+SpaceAfterTemplateKeyword: true
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeCaseColon: false
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
+SpaceBeforeParens: ControlStatements
+SpaceAroundPointerQualifiers: Default
+SpaceBeforeRangeBasedForLoopColon: true
+SpaceInEmptyBlock: false
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: Never
+SpacesInConditionalStatement: false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInLineCommentPrefix:
+ Minimum: 1
+ Maximum: -1
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+SpaceBeforeSquareBrackets: false
+BitFieldColonSpacing: Both
+Standard: Latest
+StatementAttributeLikeMacros:
+ - Q_EMIT
+StatementMacros:
+ - Q_UNUSED
+ - QT_REQUIRE_VERSION
+TabWidth: 8
+UseCRLF: false
+UseTab: Never
+WhitespaceSensitiveMacros:
+ - STRINGIZE
+ - PP_STRINGIZE
+ - BOOST_PP_STRINGIZE
+ - NS_SWIFT_NAME
+ - CF_SWIFT_NAME
+...
+
diff --git a/.clang_format.hook b/.clang_format.hook
new file mode 100644
index 0000000000..df453cbc74
--- /dev/null
+++ b/.clang_format.hook
@@ -0,0 +1,15 @@
+#!/bin/bash
+set -e
+
+readonly VERSION="3.8"
+
+version=$(clang-format -version)
+
+if ! [[ version==∗"VERSION"* ]]; then
+ echo "clang-format version check failed."
+ echo "a version contains 'VERSION′isneeded,butget′version'"
+ echo "you can install the right version, and make an soft-link to '$PATH' env"
+ exit -1
+fi
+
+clang-format -style=google $@
diff --git a/.cpplint_pre_commit.hook b/.cpplint_pre_commit.hook
new file mode 100644
index 0000000000..447b1ba134
--- /dev/null
+++ b/.cpplint_pre_commit.hook
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+#TOTAL_ERRORS=0
+#echo "HAHAHAHAHHA"
+#exit 5
+#
+#files=$(
+#
+#if [[ ! $TRAVIS_BRANCH ]]; then
+# # install cpplint on local machine.
+# if [[ ! $(which cpplint) ]]; then
+# pip install cpplint
+# fi
+# # diff files on local machine.
+# files=$(git diff --cached --name-status | awk 'Extra open brace or missing close brace2}')
+#else
+# # diff files between PR and latest commit on Travis CI.
+# branch_ref=(gitrev−parse"TRAVIS_BRANCH")
+# head_ref=$(git rev-parse HEAD)
+# files=(gitdiff−−name−statusbranch_ref $head_ref | awk 'Extra open brace or missing close brace2}')
+#fi
+## The trick to remove deleted files: https://stackoverflow.com/a/2413151
+#for file in $files; do
+# echo $file
+# if [[ $file =~ ^(patches/.*) ]]; then
+# continue;
+# else
+# cpplint --filter=-readability/fn_size $file;
+# TOTAL_ERRORS=(exprTOTAL_ERRORS + $?);
+# fi
+#done
+#
+#exit $TOTAL_ERRORS
+
+if git rev-parse --verify HEAD >/dev/null 2>&1
+then
+ against=HEAD
+else
+ # Initial commit: diff against an empty tree object
+ against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
+fi
+
+# Redirect output to stderr.
+exec 1>&2
+
+cpplint=cpplint
+sum=0
+filters='-build/include_order,-build/namespaces,-legal/copyright,-runtime/references,-build/include_what_you_use'
+
+# for cpp
+for file in $(git diff-index --name-status $against -- | grep -E '\.[ch](pp)?$' | awk '{print $2}'); do
+ $cpplint --filter=$filters $file
+ sum=$(expr ${sum} + $?)
+done
+
+if [ ${sum} -eq 0 ]; then
+ exit 0
+else
+ exit 1
+fi
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000..b2602607a9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+fastdeploy/libs/lib*
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000000..7a9bfa8ec9
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,43 @@
+repos:
+- repo: https://github.com/PaddlePaddle/mirrors-yapf.git
+ rev: 0d79c0c469bab64f7229c9aca2b1186ef47f0e37
+ hooks:
+ - id: yapf
+ files: \.py$
+- repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: a11d9314b22d8f8c7556443875b731ef05965464
+ hooks:
+ - id: check-merge-conflict
+ - id: check-symlinks
+ - id: end-of-file-fixer
+ - id: trailing-whitespace
+ - id: detect-private-key
+ - id: check-symlinks
+ - id: check-added-large-files
+- repo: local
+
+ hooks:
+ - id: copyright_checker
+ name: copyright_checker
+ entry: python ./.copyright.hook
+ language: system
+ files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto|py)$
+ exclude: (?!.*third_party)^.*$
+
+- repo: local
+ hooks:
+ - id: clang-format-with-version-check
+ name: clang-format
+ description: Format files with ClangFormat.
+ entry: bash .clang_format.hook -i
+ language: system
+ files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto)$
+
+- repo: local
+ hooks:
+ - id: cpplint-cpp-source
+ name: cpplint
+ description: Check C++ code style using cpplint.py.
+ entry: bash .cpplint_pre_commit.hook
+ language: system
+ files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx)$
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000000..7bf3a0f545
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,261 @@
+# 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.
+
+PROJECT(fastdeploy C CXX)
+CMAKE_MINIMUM_REQUIRED (VERSION 3.16)
+
+include(ExternalProject)
+add_subdirectory(fastdeploy)
+include(external/utils.cmake)
+
+# Set C++11 as standard for the whole project
+if(NOT MSVC)
+ set(CMAKE_CXX_STANDARD 11)
+endif(NOT MSVC)
+
+#############################CMAKE FOR FASTDEPLOY################################
+option(ENABLE_PADDLE_FRONTEND "if to enable PaddlePaddle frontend to support load paddle model in fastdeploy." ON)
+option(WITH_GPU "if WITH_GPU=ON, will enable onnxruntime-gpu/paddle-infernce-gpu" OFF)
+option(ENABLE_ORT_BACKEND "if to enable onnxruntime backend." OFF)
+option(ENABLE_TRT_BACKEND "if to enable tensorrt backend." OFF)
+option(CUDA_DIRECTORY "if build tensorrt backend, need to define path of cuda library.")
+option(TRT_DIRECTORY "if build tensorrt backend, need to define path of tensorrt library.")
+option(ENABLE_VISION "if to enable vision models usage." OFF)
+option(ENABLE_VISION_VISUALIZE "if to enable visualize vision model result toolbox." ON)
+
+# Please don't open this flag now, some bugs exists.
+option(ENABLE_OPENCV_CUDA "if to enable opencv with cuda, this will allow process image with GPU." OFF)
+option(ENABLE_DEBUG "if to enable print debug information, this may reduce performance." OFF)
+
+if(ENABLE_DEBUG)
+ add_definitions(-DFASTDEPLOY_DEBUG)
+endif()
+if(NOT CUDA_DIRECTORY)
+ set(CUDA_DIRECTORY "/usr/local/cuda")
+endif()
+
+option(BUILD_FASTDEPLOY_PYTHON "if build python lib for fastdeploy." OFF)
+
+include_directories(${PROJECT_SOURCE_DIR})
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
+add_definitions(-DFASTDEPLOY_LIB)
+file(GLOB_RECURSE ALL_DEPLOY_SRCS ${PROJECT_SOURCE_DIR}/fastdeploy/*.cc)
+file(GLOB_RECURSE DEPLOY_ORT_SRCS ${PROJECT_SOURCE_DIR}/fastdeploy/backends/ort/*.cc)
+file(GLOB_RECURSE DEPLOY_TRT_SRCS ${PROJECT_SOURCE_DIR}/fastdeploy/backends/tensorrt/*.cc ${PROJECT_SOURCE_DIR}/fastdeploy/backends/tensorrt/*.cpp)
+file(GLOB_RECURSE DEPLOY_VISION_SRCS ${PROJECT_SOURCE_DIR}/fastdeploy/vision/*.cc)
+file(GLOB_RECURSE DEPLOY_PYBIND_SRCS ${PROJECT_SOURCE_DIR}/fastdeploy/pybind/*.cc ${PROJECT_SOURCE_DIR}/fastdeploy/*_pybind.cc)
+list(REMOVE_ITEM ALL_DEPLOY_SRCS ${DEPLOY_ORT_SRCS} ${DEPLOY_TRT_SRCS} ${DEPLOY_VISION_SRCS})
+
+set(DEPEND_LIBS "")
+
+file(READ "${PROJECT_SOURCE_DIR}/VERSION_NUMBER" FASTDEPLOY_VERSION)
+string(STRIP "${FASTDEPLOY_VERSION}" FASTDEPLOY_VERSION)
+
+set(THIRD_PARTY_PATH ${CMAKE_CURRENT_BINARY_DIR}/third_libs)
+if(ENABLE_PADDLE_FRONTEND)
+ add_definitions(-DENABLE_PADDLE_FRONTEND)
+ include(${PROJECT_SOURCE_DIR}/external/paddle2onnx.cmake)
+ list(APPEND DEPEND_LIBS external_paddle2onnx)
+endif(ENABLE_PADDLE_FRONTEND)
+
+if(ENABLE_ORT_BACKEND)
+ add_definitions(-DENABLE_ORT_BACKEND)
+ list(APPEND ALL_DEPLOY_SRCS ${DEPLOY_ORT_SRCS})
+ include(external/onnxruntime.cmake)
+ list(APPEND DEPEND_LIBS external_onnxruntime)
+endif()
+
+if(WITH_GPU)
+ if(APPLE)
+ message(FATAL_ERROR "Cannot enable GPU while compling in Mac OSX.")
+ set(WITH_GPU OFF)
+ else()
+ add_definitions(-DWITH_GPU)
+ include_directories(${CUDA_DIRECTORY}/include)
+ find_library(CUDA_LIB cudart ${CUDA_DIRECTORY}/lib64)
+ list(APPEND DEPEND_LIBS ${CUDA_LIB})
+ endif()
+endif()
+
+if(ENABLE_TRT_BACKEND)
+ if(APPLE)
+ message(FATAL_ERROR "Cannot enable tensorrt backend in mac os, please set -DENABLE_TRT_BACKEND=OFF.")
+ endif()
+ if(NOT WITH_GPU)
+ message(FATAL_ERROR "While -DENABLE_TRT_BACKEND=ON, must set -DWITH_GPU=ON, but now it's OFF")
+ endif()
+ add_definitions(-DENABLE_TRT_BACKEND)
+ include_directories(${TRT_DIRECTORY}/include)
+ include_directories(${PROJECT_SOURCE_DIR}/fastdeploy/backends/tensorrt/common)
+ list(APPEND ALL_DEPLOY_SRCS ${DEPLOY_TRT_SRCS})
+ find_library(TRT_INFER_LIB nvinfer ${TRT_DIRECTORY}/lib)
+ find_library(TRT_ONNX_LIB nvonnxparser ${TRT_DIRECTORY}/lib)
+ find_library(TRT_CAFFE_LIB nvcaffe_parser ${TRT_DIRECTORY}/lib)
+ find_library(TRT_PLUGIN_LIB nvinfer_plugin ${TRT_DIRECTORY}/lib)
+ list(APPEND DEPEND_LIBS ${TRT_INFER_LIB} ${TRT_ONNX_LIB} ${TRT_CAFFE_LIB} ${TRT_PLUGIN_LIB})
+
+ # copy tensorrt libraries to third lib
+ if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/third_libs/install/tensorrt")
+ file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/third_libs/install/tensorrt/lib")
+ endif()
+ file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/third_libs/install/tensorrt/lib")
+ file(COPY ${TRT_INFER_LIB} ${TRT_ONNX_LIB} ${TRT_CAFFE_LIB} ${TRT_PLUGIN_LIB} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/third_libs/install/tensorrt/lib" FOLLOW_SYMLINK_CHAIN)
+endif()
+
+if(ENABLE_VISION)
+ add_definitions(-DENABLE_VISION)
+ if(ENABLE_OPENCV_CUDA)
+ add_definitions(-DENABLE_OPENCV_CUDA)
+ if(APPLE)
+ message(FATAL_ERROR "Cannot enable opencv with cuda in mac os, please set -DENABLE_OPENCV_CUDA=OFF.")
+ endif()
+ endif()
+ add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/yaml-cpp)
+ list(APPEND DEPEND_LIBS yaml-cpp)
+ list(APPEND ALL_DEPLOY_SRCS ${DEPLOY_VISION_SRCS})
+ include_directories(${PROJECT_SOURCE_DIR}/third_party/yaml-cpp/include)
+ include(external/opencv.cmake)
+
+ if(ENABLE_VISION_VISUALIZE)
+ add_definitions(-DENABLE_VISION_VISUALIZE)
+ endif()
+endif()
+
+configure_file(${PROJECT_SOURCE_DIR}/fastdeploy/core/config.h.in ${PROJECT_SOURCE_DIR}/fastdeploy/core/config.h)
+configure_file(${PROJECT_SOURCE_DIR}/FastDeploy.cmake.in ${PROJECT_SOURCE_DIR}/FastDeploy.cmake @ONLY)
+
+list(REMOVE_ITEM ALL_DEPLOY_SRCS ${DEPLOY_PYBIND_SRCS})
+
+add_library(fastdeploy SHARED ${ALL_DEPLOY_SRCS})
+redefine_file_macro(fastdeploy)
+set_target_properties(fastdeploy PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
+if(NOT APPLE)
+ set_target_properties(fastdeploy PROPERTIES LINK_FLAGS "-Wl,--start-group,--exclude-libs,ALL")
+endif()
+set_target_properties(fastdeploy PROPERTIES LINK_FLAGS_RELEASE -s)
+
+file(READ "${PROJECT_SOURCE_DIR}/VERSION_NUMBER" FASTDEPLOY_VERSION)
+string(STRIP "${FASTDEPLOY_VERSION}" FASTDEPLOY_VERSION)
+if (APPLE)
+# set_target_properties(fastdeploy PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
+ set_target_properties(fastdeploy PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
+elseif(MSVC)
+else()
+ set_target_properties(fastdeploy PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
+ set_target_properties(fastdeploy PROPERTIES LINK_FLAGS "-Wl,--exclude-libs,ALL")
+ set_target_properties(fastdeploy PROPERTIES LINK_FLAGS_RELEASE -s)
+endif()
+
+find_package(OpenMP)
+if(OpenMP_CXX_FOUND)
+ list(APPEND DEPEND_LIBS OpenMP::OpenMP_CXX)
+endif()
+set_target_properties(fastdeploy PROPERTIES VERSION ${FASTDEPLOY_VERSION})
+target_link_libraries(fastdeploy ${DEPEND_LIBS})
+
+include(external/summary.cmake)
+fastdeploy_summary()
+
+install(
+ TARGETS fastdeploy
+ LIBRARY DESTINATION lib
+)
+install(
+ DIRECTORY ${PROJECT_SOURCE_DIR}/fastdeploy
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+ FILES_MATCHING
+ PATTERN "*.h"
+ PATTERN "${PROJECT_SOURCE_DIR}/fastdeploy/backends/*/*.h"
+)
+install(
+ DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/third_libs/install
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/third_libs
+)
+install(
+ FILES
+ ${PROJECT_SOURCE_DIR}/LICENSE
+ ${PROJECT_SOURCE_DIR}/ThirdPartyNotices.txt
+ ${PROJECT_SOURCE_DIR}/VERSION_NUMBER
+ ${PROJECT_SOURCE_DIR}/FastDeploy.cmake
+ DESTINATION ${CMAKE_INSTALL_PREFIX}
+)
+
+# Build demo cpp
+if(ENABLE_VISION)
+ add_executable(yolov5_exe ${PROJECT_SOURCE_DIR}/demo/cpp/vision/yolov5.cc)
+ target_link_libraries(yolov5_exe PUBLIC fastdeploy)
+endif()
+
+if(BUILD_FASTDEPLOY_PYTHON)
+ add_definitions(-DBUILD_FASTDEPLOY_PYTHON)
+ if("${PY_EXT_SUFFIX}" STREQUAL "")
+ if(MSVC)
+ set(PY_EXT_SUFFIX ".pyd")
+ else()
+ set(PY_EXT_SUFFIX ".so")
+ endif()
+ endif()
+
+ # find_package Python has replaced PythonInterp and PythonLibs since cmake 3.12
+ # Use the following command in the future; now this is only compatible with the latest pybind11
+ # find_package(Python ${PY_VERSION} COMPONENTS Interpreter Development REQUIRED)
+ find_package(PythonInterp ${PY_VERSION} REQUIRED)
+ find_package(PythonLibs ${PY_VERSION})
+ if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
+ set(CMAKE_NO_SYSTEM_FROM_IMPORTED 1)
+ endif()
+
+ add_library(fastdeploy_main MODULE ${DEPLOY_PYBIND_SRCS})
+ redefine_file_macro(fastdeploy_main)
+ set_target_properties(fastdeploy_main PROPERTIES PREFIX "")
+ set_target_properties(fastdeploy_main
+ PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
+ set_target_properties(fastdeploy_main PROPERTIES SUFFIX ${PY_EXT_SUFFIX})
+ set_target_properties(fastdeploy_main
+ PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
+ target_include_directories(fastdeploy_main PRIVATE
+ $
+ $
+ ${PYTHON_INCLUDE_DIR})
+
+ target_include_directories(fastdeploy_main PUBLIC ${PROJECT_SOURCE_DIR}/third_party/pybind11/include)
+
+ if(APPLE)
+ set_target_properties(fastdeploy_main
+ PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
+ endif()
+
+ if(APPLE)
+ target_link_libraries(fastdeploy_main PUBLIC fastdeploy)
+ elseif(WIN32)
+ target_link_libraries(fastdeploy_main PUBLIC fastdeploy)
+ else()
+ target_link_libraries(fastdeploy_main PUBLIC fastdeploy)
+ endif()
+
+ if(MSVC)
+ target_link_libraries(fastdeploy_main PRIVATE ${PYTHON_LIBRARIES})
+ target_compile_options(fastdeploy_main
+ PRIVATE /MP
+ /wd4244 # 'argument': conversion from 'google::
+ # protobuf::uint64' to 'int', possible
+ # loss of data
+ /wd4267 # Conversion from 'size_t' to 'int',
+ # possible loss of data
+ /wd4996 # The second parameter is ignored.
+ ${EXTRA_FLAGS})
+ target_compile_options(fastdeploy_main PRIVATE $<$>:/MT> $<$:/MTd>)
+ endif()
+endif(BUILD_FASTDEPLOY_PYTHON)
diff --git a/FastDeploy.cmake.in b/FastDeploy.cmake.in
new file mode 100644
index 0000000000..ef90cefc7e
--- /dev/null
+++ b/FastDeploy.cmake.in
@@ -0,0 +1,59 @@
+CMAKE_MINIMUM_REQUIRED (VERSION 3.16)
+
+set(WITH_GPU @WITH_GPU@)
+set(ENABLE_ORT_BACKEND @ENABLE_ORT_BACKEND@)
+set(ENABLE_TRT_BACKEND @ENABLE_TRT_BACKEND&)
+set(ENABLE_PADDLE_FRONTEND @ENABLE_PADDLE_FRONTEND@)
+set(ENABLE_VISION @ENABLE_VISION@)
+set(ENABLE_OPENCV_CUDA @ENABLE_OPENCV_CUDA@)
+
+set(FASTDEPLOY_LIBS "")
+set(FASTDEPLOY_INCS "")
+list(APPEND FASTDEPLOY_INCS ${CMAKE_CURRENT_LIST_DIR}/include)
+
+find_library(FDLIB fastdeploy ${CMAKE_CURRENT_LIST_DIR}/lib)
+list(APPEND FASTDEPLOY_LIBS ${FDLIB})
+if(ENABLE_ORT_BACKEND)
+ find_library(ORT_LIB onnxruntime ${CMAKE_CURRENT_LIST_DIR}/third_libs/install/onnxruntime/lib)
+ list(APPEND FASTDEPLOY_LIBS ${ORT_LIB})
+endif()
+
+if(WITH_GPU)
+ if (NOT CUDA_DIRECTORY)
+ message(FATAL_ERROR "[FastDeploy] Please define CUDA_DIRECTORY, e.g -DCUDA_DIRECTORY=/usr/local/cuda")
+ endif()
+ find_library(CUDA_LIB cudart ${CUDA_DIRECTORY}/lib64)
+ list(APPEND FASTDEPLOY_LIBS ${CUDA_LIB})
+
+ if (ENABLE_TRT_BACKEND)
+ if (NOT TRT_DIRECTORY)
+ message(FATAL_ERROR "[FastDeploy] Please define TRT_DIRECTORY, e.g -DTRT_DIRECTORY=/usr/downloads/TensorRT-8.4.1.0")
+ endif()
+ find_library(TRT_INFER_LIB nvinfer ${TRT_DIRECTORY}/lib)
+ find_library(TRT_ONNX_LIB nvonnxparser ${TRT_DIRECTORY}/lib)
+ find_library(TRT_CAFFE_LIB nvcaffe_parser ${TRT_DIRECTORY}/lib)
+ find_library(TRT_PLUGIN_LIB nvinfer_plugin ${TRT_DIRECTORY}/lib)
+ list(APPEND FASTDEPLOY_LIBS ${TRT_INFER_LIB} ${TRT_ONNX_LIB} ${TRT_CAFFE_LIB} ${TRT_PLUGIN_LIB})
+ endif()
+endif()
+
+if(ENABLE_VISION)
+ find_library(OPENCV_CORE_LIB opencv_core ${CMAKE_CURRENT_LIST_DIR}/third_libs/install/opencv/lib)
+ find_library(OPENCV_HIGHGUI_LIB opencv_highgui ${CMAKE_CURRENT_LIST_DIR}/third_libs/install/opencv/lib)
+ find_library(OPENCV_IMGPROC_LIB opencv_imgproc ${CMAKE_CURRENT_LIST_DIR}/third_libs/install/opencv/lib)
+ find_library(OPENCV_IMGCODESC_LIB opencv_imgcodecs ${CMAKE_CURRENT_LIST_DIR}/third_libs/install/opencv/lib)
+ list(APPEND FASTDEPLOY_LIBS ${OPENCV_CORE_LIB} ${OPENCV_HIGHGUI_LIB} ${OPENCV_IMGPROC_LIB} ${OPENCV_IMGCODESC_LIB})
+ list(APPEND FASTDEPLOY_INCS ${CMAKE_CURRENT_LIST_DIR}/third_libs/install/opencv/include)
+
+ if(ENABLE_OPENCV_CUDA)
+ find_library(OPENCV_CUDAARITHM_LIB opencv_core ${CMAKE_CURRENT_LIST_DIR}/third_libs/install/opencv/lib)
+ find_library(OPENCV_CUDAIMGPROC_LIB opencv_core ${CMAKE_CURRENT_LIST_DIR}/third_libs/install/opencv/lib)
+ find_library(OPENCV_CUDAWARPING_LIB opencv_core ${CMAKE_CURRENT_LIST_DIR}/third_libs/install/opencv/lib)
+ list(APPEND FASTDEPLOY_LIBS ${OPENCV_CUDAARITHM_LIB} ${OPENCV_CUDAIMGPROC_LIB} ${OPENCV_CUDAWARPING_LIB})
+ endif()
+endif()
+
+if(ENABLE_PADDLE_FRONTEND)
+ find_library(PADDLE2ONNX_LIB paddle2onnx ${CMAKE_CURRENT_LIST_DIR}/third_libs/install/paddle2onnx/lib)
+ list(APPEND FASTDEPLOY_LIBS ${PADDLE2ONNX_LIB})
+endif()
diff --git a/README.md b/README.md
index 20a1f520a3..638f5cdcc8 100644
--- a/README.md
+++ b/README.md
@@ -1,202 +1,28 @@
-# ⚡️FastDeploy
+# FastDeploy
-
+模型推理就用FastDeploy!
-------------------------------------------------------------------------------------------
+## 环境要求
+- python >= 3.6
+- cmake >= 3.18
+- gcc >= 8.2
+- cuda >= 11.0(如若需要启用GPU)
+- tensorrt >= 8.4(如若需要启用TensorRT后端)
-
-
-
-
-
-
-
-
-
-
-
+## 如何利用FastDeploy快速完成模型部署
+- [C++部署指南](docs/cpp/README.md)
+- [Python部署指南](docs/python/README.md)
-
+## 如何自行编译FastDeploy
-**⚡️FastDeploy**是一款**简单易用**的推理部署工具箱。覆盖业界主流**优质预训练模型**并提供**开箱即用**的开发体验,包括图像分类、目标检测、图像分割、人脸检测、人体关键点识别、文字识别等多任务,满足开发者**多场景**,**多硬件**、**多平台**的快速部署需求。
+- [FastDeploy编译指南](docs/compile/README.md)
-## News 📢
-
-* 🔥 2022.6.30 晚20:30,⚡️FastDeploy天使用户邀测沟通会,与开发者共同讨论推理部署痛点问题,欢迎大家扫码报名入群获取会议链接。
-
-

-
-
-* 🔥 2022.6.27 [**⚡️FastDeploy v0.1.0**](https://github.com/PaddlePaddle/FastDeploy/releases/tag/release%2F0.1.0)测试版发布!🎉
- * 💎 发布40个重点模型在8种重点软硬件环境的支持的SDK
- * 😊 支持网页端、pip包两种下载使用方式
-
-
-## 特性
-
-
-### 📦**开箱即用的推理部署工具链,支持云边端、多硬件、多平台部署**
-- 网页端点选下载、PIP 安装一行命令,快速下载多种类型SDK安装包
-- 云端(含服务器、数据中心):
- - 支持一行命令启动 Serving 服务(含网页图形化展示)
- - 支持一行命令启动图像、本地视频流、本地摄像头、网络视频流预测
- - 支持 Window、Linux 操作系统
- - 支持 Python、C++ 编程语言
-- 边缘端:
- - 支持 NVIDIA Jetson 等边缘设备,支持视频流预测服务
-- 端侧(含移动端)
- - 支持 iOS、Android 移动端
- - 支持 ARM CPU 端侧设备
-- 支持主流硬件
- - 支持 Intel CPU 系列(含酷睿、至强等)
- - 支持 ARM CPU 全系(含高通、MTK、RK等)
- - 支持 NVIDIA GPU 全系(含 V100、T4、Jetson 等)
-
-### 🤗**丰富的预训练模型,轻松下载SDK搞定推理部署**
-
-
-
-
-| 模型| 任务 | 大小(MB) | 端侧 | 移动端 | 移动端 |边缘端 |服务器+云端 | 服务器+云端 | 服务器+云端 | 服务器+云端 |
-|---|---|---|---|---|---|---|---|---|---|---|
-|----- | ---- |----- | Linux | Android | iOS | Linux | Linux | Linux | Windows | Windows |
-|----- | ---- |--- | ARM CPU | ARM CPU | ARM CPU | Jetson | X86 CPU | GPU | X86 CPU | GPU |
-| [PP-LCNet](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.3/docs/zh_CN/models_training/classification.md) |Classfication | 11.9 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [PP-LCNetv2](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.3/docs/zh_CN/models_training/classification.md) |Classfication | 26.6 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [EfficientNet](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.3/docs/zh_CN/models_training/classification.md) |Classfication |31.4 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [GhostNet](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.3/docs/zh_CN/models_training/classification.md) |Classfication | 20.8 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [MobileNetV1](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.3/docs/zh_CN/models_training/classification.md) |Classfication | 17 |✅|✅|✅|✅|✅|✅|✅|✅|✅|
-| [MobileNetV2](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.3/docs/zh_CN/models_training/classification.md) |Classfication | 14.2 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [MobileNetV3](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.3/docs/zh_CN/models_training/classification.md) |Classfication | 22 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [ShuffleNetV2](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.3/docs/zh_CN/models_training/classification.md)|Classfication | 9.2 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [SqueezeNetV1.1](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.3/docs/zh_CN/models_training/classification.md) |Classfication |5 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [Inceptionv3](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.3/docs/zh_CN/models_training/classification.md) |Classfication |95.5 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [PP-HGNet](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.3/docs/zh_CN/models_training/classification.md) |Classfication | 59 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [ResNet50_vd](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.3/docs/zh_CN/models_training/classification.md) |Classfication | 102.5 |❌|❌|❌|✅|✅|✅|✅|✅|
-| [SwinTransformer_224_win7](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.3/docs/zh_CN/models_training/classification.md) |Classfication | 352.7 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [PP-PicoDet_s_320_coco](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/GETTING_STARTED_cn.md) |Detection | 4.1 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [PP-PicoDet_s_320_lcnet](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/GETTING_STARTED_cn.md) |Detection | 4.9 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [CenterNet](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/GETTING_STARTED_cn.md) |Detection |4.8 |✅|✅|✅|✅ |✅ |✅|✅|✅|
-| [YOLOv3_MobileNetV3](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/GETTING_STARTED_cn.md) |Detection | 94.6 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [PP-YOLO_tiny_650e_coco](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/GETTING_STARTED_cn.md) |Detection |4.4 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [SSD_MobileNetV1_300_120e_voc](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/GETTING_STARTED_cn.md) |Detection | 23.3 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [YOLOX_Nano_300e_coco](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/GETTING_STARTED_cn.md) |Detection | 3.7 |❌|❌|❌|✅|✅ |✅|✅|✅|
-| [PP-YOLO_ResNet50vd](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/GETTING_STARTED_cn.md) |Detection | 188.5|✅ |✅ |✅ |✅ |✅ |✅|✅|✅|
-| [PP-YOLOv2_ResNet50vd](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/GETTING_STARTED_cn.md) |Detection | 218.7 |✅|✅|✅|✅|✅ |✅|✅|✅|
-| [PP-YOLO_crn_l_300e_coco](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/GETTING_STARTED_cn.md) |Detection | 209.1 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [YOLOv5s](https://github.com/ultralytics/yolov5) |Detection | 29.3|✅|✅|✅|✅|✅|✅|✅|✅|
-| [Faster R-CNN_r50_fpn_1x_coco](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/GETTING_STARTED_cn.md) |Detection | 167.2 |❌|❌|❌|✅|✅|✅|✅|✅|
-| [BlazeFace](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/GETTING_STARTED_cn.md) |Face Detection |1.5|✅|✅|✅|✅|✅|✅|✅|✅|
-| [RetinaFace](https://github.com/biubug6/Pytorch_Retinaface) |Face Localisation |1.7| ✅|❌|❌|✅|✅|✅|✅|✅|
-| [PP-TinyPose](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/GETTING_STARTED_cn.md) |Keypoint Detection| 5.5 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [PP-LiteSeg(STDC1)](https://github.com/PaddlePaddle/PaddleSeg/blob/develop/configs/pp_liteseg/README.md)|Segmentation | 32.2|✅|✅|✅|✅|✅|✅|✅|✅|
-| [PP-HumanSeg-Lite](https://github.com/PaddlePaddle/PaddleSeg/blob/develop/contrib/PP-HumanSeg/README_cn.md) |Segmentation | 0.556|✅|✅|✅|✅|✅|✅|✅|✅|
-| [HRNet-w18](https://github.com/PaddlePaddle/PaddleSeg/blob/develop/docs/train/train_cn.md) |Segmentation | 38.7|✅|✅|✅|❌|✅|✅|✅|✅|
-| [Mask R-CNN_r50_fpn_1x_coco](https://github.com/PaddlePaddle/PaddleSeg/blob/develop/contrib/PP-HumanSeg/README_cn.md)|Segmentation| 107.2|❌|❌|❌|✅|✅|✅|✅|✅|
-| [PP-HumanSeg-Server](https://github.com/PaddlePaddle/PaddleSeg/blob/develop/contrib/PP-HumanSeg/README_cn.md)|Segmentation | 107.2|✅|✅|✅|✅|✅|✅|✅|✅|
-| [Unet](https://github.com/PaddlePaddle/PaddleSeg/blob/develop/docs/train/train_cn.md) |Segmentation | 53.7|❌|✅|❌|❌|✅|✅|✅|❌|
-| [Deeplabv3-ResNet50](https://github.com/PaddlePaddle/PaddleSeg/blob/develop/docs/train/train_cn.md)|Segmentation |156.5|❌|❌|❌|❌|✅|✅|✅|✅|
-| [PP-OCRv1](https://github.com/PaddlePaddle/PaddleOCR/blob/release%2F2.5/doc/doc_ch/ppocr_introduction.md) |OCR | 2.3+4.4 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [PP-OCRv2](https://github.com/PaddlePaddle/PaddleOCR/blob/release%2F2.5/doc/doc_ch/ppocr_introduction.md) |OCR | 2.3+4.4 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [PP-OCRv3](https://github.com/PaddlePaddle/PaddleOCR/blob/release%2F2.5/doc/doc_ch/PP-OCRv3_introduction.md) |OCR | 2.4+10.6 |✅|✅|✅|✅|✅|✅|✅|✅|
-| [PP-OCRv3-tiny](https://github.com/PaddlePaddle/PaddleOCR/blob/release%2F2.5/doc/doc_ch/models_list.md) |OCR |2.4+10.7 |✅|✅|✅|✅|✅|✅|✅|✅|
-
-
-
-## SDK安装
-
-### 方式1:网页版下载安装
-
-- 可以登录[EasyEdge网页端](https://ai.baidu.com/easyedge/app/openSource)下载SDK
-
-### 方式2:pip安装
-
-开发者可以通过pip安装`fastdeploy-python`来获取最新的下载链接
-
-- 环境依赖
-
- python >= 3.6
-
-- 安装方式
+## 代码提交
+提交代码前,先初始化代码环境,在clone代码后,执行
```
-pip install fastdeploy-python --upgrade
+sh commit-prepare.sh
```
-- 使用方式
-
- - 列出FastDeploy当前支持的所有模型
- ```
- fastdeploy --list_models
- ```
- - 下载模型在具体平台和对应硬件上的部署SDK以及示例
- ```
- fastdeploy --download_sdk \
- --model PP-PicoDet-s_320 \
- --platform Linux \
- --soc x86 \
- --save_dir .
- ```
-
- - 参数说明
- - `list_models`: 列出FastDeploy当前最新支持的所有模型
- - `download_sdk`: 下载模型在具体平台和对应硬件上的部署SDK以及示例
- - `model`: 模型名,如"PP-PicoDet-s_320",可通过`list_models`查看所有的可选项
- - `platform`: 部署平台,支持 Windows/Linux/Android/iOS
- - `soc`: 部署硬件,支持 x86/x86-NVIDIA-GPU/ARM/Jetson
- - `save_dir`: SDK下载保存目录
-
-## SDK使用
-### 1 云+服务器部署
- - Linux 系统(X86 CPU、NVIDIA GPU)
- - [C++ Inference部署(含视频流)](./docs/Linux-CPP-SDK-Inference.md)
- - [C++ 服务化部署](./docs/Linux-CPP-SDK-Serving.md)
- - [Python Inference部署](./docs/Linux-Python-SDK-Inference.md)
- - [Python 服务化部署](./docs/Linux-Python-SDK-Serving.md)
- - Window系统(X86 CPU、NVIDIA GPU)
- - [C++ Inference部署(含视频流)](./docs/Windows-CPP-SDK-Inference.md)
- - [C++ 服务化部署](./docs/Windows-CPP-SDK-Serving.md)
- - [Python Inference部署](./docs/Windows-Python-SDK-Inference.md)
- - [Python 服务化部署](./docs/Windows-Python-SDK-Serving.md)
-
-### 2 边缘侧部署
- - ArmLinux 系统(NVIDIA Jetson Nano/TX2/Xavier)
- - [C++ Inference部署(含视频流)](./docs/Jetson-Linux-CPP-SDK-Inference.md)
- - [C++ 服务化部署](./docs/Jetson-Linux-CPP-SDK-Serving.md)
-
-### 3 端侧部署
- - ArmLinux 系统(ARM CPU)
- - [C++ Inference部署(含视频流)](./docs/ARM-Linux-CPP-SDK-Inference.md)
- - [C++ 服务化部署](./docs/ARM-Linux-CPP-SDK-Serving.md)
- - [Python Inference部署](./docs/ARM-Linux-Python-SDK-Inference.md)
- - [Python 服务化部署](./docs/ARM-Linux-Python-SDK-Serving.md)
-
-### 4 移动端部署
- - [iOS 系统部署](./docs/iOS-SDK.md)
- - [Android 系统部署](./docs/Android-SDK.md)
-
-### 5 自定义模型部署
- - [快速实现个性化模型替换](./docs/Replace-Model-With-Anther-One.md)
-
-## 社区交流
- - **加入社区👬:** 微信扫描二维码后,填写问卷加入交流群,与开发者共同讨论推理部署痛点问题
-
-
-

-
-
-
-
-## Acknowledge
-
-本项目中SDK生成和下载使用了[EasyEdge](https://ai.baidu.com/easyedge/app/openSource)中的免费开放能力,再次表示感谢。
-
-## License
-
-FastDeploy遵循[Apache-2.0开源协议](./LICENSE)。
+在之后commit代码时,会自动进行代码格式的检查。
diff --git a/ThirdPartyNotices.txt b/ThirdPartyNotices.txt
new file mode 100644
index 0000000000..5842b9a717
--- /dev/null
+++ b/ThirdPartyNotices.txt
@@ -0,0 +1,734 @@
+This project depends on some open source projects, list as below
+
+--------
+1. https://github.com/protocolbuffers/protobuf
+
+Copyright 2008 Google Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Code generated by the Protocol Buffer compiler is owned by the owner
+of the input file used when generating it. This code is not
+standalone and requires a support library to be linked with it. This
+support library is itself covered by the above license.
+
+--------
+2. https://github.com/onnx/onnx
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
+--------
+3. https://github.com/microsoft/onnxruntime
+
+MIT License
+
+Copyright (c) Microsoft Corporation
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+--------
+4. https://github.com/pybind/pybind11
+
+Copyright (c) 2016 Wenzel Jakob , All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Please also refer to the file .github/CONTRIBUTING.md, which clarifies licensing of
+external contributions to this project including patches, pull requests, etc.
+
+--------
+4. https://github.com/onnx/onnx-tensorrt
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2021 NVIDIA Corporation
+
+ 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.
+
+--------
+5. https://github.com/opencv/opencv
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
+--------
+6. https://github.com/jbeder/yaml-cpp
+
+Copyright (c) 2008-2015 Jesse Beder.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/VERSION_NUMBER b/VERSION_NUMBER
new file mode 100644
index 0000000000..0d91a54c7d
--- /dev/null
+++ b/VERSION_NUMBER
@@ -0,0 +1 @@
+0.3.0
diff --git a/commit-prepare.sh b/commit-prepare.sh
index faa217e8f4..19626baaac 100644
--- a/commit-prepare.sh
+++ b/commit-prepare.sh
@@ -3,4 +3,5 @@ cd $path
pip install pre-commit
pip install yapf
+pip install cpplint
pre-commit install
diff --git a/demo/cpp/vision/yolov5.cc b/demo/cpp/vision/yolov5.cc
new file mode 100644
index 0000000000..0fabe77ba1
--- /dev/null
+++ b/demo/cpp/vision/yolov5.cc
@@ -0,0 +1,49 @@
+// 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"
+
+int main() {
+ auto model = fastdeploy::vision::ultralytics::YOLOv5("yolov5s.onnx");
+ model.EnableDebug();
+ if (!model.Initialized()) {
+ std::cout << "Init Failed." << std::endl;
+ return -1;
+ }
+ cv::Mat im = cv::imread("bus.jpg");
+
+ for (size_t i = 0; i < 10; ++i) {
+ auto im1 = im.clone();
+ fastdeploy::vision::DetectionResult res;
+ if (!model.Predict(&im1, &res)) {
+ std::cout << "Predict Failed." << std::endl;
+ return -1;
+ }
+ }
+
+ {
+ fastdeploy::vision::DetectionResult res;
+ auto vis_im = im.clone();
+ if (!model.Predict(&im, &res)) {
+ std::cout << "Predict Failed." << std::endl;
+ return -1;
+ }
+
+ fastdeploy::vision::Visualize::VisDetection(&vis_im, res);
+ cv::imwrite("vis.jpg", vis_im);
+ // Print Detection Result
+ std::cout << res.Str() << std::endl;
+ }
+ return 0;
+}
diff --git a/demo/python/vision/yolov5.py b/demo/python/vision/yolov5.py
new file mode 100644
index 0000000000..d01df98b8a
--- /dev/null
+++ b/demo/python/vision/yolov5.py
@@ -0,0 +1,10 @@
+import fastdeploy as fd
+import cv2
+
+# 获取模型 和 测试图片
+# wget https://github.com/ultralytics/yolov5/releases/download/v6.0/yolov5s.onnx
+# wget https://raw.githubusercontent.com/ultralytics/yolov5/master/data/images/bus.jpg
+model = fd.vision.ultralytics.YOLOv5("yolov5s.onnx")
+im = cv2.imread("bus.jpg")
+result = model.predict(im, conf_threshold=0.25, nms_iou_threshold=0.5)
+print(result)
diff --git a/docs/ARM-Linux-CPP-SDK-Inference.md b/docs/ARM-Linux-CPP-SDK-Inference.md
deleted file mode 100644
index bcd4128e5d..0000000000
--- a/docs/ARM-Linux-CPP-SDK-Inference.md
+++ /dev/null
@@ -1,404 +0,0 @@
-# 简介
-
-本文档介绍FastDeploy中的模型SDK,在ARM Linux C++环境下 : (1)推理部署步骤; (2)介绍模型推流全流程API,方便开发者了解项目后二次开发。
-其中ARM Linux Python请参考[ARM Linux Python环境下的推理部署](./ARM-Linux-Python-SDK-Inference.md)文档。
-
-**注意**:部分模型(如Tinypose、OCR等)仅支持图像推理,不支持视频推理。
-
-
-
-* [简介](#简介)
-
-* [环境准备](#环境准备)
-
- * [1. 硬件支持](#1-硬件支持)
- * [2. 软件环境](#2-软件环境)
-
-* [快速开始](#快速开始)
-
- * [1. 项目结构说明](#1-项目结构说明)
- * [2. 测试Demo](#2-测试demo)
- * [2.1 预测图像](#21-预测图像)
- * [2.2 预测视频流](#22-预测视频流)
-
-* [预测API流程详解](#预测api流程详解)
-
- * [1. SDK参数运行配置](#1-sdk参数运行配置)
- * [2. 初始化Predictor](#2-初始化predictor)
- * [3. 预测推理](#3-预测推理)
- * [3.1 预测图像](#31-预测图像)
- * [3.2 预测视频](#32-预测视频)
-
-* [FAQ](#faq)
-
-
-
-# 环境准备
-
-## 1. 硬件支持
-
-目前支持的ARM架构:aarch64 、armv7hf
-
-## 2. 软件环境
-
-1.运行二进制文件-环境要求
-
-* gcc: 5.4 以上 (GLIBCXX_3.4.22)
- * Linux下查看gcc版本命名(可能因系统差异命令会不同):`gcc --version`
- * Linux下C++基础库GLIBCXX的命令(因系统差异,库路径会有不同):`strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX`
-* glibc:2.23以上
- * Linux查看命令:`ldd --version`
-
-2.二次开发编译-环境要求
-
-编译源代码时,除gcc、GLIBCXX、glibc满足`1.运行二进制文件-环境要求`外,cmake需满足:
-
-* cmake: 3.0 以上
-
- * Linux查看命令:`cmake --version`
-
-# 快速开始
-
-## 1. 项目结构说明
-
-根据开发者模型、部署芯片、操作系统需要,在图像界面[飞桨开源模型](https://ai.baidu.com/easyedge/app/openSource)或[GIthub](https://github.com/PaddlePaddle/FastDeploy)中选择对应的SDK进行下载。SDK目录结构如下:
-
-```
-.EasyEdge-Linux-m43157-b97741-x86
-├── RES # 模型资源文件夹,一套模型适配不同硬件、OS和部署方式
-│ ├── conf.json # Android、iOS系统APP名字需要
-│ ├── model # 模型结构文件
-│ ├── params # 模型参数文件
-│ ├── label_list.txt # 模型标签文件
-│ ├── infer_cfg.json # 模型前后处理等配置文件
-├── ReadMe.txt
-├── cpp # C++ SDK 文件结构
- └── baidu_easyedge_ocr_linux_cpp_aarch64_ARM_gcc5.4_v1.5.1_20220530.tar.gz #armv8架构硬件的C++包,根据自己硬件,选择对应的压缩包解压即可
- ├── ReadMe.txt
- ├── bin # 可直接运行的二进制文件
- ├── include # 二次开发用的头文件
- ├── lib # 二次开发用的所依赖的库
- ├── src # 二次开发用的示例工程
- └── thirdparty # 第三方依赖
- └── baidu_easyedge_ocr_linux_cpp_armv7l_armv7hf_ARM_gcc5.4_v1.5.1_20220530.tar.gz #armv7架构硬件的C++包,根据自己硬件,选择对应的压缩包解压即可
-└── python # Python SDK 文件
-```
-
-**注意**:
-
-1. 【OCR需要编译】因为OCR任务的特殊性,本次SDK没有提供bin文件夹可执行文件。开发者根据需要,满足文档中gcc和cmake要求后,在`src/demo*`路径编译获取可执行文件,具体可参考。
-2. 【OCR仅支持图像推理,不支持视频流推理】
-3. ARM-Linux-Python的环境要求和使用,请参考[ARM Linux Python环境下的推理部署](./ARM-Linux-Python-SDK.md)文档。
-
-## 2. 测试Demo
-
-> 模型资源文件(即压缩包中的RES文件夹)默认已经打包在开发者下载的SDK包中,请先将tar包整体拷贝到具体运行的设备中,再解压缩使用。
-
-SDK中已经包含预先编译的二进制,可直接运行。以下运行示例均是`cd cpp/bin`路径下执行的结果。
-
-### 2.1 预测图像
-
-```bash
-./easyedge_image_inference {模型RES文件夹路径} {测试图片路径}
-```
-
-运行效果示例:
-
-
-
-```bash
- > ./easyedge_image_inference ../../../../RES 2.jpeg
-2019-02-13 16:46:12,659 INFO [EasyEdge] [easyedge.cpp:34] 140606189016192 Baidu EasyEdge Linux Development Kit 0.2.1(20190213)
-2019-02-13 16:46:14,083 INFO [EasyEdge] [paddlev2_edge_predictor.cpp:60] 140606189016192 Allocate graph success.
-2019-02-13 16:46:14,326 DEBUG [EasyEdge] [paddlev2_edge_predictor.cpp:143] 140606189016192 Inference costs 168 ms
-1, 1:txt_frame, p:0.994905 loc: 0.168161, 0.153654, 0.920856, 0.779621
-Done
-```
-
-### 2.2 预测视频流
-
-```
-./easyedge_video_inference {模型RES文件夹路径} {video_type} {video_src_path}
-```
-
-其中 video_type 支持三种:
-
-```
- video_type : 1 // 本地视频文件
- video_type : 2 // 摄像头的index
- video_type : 3 // 网络视频流
-```
-
-video_src_path: 为 video_type 数值所对应的本地视频路径 、本地摄像头id、网络视频流地址,如:
-
-```
- 本地视频文件: ./easyedge_video_inference {模型RES文件夹路径} 1 ~/my_video_file.mp4
- 本地摄像头: ./easyedge_video_inference {模型RES文件夹路径} 2 1 #/dev/video1
- 网络视频流: ./easyedge_video_inference {模型RES文件夹路径} 3 rtmp://192.168.x.x:8733/live/src
-```
-
-注:以上路径是假模拟路径,开发者需要根据自己实际图像/视频,准备测试图像,并填写正确的测试路径。
-
-# 预测API流程详解
-
-本章节主要结合[2.测试Demo](#4)的Demo示例介绍推理API,方便开发者学习后二次开发。更详细的API请参考`include/easyedge/easyedge*.h`文件。图像、视频的推理包含以下3个API,如下代码片段`step`注释所示。
-
-> ❗注意:
-> (1)`src`文件夹中包含完整可编译的cmake工程实例,建议开发者先行了解[cmake工程基本知识](https://cmake.org/cmake/help/latest/guide/tutorial/index.html)。
-> (2)请优先参考SDK中自带的Demo工程的使用流程和说明。遇到错误,请优先参考文件中的注释、解释、日志说明。
-
-```cpp
- // step 1: SDK配置运行参数
- EdgePredictorConfig config;
- config.model_dir = {模型文件目录};
-
- // step 2: 创建并初始化Predictor;这这里选择合适的引擎
- auto predictor = global_controller()->CreateEdgePredictor(config);
-
- // step 3-1: 预测图像
- auto img = cv::imread({图片路径});
- std::vector results;
- predictor->infer(img, results);
-
- // step 3-2: 预测视频
- std::vector results;
- FrameTensor frame_tensor;
- VideoConfig video_config;
- video_config.source_type = static_cast(video_type); // source_type 定义参考头文件 easyedge_video.h
- video_config.source_value = video_src;
- /*
- ... more video_configs, 根据需要配置video_config的各选项
- */
- auto video_decoding = CreateVideoDecoding(video_config);
- while (video_decoding->next(frame_tensor) == EDGE_OK) {
- results.clear();
- if (frame_tensor.is_needed) {
- predictor->infer(frame_tensor.frame, results);
- render(frame_tensor.frame, results, predictor->model_info().kind);
- }
- //video_decoding->display(frame_tensor); // 显示当前frame,需在video_config中开启配置
- //video_decoding->save(frame_tensor); // 存储当前frame到视频,需在video_config中开启配置
- }
-```
-
-若需自定义library search path或者gcc路径,修改对应Demo工程下的CMakeList.txt即可。
-
-## 1. SDK参数运行配置
-
-SDK的参数通过`EdgePredictorConfig::set_config`和`global_controller()->set_config`配置。本Demo 中设置了模型路径,其他参数保留默认参数。更详细的支持运行参数等,可以参考开发工具包中的头文件(`include/easyedge/easyedge_xxxx_config.h`)的详细说明。
-
-配置参数使用方法如下:
-
-```
-EdgePredictorConfig config;
-config.model_dir = {模型文件目录};
-```
-
-## 2. 初始化Predictor
-
-* 接口
-
- ```cpp
- auto predictor = global_controller()->CreateEdgePredictor(config);
- predictor->init();
- ```
-
-若返回非0,请查看输出日志排查错误原因。
-
-## 3. 预测推理
-
-### 3.1 预测图像
-
-> 在Demo中展示了预测接口infer()传入cv::Mat& image图像内容,并将推理结果赋值给std::vector& result。更多关于infer()的使用,可以根据参考`easyedge.h`头文件中的实际情况、参数说明自行传入需要的内容做推理
-
-* 接口输入
-
-```cpp
- /**
- * @brief
- * 通用接口
- * @param image: must be BGR , HWC format (opencv default)
- * @param result
- * @return
- */
- virtual int infer(cv::Mat& image, std::vector& result) = 0;
-```
-
- 图片的格式务必为opencv默认的BGR, HWC格式。
-
-* 接口返回
-
- `EdgeResultData`中可以获取对应的分类信息、位置信息。
-
-```cpp
-struct EdgeResultData {
- int index; // 分类结果的index
- std::string label; // 分类结果的label
- float prob; // 置信度
-
- // 物体检测 或 图像分割时使用:
- float x1, y1, x2, y2; // (x1, y1): 左上角, (x2, y2): 右下角; 均为0~1的长宽比例值。
-
- // 图像分割时使用:
- cv::Mat mask; // 0, 1 的mask
- std::string mask_rle; // Run Length Encoding,游程编码的mask
-};
-```
-
-*** 关于矩形坐标 ***
-
-x1 * 图片宽度 = 检测框的左上角的横坐标
-
-y1 * 图片高度 = 检测框的左上角的纵坐标
-
-x2 * 图片宽度 = 检测框的右下角的横坐标
-
-y2 * 图片高度 = 检测框的右下角的纵坐标
-
-*** 关于图像分割mask ***
-
-```
-cv::Mat mask为图像掩码的二维数组
-{
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-}
-其中1代表为目标区域,0代表非目标区域
-```
-
-*** 关于图像分割mask_rle ***
-
-该字段返回了mask的游程编码,解析方式可参考 [http demo](https://github.com/Baidu-AIP/EasyDL-Segmentation-Demo)
-
-以上字段可以参考demo文件中使用opencv绘制的逻辑进行解析
-
-### 3.2 预测视频
-
-SDK 提供了支持摄像头读取、视频文件和网络视频流的解析工具类`VideoDecoding`,此类提供了获取视频帧数据的便利函数。通过`VideoConfig`结构体可以控制视频/摄像头的解析策略、抽帧策略、分辨率调整、结果视频存储等功能。对于抽取到的视频帧可以直接作为SDK infer 接口的参数进行预测。
-
-* 接口输入
-
-class`VideoDecoding`:
-
-```
- /**
- * @brief 获取输入源的下一帧
- * @param frame_tensor
- * @return
- */
- virtual int next(FrameTensor &frame_tensor) = 0;
-
- /**
- * @brief 显示当前frame_tensor中的视频帧
- * @param frame_tensor
- * @return
- */
- virtual int display(const FrameTensor &frame_tensor) = 0;
-
- /**
- * @brief 将当前frame_tensor中的视频帧写为本地视频文件
- * @param frame_tensor
- * @return
- */
- virtual int save(FrameTensor &frame_tensor) = 0;
-
- /**
- * @brief 获取视频的fps属性
- * @return
- */
- virtual int get_fps() = 0;
- /**
- * @brief 获取视频的width属性
- * @return
- */
- virtual int get_width() = 0;
-
- /**
- * @brief 获取视频的height属性
- * @return
- */
- virtual int get_height() = 0;
-```
-
-struct `VideoConfig`
-
-```
-/**
- * @brief 视频源、抽帧策略、存储策略的设置选项
- */
-struct VideoConfig {
- SourceType source_type; // 输入源类型
- std::string source_value; // 输入源地址,如视频文件路径、摄像头index、网络流地址
- int skip_frames{0}; // 设置跳帧,每隔skip_frames帧抽取一帧,并把该抽取帧的is_needed置为true
- int retrieve_all{false}; // 是否抽取所有frame以便于作为显示和存储,对于不满足skip_frames策略的frame,把所抽取帧的is_needed置为false
- int input_fps{0}; // 在采取抽帧之前设置视频的fps
- Resolution resolution{Resolution::kAuto}; // 采样分辨率,只对camera有效
-
- bool enable_display{false}; // 默认不支持。
- std::string window_name{"EasyEdge"};
- bool display_all{false}; // 是否显示所有frame,若为false,仅显示根据skip_frames抽取的frame
-
- bool enable_save{false};
- std::string save_path; // frame存储为视频文件的路径
- bool save_all{false}; // 是否存储所有frame,若为false,仅存储根据skip_frames抽取的frame
-
- std::map conf;
-};
-```
-
-| 序号 | 字段 | 含义 |
-| --- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
-| 1 | `source_type` | 输入源类型,支持视频文件、摄像头、网络视频流三种,值分别为1、2、3 |
-| 2 | `source_value` | 若`source_type`为视频文件,该值为指向视频文件的完整路径;若`source_type`为摄像头,该值为摄像头的index,如对于`/dev/video0`的摄像头,则index为0;若`source_type`为网络视频流,则为该视频流的完整地址。 |
-| 3 | `skip_frames` | 设置跳帧,每隔skip_frames帧抽取一帧,并把该抽取帧的is_needed置为true,标记为is_needed的帧是用来做预测的帧。反之,直接跳过该帧,不经过预测。 |
-| 4 | `retrieve_all` | 若置该项为true,则无论是否设置跳帧,所有的帧都会被抽取返回,以作为显示或存储用。 |
-| 5 | `input_fps` | 用于抽帧前设置fps |
-| 6 | `resolution` | 设置摄像头采样的分辨率,其值请参考`easyedge_video.h`中的定义,注意该分辨率调整仅对输入源为摄像头时有效 |
-| 7 | `conf` | 高级选项。部分配置会通过该map来设置 |
-
-*** 注意:***
-
-1. `VideoConfig`不支持`display`功能。如果需要使用`VideoConfig`的`display`功能,需要自行编译带有GTK选项的OpenCV。
-
-2. 使用摄像头抽帧时,如果通过`resolution`设置了分辨率调整,但是不起作用,请添加如下选项:
-
- ```
- video_config.conf["backend"] = "2";
- ```
-
-3. 部分设备上的CSI摄像头尚未兼容,如遇到问题,可以通过工单、QQ交流群或微信交流群反馈。
-
-具体接口调用流程,可以参考SDK中的`demo_video_inference`。
-
-# FAQ
-
-1. 如何处理一些 undefined reference / error while loading shared libraries?
-
- > 如:./easyedge_demo: error while loading shared libraries: libeasyedge.so.1: cannot open shared object file: No such file or directory
-
- 遇到该问题时,请找到具体的库的位置,设置LD_LIBRARY_PATH;或者安装缺少的库。
-
- > 示例一:libverify.so.1: cannot open shared object file: No such file or directory
- > 链接找不到libveirfy.so文件,一般可通过 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../lib 解决(实际冒号后面添加的路径以libverify.so文件所在的路径为准)
-
- > 示例二:libopencv_videoio.so.4.5: cannot open shared object file: No such file or directory
- > 链接找不到libopencv_videoio.so文件,一般可通过 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../thirdparty/opencv/lib 解决(实际冒号后面添加的路径以libopencv_videoio.so所在路径为准)
-
- > 示例三:GLIBCXX_X.X.X not found
- > 链接无法找到glibc版本,请确保系统gcc版本>=SDK的gcc版本。升级gcc/glibc可以百度搜索相关文献。
-
-2. 运行二进制时,提示 libverify.so cannot open shared object file
-
- 可能cmake没有正确设置rpath, 可以设置LD_LIBRARY_PATH为sdk的lib文件夹后,再运行:
-
- ```bash
- LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib ./easyedge_demo
- ```
-
-3. 编译时报错:file format not recognized
-
- 可能是因为在复制SDK时文件信息丢失。请将整个压缩包复制到目标设备中,再解压缩、编译。
diff --git a/docs/ARM-Linux-CPP-SDK-Serving.md b/docs/ARM-Linux-CPP-SDK-Serving.md
deleted file mode 100644
index 9c6a215cfd..0000000000
--- a/docs/ARM-Linux-CPP-SDK-Serving.md
+++ /dev/null
@@ -1,318 +0,0 @@
-# 简介
-
-本文档介绍FastDeploy中的模型SDK,在ARM Linux C++环境下:(1)服务化推理部署步骤;(2)介绍模型推流全流程API,方便开发者了解项目后二次开发。
-其中ARM Linux Python请参考[ARM Linux Python环境下的HTTP推理部署](./ARM-Linux-Python-SDK-Serving.md)文档。
-
-**注意**:部分模型(如OCR等)不支持服务化推理。
-
-
-
-* [简介](#简介)
-
-* [安装准备](#安装准备)
-
- * [1. 硬件支持](#1-硬件支持)
- * [2. 软件环境](#2-软件环境)
-
-* [快速开始](#快速开始)
-
- * [1. 项目结构说明](#1-项目结构说明)
- * [2. 测试 HTTP Demo](#2-测试-http-demo)
- * [2.1 启动HTTP预测服务](#21-启动http预测服务)
-
-* [HTTP API流程详解](#http-api流程详解)
-
- * [1. 开启http服务](#1-开启http服务)
- * [2. 请求http服务](#2-请求http服务)
- * [2.1 http 请求方式一:不使用图片base64格式](#21-http-请求方式一不使用图片base64格式)
- * [2.2 http 请求方法二:使用图片base64格式](#22-http-请求方法二使用图片base64格式)
- * [3. http返回数据](#3-http返回数据)
-
-* [FAQ](#faq)
-
-
-
-# 安装准备
-
-## 1. 硬件支持
-
-目前支持的ARM架构:aarch64 、armv7hf
-
-## 2. 软件环境
-
-1.运行二进制文件-环境要求
-
-* gcc: 5.4 以上 (GLIBCXX_3.4.22)
- * Linux下查看gcc版本命名(可能因系统差异命令会不同):`gcc --version`;
- * Linux下C++基础库GLIBCXX的命令(可能因系统差异路径会有不同,可检测自己环境下的情况):`strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX`
-* glibc:2.23以上
- * Linux查看命令:`ldd --version`
-
-2.二次开发编译-环境要求
-
-编译源代码时,除了gcc、GLIBCXX、glibc满足`1.运行二进制文件-环境要求`外,还需要cmake满足要求。
-
-* cmake: 3.0 以上
-
- * Linux查看命令:`cmake --version`
-
-# 快速开始
-
-## 1. 项目结构说明
-
-根据开发者模型、部署芯片、操作系统需要,在图像界面[飞桨开源模型](https://ai.baidu.com/easyedge/app/openSource)或[GIthub](https://github.com/PaddlePaddle/FastDeploy)中选择对应的SDK进行下载。解压后SDK目录结构如下:
-
-```
-.EasyEdge-Linux-m43157-b97741-x86
-├── RES # 模型资源文件夹,一套模型适配不同硬件、OS和部署方式
-│ ├── conf.json # Android、iOS系统APP名字需要
-│ ├── model # 模型结构文件
-│ ├── params # 模型参数文件
-│ ├── label_list.txt # 模型标签文件
-│ ├── infer_cfg.json # 模型前后处理等配置文件
-├── ReadMe.txt
-├── cpp # C++ SDK 文件结构
- └── baidu_easyedge_linux_cpp_x86_64_CPU.Generic_gcc5.4_v1.4.0_20220325.tar.gz
- ├── bin # 可直接运行的二进制文件
- ├── include # 二次开发用的头文件
- ├── lib # 二次开发用的所依赖的库
- ├── src # 二次开发用的示例工程
- └── thirdparty # 第三方依赖
-└── python # Python SDK 文件
-```
-
-## 2. 测试 HTTP Demo
-
-> 模型资源文件(即压缩包中的RES文件夹)默认已经打包在开发者下载的SDK包中,请先将tar包整体拷贝到具体运行的设备中,再解压缩使用。
-
-SDK中已经包含预先编译的二进制,可直接运行。以下运行示例均是`cd cpp/bin`路径下执行的结果。
-
-### 2.1 启动HTTP预测服务
-
-```
-./easyedge_serving {模型RES文件夹路径}
-```
-
-启动后,日志中会显示如下设备IP和24401端口号信息:
-
-```
-HTTP is now serving at 0.0.0.0:24401
-```
-
-此时,开发者可以打开浏览器,输入链接地址`http://0.0.0.0:24401`(这里的`设备IP和24401端口号`根据开发者电脑显示修改),选择图片来进行测试。
-
-
-
-同时,可以调用HTTP接口来访问服务,具体参考下文的[二次开发](#10)接口说明。
-
-# HTTP API流程详解
-
-本章节主要结合[2.1 HTTP Demo]()的API介绍,方便开发者学习并将运行库嵌入到开发者的程序当中,更详细的API请参考`include/easyedge/easyedge*.h`文件。http服务包含服务端和客户端,目前支持的能力包括以下几种方式,Demo中提供了不使用图片base格式的`方式一:浏览器请求的方式`,其他几种方式开发者根据个人需要,选择开发。
-
-## 1. 开启http服务
-
-http服务的启动可直接使用`bin/easyedge_serving`,或参考`src/demo_serving.cpp`文件修改相关逻辑
-
-```cpp
- /**
- * @brief 开启一个简单的demo http服务。
- * 该方法会block直到收到sigint/sigterm。
- * http服务里,图片的解码运行在cpu之上,可能会降低推理速度。
- * @tparam ConfigT
- * @param config
- * @param host
- * @param port
- * @param service_id service_id user parameter, uri '/get/service_id' will respond this value with 'text/plain'
- * @param instance_num 实例数量,根据内存/显存/时延要求调整
- * @return
- */
- template
- int start_http_server(
- const ConfigT &config,
- const std::string &host,
- int port,
- const std::string &service_id,
- int instance_num = 1);
-```
-
-## 2. 请求http服务
-
-> 开发者可以打开浏览器,`http://{设备ip}:24401`,选择图片来进行测试。
-
-### 2.1 http 请求方式一:不使用图片base64格式
-
-URL中的get参数:
-
-| 参数 | 说明 | 默认值 |
-| --------- | --------- | ---------------- |
-| threshold | 阈值过滤, 0~1 | 如不提供,则会使用模型的推荐阈值 |
-
-HTTP POST Body即为图片的二进制内容(无需base64, 无需json)
-
-Python请求示例
-
-```Python
-import requests
-
-with open('./1.jpg', 'rb') as f:
- img = f.read()
- result = requests.post(
- 'http://127.0.0.1:24401/',
- params={'threshold': 0.1},
- data=img).json()
-```
-
-### 2.2 http 请求方法二:使用图片base64格式
-
-HTTP方法:POST
-Header如下:
-
-| 参数 | 值 |
-| ------------ | ---------------- |
-| Content-Type | application/json |
-
-**Body请求填写**:
-
-* 分类网络:
- body 中请求示例
-
- ```
- {
- "image": ""
- "top_num": 5
- }
- ```
-
- body中参数详情
-
-| 参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
-| ------- | ---- | ------ | ----- | ----------------------------------------------------------------------------------- |
-| image | 是 | string | - | 图像数据,base64编码,要求base64图片编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 **注意去掉头部** |
-| top_num | 否 | number | - | 返回分类数量,不填该参数,则默认返回全部分类结果 |
-
-* 检测和分割网络:
- Body请求示例:
-
- ```
- {
- "image": ""
- }
- ```
-
- body中参数详情:
-
-| 参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
-| --------- | ---- | ------ | ----- | ----------------------------------------------------------------------------------- |
-| image | 是 | string | - | 图像数据,base64编码,要求base64图片编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 **注意去掉头部** |
-| threshold | 否 | number | - | 默认为推荐阈值,也可自行根据需要进行设置 |
-
-Python请求示例:
-
-```Python
-import base64
-import requests
-def main():
- with open("图像路径", 'rb') as f:
- result = requests.post("http://{服务ip地址}:24401/", json={
- "image": base64.b64encode(f.read()).decode("utf8")
- })
- # print(result.request.body)
- # print(result.request.headers)
- print(result.content)
-
-if __name__ == '__main__':
- main()
-```
-
-## 3. http返回数据
-
-| 字段 | 类型说明 | 其他 |
-| ---------- | ------ | ------------------------------------ |
-| error_code | Number | 0为成功,非0参考message获得具体错误信息 |
-| results | Array | 内容为具体的识别结果。其中字段的具体含义请参考`预测图像-返回格式`一节 |
-| cost_ms | Number | 预测耗时ms,不含网络交互时间 |
-
-返回示例
-
-```json
-{
- "cost_ms": 52,
- "error_code": 0,
- "results": [
- {
- "confidence": 0.94482421875,
- "index": 1,
- "label": "IronMan",
- "x1": 0.059185408055782318,
- "x2": 0.18795496225357056,
- "y1": 0.14762254059314728,
- "y2": 0.52510076761245728,
- "mask": "...", // 图像分割模型字段
- "trackId": 0, // 目标追踪模型字段
- },
-
- ]
-}
-```
-
-*** 关于矩形坐标 ***
-
-x1 * 图片宽度 = 检测框的左上角的横坐标
-
-y1 * 图片高度 = 检测框的左上角的纵坐标
-
-x2 * 图片宽度 = 检测框的右下角的横坐标
-
-y2 * 图片高度 = 检测框的右下角的纵坐标
-
-*** 关于图像分割mask ***
-
-```
-cv::Mat mask为图像掩码的二维数组
-{
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-}
-其中1代表为目标区域,0代表非目标区域
-```
-
-# FAQ
-
-1. 如何处理一些 undefined reference / error while loading shared libraries?
-
- > 如:./easyedge_demo: error while loading shared libraries: libeasyedge.so.1: cannot open shared object file: No such file or directory
-
- 遇到该问题时,请找到具体的库的位置,设置LD_LIBRARY_PATH;或者安装缺少的库。
-
- > 示例一:libverify.so.1: cannot open shared object file: No such file or directory
- > 链接找不到libveirfy.so文件,一般可通过 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../lib 解决(实际冒号后面添加的路径以libverify.so文件所在的路径为准)
-
- > 示例二:libopencv_videoio.so.4.5: cannot open shared object file: No such file or directory
- > 链接找不到libopencv_videoio.so文件,一般可通过 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../thirdparty/opencv/lib 解决(实际冒号后面添加的路径以libopencv_videoio.so所在路径为准)
-
- > 示例三:GLIBCXX_X.X.X not found
- > 链接无法找到glibc版本,请确保系统gcc版本>=SDK的gcc版本。升级gcc/glibc可以百度搜索相关文献。
-
-2. 使用libcurl请求http服务时,速度明显变慢
-
- 这是因为libcurl请求continue导致server等待数据的问题,添加空的header即可
-
- ```bash
- headers = curl_slist_append(headers, "Expect:");
- ```
-
-3. 运行二进制时,提示 libverify.so cannot open shared object file
-
- 可能cmake没有正确设置rpath, 可以设置LD_LIBRARY_PATH为sdk的lib文件夹后,再运行:
-
- ```bash
- LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib ./easyedge_demo
- ```
-
-4. 编译时报错:file format not recognized
-
- 可能是因为在复制SDK时文件信息丢失。请将整个压缩包复制到目标设备中,再解压缩、编译。
diff --git a/docs/ARM-Linux-Python-SDK-Inference.md b/docs/ARM-Linux-Python-SDK-Inference.md
deleted file mode 100644
index 260be108dd..0000000000
--- a/docs/ARM-Linux-Python-SDK-Inference.md
+++ /dev/null
@@ -1,371 +0,0 @@
-# 简介
-
-本文档以[千分类模型_MobileNetV3](https://ai.baidu.com/easyedge/app/openSource)为例,介绍FastDeploy中的模型SDK, 在**ARM Linux Python** 环境下:(1)图像推理部署步骤; (2)介绍模型推流全流程API,方便开发者了解项目后二次开发。其中ARM Linux C++请参考[ARM Linux C++环境下的推理部署](./ARM-Linux-CPP-SDK-Inference.md)文档。
-
-**注意**:部分模型(如Tinypose、OCR等)仅支持图像推理,不支持视频推理。
-
-
-
-* [简介](#简介)
-
-* [环境准备](#环境准备)
-
- * [1.SDK下载](#1sdk下载)
- * [2.硬件支持](#2硬件支持)
- * [3.python环境](#3python环境)
- * [4.安装依赖](#4安装依赖)
- * [4.1.安装paddlepaddle](#41安装paddlepaddle)
- * [4.2.安装EasyEdge Python Wheel 包](#42安装easyedge-python-wheel-包)
-
-* [快速开始](#快速开始)
-
- * [1.文件结构说明](#1文件结构说明)
- * [2.测试Demo](#2测试demo)
- * [2.1预测图像](#21预测图像)
-
-* [Demo API介绍](#demo-api介绍)
-
- * [1.基础流程](#1基础流程)
- * [2.初始化](#2初始化)
- * [3.SDK参数配置](#3sdk参数配置)
- * [4.预测图像](#4预测图像)
-
-* [FAQ](#faq)
-
-
-
-# 环境准备
-
-## 1.SDK下载
-
-根据开发者模型、部署芯片、操作系统需要,在图像界面[飞桨开源模型](https://ai.baidu.com/easyedge/app/openSource)或[GIthub](https://github.com/PaddlePaddle/FastDeploy)中选择对应的SDK进行下载。
-
-```shell
-EasyEdge-Linux-x86--[部署芯片]
-├──...
-├──python # Linux Python SDK
- ├── # 特定Python版本的EasyEdge Wheel包, 二次开发可使用
- ├── BaiduAI_EasyEdge_SDK-1.3.1-cp36-cp36m-linux_aarch64.whl
- ├── infer_demo # demo体验完整文件
- │ ├── demo_xxx.py # 包含前后处理的端到端推理demo文件
- │ └── demo_serving.py # 提供http服务的demo文件
- ├── tensor_demo # 学习自定义算法前后处理时使用
- │ └── demo_xxx.py
-```
-
-## 2.硬件支持
-
-目前支持的ARM架构:aarch64 、armv7hf
-
-## 3.python环境
-
-> ARM Linux SDK仅支持Python 3.6
-
-使用如下命令获取已安装的Python版本号。如果本机的版本不匹配,建议使用[pyenv](https://github.com/pyenv/pyenv)、[anaconda](https://www.anaconda.com/)等Python版本管理工具对SDK所在目录进行配置。
-
-```shell
-$python3 --version
-```
-
-接着使用如下命令确认pip的版本是否满足要求,要求pip版本为20.2.2或更高版本。详细的pip安装过程可以参考[官网教程](https://pip.pypa.io/en/stable/installation/)。
-
-```shell
-$python3 -m pip --version
-```
-
-## 4.安装依赖
-
-### 4.1.安装paddlepaddle
-
-根据具体的部署芯片(CPU/GPU)安装对应的PaddlePaddle的whl包。
-
-`armv8 CPU平台`可以使用如下命令进行安装:
-
-```shell
-python3 -m pip install http://aipe-easyedge-public.bj.bcebos.com/easydeploy/paddlelite-2.11-cp36-cp36m-linux_aarch64.whl
-```
-
-### 4.2.安装EasyEdge Python Wheel 包
-
-在`python`目录下,安装特定Python版本的EasyEdge Wheel包。`armv8 CPU平台`可以使用如下命令进行安装:
-
-```shell
-python3 -m pip install -U BaiduAI_EasyEdge_SDK-1.3.1-cp36-cp36m-linux_aarch64.whl
-```
-
-# 快速开始
-
-## 1.文件结构说明
-
-Python SDK文件结构如下:
-
-```shell
-.EasyEdge-Linux-x86--[部署芯片]
-├── RES # 模型资源文件夹,一套模型适配不同硬件、OS和部署方式
-│ ├── conf.json # Android、iOS系统APP名字需要
-│ ├── label_list.txt # 模型标签文件
-│ ├── model # 模型结构文件
-│ ├── params # 模型参数文件
-│ └── infer_cfg.json # 模型前后处理等配置文件
-├── ReadMe.txt
-├── cpp # C++ SDK 文件结构
-└── python # Python SDK 文件
- ├── BaiduAI_EasyEdge_SDK-1.3.1-cp36-cp36m-linux_aarch64.whl #EasyEdge Python Wheel 包
- ├── infer_demo
- ├── demo_armv8_cpu.py # 图像推理
- ├── demo_serving.py # HTTP服务化推理
- └── tensor_demo # 学习自定义算法前后处理时使用
- ├── demo_armv8_cpu.py
-```
-
-## 2.测试Demo
-
-> 模型资源文件默认已经打包在开发者下载的SDK包中, 默认为`RES`目录。
-
-### 2.1预测图像
-
-使用infer_demo文件夹下的demo文件。
-
-```bash
-python3 demo_x86_cpu.py {模型RES文件夹} {测试图片路径}
-```
-
-运行效果示例:
-
-
-
-```shell
-2022-06-14 14:40:16 INFO [EasyEdge] [demo_nvidia_gpu.py:38] 140518522509120: Init paddlefluid engine...
-2022-06-14 14:40:20 INFO [EasyEdge] [demo_nvidia_gpu.py:38] 140518522509120: Paddle version: 2.2.2
-{'confidence': 0.9012349843978882, 'index': 8, 'label': 'n01514859 hen'}
-```
-
-可以看到,运行结果为`index:8,label:hen`,通过imagenet [类别映射表](https://gist.github.com/yrevar/942d3a0ac09ec9e5eb3a),可以找到对应的类别,即 'hen',由此说明我们的预测结果正确。
-
-# Demo API介绍
-
-本章节主要结合[测试Demo](#2测试Demo)的Demo示例介绍推理API,方便开发者学习后二次开发。
-
-## 1.基础流程
-
-> ❗注意,请优先参考SDK中自带demo的使用流程和说明。遇到错误,请优先参考文件中的注释、解释、日志说明。
-
-`infer_demo/demo_xx_xx.py`
-
-```python
-# 引入EasyEdge运行库
-import BaiduAI.EasyEdge as edge
-
-# 创建并初始化一个预测Progam;选择合适的引擎
-pred = edge.Program()
-pred.init(model_dir={RES文件夹路径}, device=edge.Device.CPU, engine=edge.Engine.PADDLE_FLUID) # x86_64 CPU
-# pred.init(model_dir=_model_dir, device=edge.Device.GPU, engine=edge.Engine.PADDLE_FLUID) # x86_64 Nvidia GPU
-# pred.init(model_dir=_model_dir, device=edge.Device.CPU, engine=edge.Engine.PADDLE_LITE) # armv8 CPU
-
-# 预测图像
-res = pred.infer_image({numpy.ndarray的图片})
-
-# 关闭结束预测Progam
-pred.close()
-```
-
-`infer_demo/demo_serving.py`
-
-```python
-import BaiduAI.EasyEdge as edge
-from BaiduAI.EasyEdge.serving import Serving
-
-# 创建并初始化Http服务
-server = Serving(model_dir={RES文件夹路径}, license=serial_key)
-
-# 运行Http服务
-# 请参考同级目录下demo_xx_xx.py里:
-# pred.init(model_dir=xx, device=xx, engine=xx, device_id=xx)
-# 对以下参数device\device_id和engine进行修改
-server.run(host=host, port=port, device=edge.Device.CPU, engine=edge.Engine.PADDLE_FLUID) # x86_64 CPU
-# server.run(host=host, port=port, device=edge.Device.GPU, engine=edge.Engine.PADDLE_FLUID) # x86_64 Nvidia GPU
-# server.run(host=host, port=port, device=edge.Device.CPU, engine=edge.Engine.PADDLE_LITE) # armv8 CPU
-```
-
-## 2.初始化
-
-* 接口
-
- ```python
- def init(self,
- model_dir,
- device=Device.CPU,
- engine=Engine.PADDLE_FLUID,
- config_file='conf.json',
- preprocess_file='preprocess_args.json',
- model_file='model',
- params_file='params',
- label_file='label_list.txt',
- infer_cfg_file='infer_cfg.json',
- device_id=0,
- thread_num=1
- ):
- """
- Args:
- model_dir: str
- device: BaiduAI.EasyEdge.Device,比如:Device.CPU
- engine: BaiduAI.EasyEdge.Engine, 比如: Engine.PADDLE_FLUID
- config_file: str
- preprocess_file: str
- model_file: str
- params_file: str
- label_file: str 标签文件
- infer_cfg_file: 包含预处理、后处理信息的文件
- device_id: int 设备ID
- thread_num: int CPU的线程数
-
- Raises:
- RuntimeError, IOError
- Returns:
- bool: True if success
- """
- ```
-
-若返回不是True,请查看输出日志排查错误原因。
-
-## 3.SDK参数配置
-
-使用 CPU 预测时,可以通过在 init 中设置 thread_num 使用多线程预测。如:
-
-```python
-pred.init(model_dir=_model_dir, device=edge.Device.CPU, engine=edge.Engine.PADDLE_FLUID, thread_num=4)
-```
-
-使用 GPU 预测时,可以通过在 init 中设置 device_id 指定需要的GPU device id。如:
-
-```python
-pred.init(model_dir=_model_dir, device=edge.Device.GPU, engine=edge.Engine.PADDLE_FLUID, device_id=0)
-```
-
-## 4.预测图像
-
-* 接口
-
- ```python
- def infer_image(self, img,
- threshold=0.3,
- channel_order='HWC',
- color_format='BGR',
- data_type='numpy'):
- """
-
- Args:
- img: np.ndarray or bytes
- threshold: float
- only return result with confidence larger than threshold
- channel_order: string
- channel order HWC or CHW
- color_format: string
- color format order RGB or BGR
- data_type: string
- 仅在图像分割时有意义。 'numpy' or 'string'
- 'numpy': 返回已解析的mask
- 'string': 返回未解析的mask游程编码
-
- Returns:
- list
-
- """
- ```
-
-* 返回格式: `[dict1, dict2, ...]`
-
-| 字段 | 类型 | 取值 | 说明 |
-| ---------- | -------------------- | --------- | ------------------------ |
-| confidence | float | 0~1 | 分类或检测的置信度 |
-| label | string | | 分类或检测的类别 |
-| index | number | | 分类或检测的类别 |
-| x1, y1 | float | 0~1 | 物体检测,矩形的左上角坐标 (相对长宽的比例值) |
-| x2, y2 | float | 0~1 | 物体检测,矩形的右下角坐标(相对长宽的比例值) |
-| mask | string/numpy.ndarray | 图像分割的mask | |
-
-***关于矩形坐标***
-
-x1 * 图片宽度 = 检测框的左上角的横坐标
-
-y1 * 图片高度 = 检测框的左上角的纵坐标
-
-x2 * 图片宽度 = 检测框的右下角的横坐标
-
-y2 * 图片高度 = 检测框的右下角的纵坐标
-
-可以参考 demo 文件中使用 opencv 绘制矩形的逻辑。
-
-***结果示例***
-
- i) 图像分类
-
-```json
-{
- "index": 736,
- "label": "table",
- "confidence": 0.9
-}
-```
-
- ii) 物体检测
-
-```json
-{
- "index": 8,
- "label": "cat",
- "confidence": 1.0,
- "x1": 0.21289,
- "y1": 0.12671,
- "x2": 0.91504,
- "y2": 0.91211,
-}
-```
-
- iii) 图像分割
-
-```json
-{
- "name": "cat",
- "score": 1.0,
- "location": {
- "left": ...,
- "top": ...,
- "width": ...,
- "height": ...,
- },
- "mask": ...
-}
-```
-
-mask字段中,data_type为`numpy`时,返回图像掩码的二维数组
-
-```
-{
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-}
-其中1代表为目标区域,0代表非目标区域
-```
-
-data_type为`string`时,mask的游程编码,解析方式可参考 [demo](https://github.com/Baidu-AIP/EasyDL-Segmentation-Demo)
-
-# FAQ
-
-1.执行infer_demo文件时,提示your generated code is out of date and must be regenerated with protoc >= 3.19.0
-
- 进入当前项目,首先卸载protobuf
-
- ```shell
- python3 -m pip uninstall protobuf
- ```
-
- 安装低版本protobuf
-
- ```shell
- python3 -m pip install protobuf==3.19.0
- ```
diff --git a/docs/ARM-Linux-Python-SDK-Serving.md b/docs/ARM-Linux-Python-SDK-Serving.md
deleted file mode 100644
index aa37e7e405..0000000000
--- a/docs/ARM-Linux-Python-SDK-Serving.md
+++ /dev/null
@@ -1,266 +0,0 @@
-# 简介
-
-本文档以[千分类模型_MobileNetV3](https://ai.baidu.com/easyedge/app/openSource)为例,介绍FastDeploy中的模型SDK, 在**ARM Linux Python** 环境下: (1)**服务化**推理部署步骤; (2)介绍模型推流全流程API,方便开发者了解项目后二次开发。其中ARM Linux Python请参考[ARM Linux C++环境下的HTTP推理部署](./ARM-Linux-CPP-SDK-Serving.md)文档。
-
-**注意**:部分模型(如OCR等)不支持服务化推理。
-
-
-
-* [简介](#简介)
-
-* [环境准备](#环境准备)
-
- * [1.SDK下载](#1sdk下载)
- * [2.硬件支持](#2硬件支持)
- * [3.Python环境](#3python环境)
- * [4.安装依赖](#4安装依赖)
- * [4.1.安装paddlepaddle](#41安装paddlepaddle)
- * [4.2.安装EasyEdge Python Wheel 包](#42安装easyedge-python-wheel-包)
-
-* [快速开始](#快速开始)
-
- * [1.文件结构说明](#1文件结构说明)
- * [2.测试Serving服务](#2测试serving服务)
- * [2.1 启动HTTP预测服务](#21-启动http预测服务)
-
-* [HTTP API流程详解](#http-api流程详解)
-
- * [1. 开启http服务](#1-开启http服务)
- * [2. 请求http服务](#2-请求http服务)
- * [2.1 http 请求方式:不使用图片base64格式](#21-http-请求方式不使用图片base64格式)
- * [3. http返回数据](#3-http返回数据)
-
-* [FAQ](#faq)
-
-
-
-# 环境准备
-
-## 1.SDK下载
-
-根据开发者模型、部署芯片、操作系统需要,在图像界面[飞桨开源模型](https://ai.baidu.com/easyedge/app/openSource)或[GIthub](https://github.com/PaddlePaddle/FastDeploy)中选择对应的SDK进行下载。解压缩后的文件结构如下。
-
-```shell
-EasyEdge-Linux-x86-[部署芯片]
-├── RES # 模型文件资源文件夹,可替换为其他模型
-├── README.md
-├── cpp # C++ SDK
-└── python # Python SDK
-```
-
-## 2.硬件支持
-
-目前支持的ARM架构:aarch64 、armv7hf
-
-## 3.Python环境
-
-> ARM Linux SDK仅支持Python 3.6
-
-使用如下命令获取已安装的Python版本号。如果本机的版本不匹配,需要根据ARM Linux下Python安装方式进行安装。(不建议在ARM Linux下使用conda,因为ARM Linux场景通常资源很有限)
-
-```shell
-$python3 --version
-```
-
-接着使用如下命令确认pip的版本是否满足要求,要求pip版本为20.2.2或更高版本。详细的pip安装过程可以参考[官网教程](https://pip.pypa.io/en/stable/installation/)。
-
-```shell
-$python3 -m pip --version
-```
-
-## 4.安装依赖
-
-### 4.1.安装paddlepaddle
-
-根据具体的部署芯片(CPU/GPU)安装对应的PaddlePaddle的whl包。
-
-`armv8 CPU平台`可以使用如下命令进行安装:
-
-```shell
-python3 -m pip install http://aipe-easyedge-public.bj.bcebos.com/easydeploy/paddlelite-2.11-cp36-cp36m-linux_aarch64.whl
-```
-
-### 4.2.安装EasyEdge Python Wheel 包
-
-在`python`目录下,安装特定Python版本的EasyEdge Wheel包。`armv8 CPU平台`可以使用如下命令进行安装:
-
-```shell
-python3 -m pip install -U BaiduAI_EasyEdge_SDK-1.3.1-cp36-cp36m-linux_aarch64.whl
-```
-
-# 二.快速开始
-
-## 1.文件结构说明
-
-Python SDK文件结构如下:
-
-```shell
-EasyEdge-Linux-x86--[部署芯片]
-├──...
-├──python # Linux Python SDK
- ├── # 特定Python版本的EasyEdge Wheel包, 二次开发可使用
- ├── BBaiduAI_EasyEdge_SDK-1.3.1-cp36-cp36m-linux_aarch64.whl
- ├── infer_demo # demo体验完整文件
- │ ├── demo_xxx.py # 包含前后处理的端到端推理demo文件
- │ └── demo_serving.py # 提供http服务的demo文件
- ├── tensor_demo # 学习自定义算法前后处理时使用
- │ └── demo_xxx.py
-```
-
-## 2.测试Serving服务
-
-> 模型资源文件默认已经打包在开发者下载的SDK包中, 默认为`RES`目录。
-
-### 2.1 启动HTTP预测服务
-
-指定对应的模型文件夹(默认为`RES`)、设备ip和指定端口号,运行如下命令。
-
-```shell
-python3 demo_serving.py {模型RES文件夹} {host, default 0.0.0.0} {port, default 24401}
-```
-
-成功启动后,终端中会显示如下字样。
-
-```shell
-...
-* Running on {host ip}:24401
-```
-
-如果是在局域网内的机器上部署,开发者此时可以打开浏览器,输入`http://{host ip}:24401`,选择图片来进行测试,运行效果如下。
-
-
-
-如果是在远程机器上部署,那么可以参考`demo_serving.py`中的 `http_client_test()函数`请求http服务来执行推理。
-
-# 三. HTTP API流程详解
-
-## 1. 开启http服务
-
-http服务的启动使用`demo_serving.py`文件
-
-```python
-class Serving(object):
- """
- SDK local serving
- """
-
- def __init__(self, model_dir, license='', model_filename='model', params_filename='params'):
-
- self.program = None
- self.model_dir = model_dir
- self.model_filename = model_filename
- self.params_filename = params_filename
- self.program_lock = threading.Lock()
- self.license_key = license
- # 只有ObjectTracking会初始化video_processor
- self.video_processor = None
-
- def run(self, host, port, device, engine=Engine.PADDLE_FLUID, service_id=0, device_id=0, **kwargs):
- """
- Args:
- host : str
- port : str
- device : BaiduAI.EasyEdge.Device,比如:Device.CPU
- engine : BaiduAI.EasyEdge.Engine, 比如: Engine.PADDLE_FLUID
- """
- self.run_serving_with_flask(host, port, device, engine, service_id, device_id, **kwargs)
-```
-
-## 2. 请求http服务
-
-> 开发者可以打开浏览器,`http://{设备ip}:24401`,选择图片来进行测试。
-
-### 2.1 http 请求方式:不使用图片base64格式
-
-URL中的get参数:
-
-| 参数 | 说明 | 默认值 |
-| --------- | --------- | ---------------- |
-| threshold | 阈值过滤, 0~1 | 如不提供,则会使用模型的推荐阈值 |
-
-HTTP POST Body即为图片的二进制内容
-
-Python请求示例
-
-```python
-import requests
-
-with open('./1.jpg', 'rb') as f:
- img = f.read()
- result = requests.post(
- 'http://127.0.0.1:24401/',
- params={'threshold': 0.1},
- data=img).json()
-```
-
-## 3. http返回数据
-
-| 字段 | 类型说明 | 其他 |
-| ---------- | ------ | ------------------------------------ |
-| error_code | Number | 0为成功,非0参考message获得具体错误信息 |
-| results | Array | 内容为具体的识别结果。其中字段的具体含义请参考`预测图像-返回格式`一节 |
-| cost_ms | Number | 预测耗时ms,不含网络交互时间 |
-
-返回示例
-
-```json
-{
- "cost_ms": 52,
- "error_code": 0,
- "results": [
- {
- "confidence": 0.94482421875,
- "index": 1,
- "label": "IronMan",
- "x1": 0.059185408055782318,
- "x2": 0.18795496225357056,
- "y1": 0.14762254059314728,
- "y2": 0.52510076761245728,
- "mask": "...", // 图像分割模型字段
- "trackId": 0, // 目标追踪模型字段
- },
-
- ]
-}
-```
-
-***关于矩形坐标***
-
-x1 * 图片宽度 = 检测框的左上角的横坐标
-
-y1 * 图片高度 = 检测框的左上角的纵坐标
-
-x2 * 图片宽度 = 检测框的右下角的横坐标
-
-y2 * 图片高度 = 检测框的右下角的纵坐标
-
-*** 关于图像分割mask ***
-
-```
-cv::Mat mask为图像掩码的二维数组
-{
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-}
-其中1代表为目标区域,0代表非目标区域
-```
-
-# FAQ
-
-1.执行infer_demo文件时,提示your generated code is out of date and must be regenerated with protoc >= 3.19.0
-
- 进入当前项目,首先卸载protobuf
-
- ```shell
- python3 -m pip uninstall protobuf
- ```
-
- 安装低版本protobuf
-
- ```shell
- python3 -m pip install protobuf==3.19.0
- ```
diff --git a/docs/Android-SDK.md b/docs/Android-SDK.md
deleted file mode 100644
index 2a2abbc560..0000000000
--- a/docs/Android-SDK.md
+++ /dev/null
@@ -1,404 +0,0 @@
-# 简介
-
-本文档介绍FastDeploy中的模型SDK,在Android环境下:(1)推理操作步骤;(2)介绍模型SDK使用说明,方便开发者了解项目后二次开发。
-
-
-
-* [简介](#简介)
-
-* [系统支持说明](#系统支持说明)
-
-* [快速开始](#快速开始)
-
- * [1. 项目结构说明](#1-项目结构说明)
- * [2. APP 标准版测试](#2-app-标准版测试)
- * [2.1 扫码体验](#21-扫码体验)
- * [2.2 源码运行](#22-源码运行)
- * [3. 精简版测试](#3-精简版测试)
-
-* [SDK使用说明](#sdk使用说明)
-
- * [1. 集成指南](#1-集成指南)
- * [1.1 依赖库集成](#11-依赖库集成)
- * [1.2 添加权限](#12-添加权限)
- * [1.3 混淆规则(可选)](#13-混淆规则可选)
- * [2. API调用流程示例](#2-api调用流程示例)
- * [2.1 初始化](#21-初始化)
- * [2.2 预测图像](#22-预测图像)
-
-* [错误码](#错误码)
-
-
-
-# 系统支持说明
-
-1. Android 版本支持范围:Android 5.0(API21)<= Android < Android 10(API 29)。
-
-2. 硬件支持情况:支持 arm64-v8a 和 armeabi-v7a,暂不支持模拟器。
-* 官网测试机型:红米k30,Vivo v1981a,华为oxp-an00,华为cdy-an90,华为pct-al10,荣耀yal-al00,OPPO Reno5 Pro 5G
-3. 其他说明
-* 【图像分割类算法】(1)图像分割类算法,暂未提供实时摄像头推理功能,开发者可根据自己需要,进行安卓开发;(2)PP-Humanseg-Lite模型设计初衷为横屏视频会议等场景,本次安卓SDK仅支持竖屏场景,开发者可根据自己需要,开发横屏功能。
-* 【OCR模型】OCR任务第一次启动任务,第一张推理时间久,属于正常情况(因为涉及到模型加载、预处理等工作)。
-
-> 预测图像时运行内存不能过小,一般大于模型资源文件夹大小的3倍。
-
-# 快速开始
-
-## 1. 项目结构说明
-
-根据开发者模型、部署芯片、操作系统需要,在图像界面[飞桨开源模型](https://ai.baidu.com/easyedge/app/openSource)或[GIthub](https://github.com/PaddlePaddle/FastDeploy)中选择对应的SDK进行下载。SDK目录结构如下:
-
-```
-.EasyEdge-Android-SDK
-├── app
-│ ├── src/main
-│ │ ├── assets
-│ │ │ ├── demo
-│ │ │ │ └── conf.json # APP名字
-│ │ │ ├── infer # 模型资源文件夹,一套模型适配不同硬件、OS和部署方式
-│ │ │ │ ├── model # 模型结构文件
-│ │ │ │ ├── params # 模型参数文件
-│ │ │ │ ├── label_list.txt # 模型标签文件
-│ │ │ │ └── infer_cfg.json # 模型前后处理等配置文件
-│ │ ├── java/com.baidu.ai.edge/demo
-│ │ │ ├── infertest # 通用ARM精简版测试
-│ │ │ │ ├── TestInferClassifyTask.java # 图像分类
-│ │ │ │ ├── TestInferDetectionTask.java # 物体检测
-│ │ │ │ ├── TestInferSegmentTask.java # 实例分割
-│ │ │ │ ├── TestInferPoseTask.java # 姿态估计
-│ │ │ │ ├── TestInferOcrTask.java # OCR
-│ │ │ │ └── MainActivity.java # 精简版启动 Activity
-│ │ │ ├── MainActivity.java # Demo APP 启动 Activity
-│ │ │ ├── CameraActivity.java # 摄像头UI逻辑
-│ │ │ └── ...
-│ │ └── ...
-│ ├── libs
-│ │ ├── armeabi-v7a # v7a的依赖库
-│ │ ├── arm64-v8a # v8a的依赖库
-│ │ └── easyedge-sdk.jar # jar文件
-│ └── ...
-├── camera_ui # UI模块,包含相机逻辑
-├── README.md
-└── ... # 其他 gradle 等工程文件
-```
-
-## 2. APP 标准版测试
-
-考虑部分Android开发板没有摄像头,因此本项目开发了标准版和精简版两种。标准版会调用Android系统的摄像头,采集摄像头来进行AI模型推理;精简版在没有摄像头的开发板上运行,需要开发者准备图像。开发者根据硬件情况,选择对应的版本。
-
-### 2.1 扫码体验
-
-扫描二维码(二维码见下载网页`体验Demo`),无需任何依赖,手机上下载即可直接体验。
-
-
-
-### 2.2 源码运行
-
-(1)下载对应的SDK,解压工程。
-
-(2)打开Android Studio, 点击 "Import Project...",即:File->New-> "Import Project...", 选择解压后的目录。
-(3)手机链接Android Studio,并打开开发者模式。(不了解开发者模式的开发者,可浏览器搜索)
-(4)此时点击运行按钮,手机上会有新app安装完毕,运行效果和二维码扫描的一样。
-
-
-
-## 3. 精简版测试
-
-* 考虑部分Android开发板没有摄像头,本项目提供了精简版本,精简版忽略摄像头等UI逻辑,可兼容如无摄像头的开发板测试。
-
-* 精简版对应的测试图像路径,在代码`src/main/java/com.baidu.ai.edge/demo/TestInfer*.java`中进行了设置,开发者可以准备图像到对应路径测试,也可以修改java代码测试。
-
-* 支持以下硬件环境的精简版测试:通用ARM:图像分类、物体检测、实例分割、姿态估计、文字识别。
-
-示例代码位于 app 模块下 infertest 目录,修改 app/src/main/AndroidManifest.xml 中的启动 Activity 开启测试。
-修改前:
-
-```
-
-
-
- infertest.MainActivity
-
-
-
-
-
-```
-
-修改后:
-
-```
-
-
-
-
-
-
-
-```
-
-注意:修改后,因为没有测试数据,需要开发者准备一张测试图像,放到 `app/src/main/asserts/` 路径下,并按照`app/src/main/java/com/baidu/ai/edge/demo/infertest/TestInfer*.java`中的图像命名要求对图像进行命名。
-
-
-
-| Demo APP 检测模型运行示例 | 精简版检测模型运行示例 |
-| --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
-|  |  |
-
-
-# SDK使用说明
-
-本节介绍如何将 SDK 接入开发者的项目中使用。
-
-## 1. 集成指南
-
-步骤一:依赖库集成
-步骤二:添加必要权限
-步骤三:混淆配置(可选)
-
-### 1.1 依赖库集成
-
-A. 项目中未集成其他 jar 包和 so 文件:
-
-```
-// 1. 复制 app/libs 至项目的 app/libs 目录
-// 2. 参考 app/build.gradle 配置 NDK 可用架构和 so 依赖库目录
-
-android {
- ...
- defaultConfig {
- ndk {
- abiFilters 'armeabi-v7a', 'arm64-v8a'
- }
- }
- sourceSets {
- main {
- jniLibs.srcDirs = ['libs']
- }
- }
-}
-```
-
-B. 项目中已集成其他 jar 包,未集成 so 文件:
-
-```
-// 1. 复制 app/libs/easyedge-sdk.jar 与其他 jar 包同目录
-// 2. 复制 app/libs 下 armeabi-v7a 和 arm64-v8a 目录至 app/src/main/jniLibs 目录下
-// 3. 参考 app/build.gradle 配置 NDK 可用架构
-
-android {
- ...
- defaultConfig {
- ndk {
- abiFilters 'armeabi-v7a', 'arm64-v8a'
- }
- }
-}
-```
-
-C. 项目中已集成其他 jar 包和 so 文件:
-
-```
-// 1. 复制 app/libs/easyedge-sdk.jar 与其他 jar 包同目录
-// 2. 融合 app/libs 下 armeabi-v7a 和 arm64-v8a 下的 so 文件与其他同架构 so 文件同目录
-// 3. 参考 app/build.gradle 配置 NDK 可用架构
-
-android {
- ...
- defaultConfig {
- ndk {
- abiFilters 'armeabi-v7a', 'arm64-v8a' // 只支持 v7a 和 v8a 两种架构,有其他架构需删除
- }
- }
-}
-```
-
-### 1.2 添加权限
-
-参考 app/src/main/AndroidManifest.xml 中配置的权限。
-
-```
-
-
-
-```
-
-### 1.3 混淆规则(可选)
-
-请不要混淆 jar 包文件,参考 app/proguard-rules.pro 配置。
-
-```
--keep class com.baidu.ai.edge.core.*.*{ *; }
-```
-
-## 2. API调用流程示例
-
-以通用ARM的图像分类预测流程为例,详细说明请参考后续章节:
-
-```
-try {
- // step 1-1: 准备配置类
- InferConfig config = new InferConfig(context.getAssets(), "infer");
-
- // step 1-2: 准备预测 Manager
- InferManager manager = new InferManager(context, config, "");
-
- // step 2-1: 准备待预测的图像,必须为 Bitmap.Config.ARGB_8888 格式,一般为默认格式
- Bitmap image = getFromSomeWhere();
-
- // step 2-2: 预测图像
- List results = manager.classify(image, 0.3f);
-
- // step 3: 解析结果
- for (ClassificationResultModel resultModel : results) {
- Log.i(TAG, "labelIndex=" + resultModel.getLabelIndex()
- + ", labelName=" + resultModel.getLabel()
- + ", confidence=" + resultModel.getConfidence());
- }
-
- // step 4: 释放资源。预测完毕请及时释放资源
- manager.destroy();
-} catch (Exception e) {
- Log.e(TAG, e.getMessage());
-}
-```
-
-### 2.1 初始化
-
-**准备配置类**
-芯片与配置类对应关系:
-
-- 通用ARM:InferConfig
-
-```
-// 示例
-// 参数二为芯片对应的模型资源文件夹名称
-InferConfig config = new InferConfig(context.getAssets(), "infer");
-```
-
-**准备预测 Manager**
-芯片与 Manager 对应关系:
-
-- 通用ARM:InferManager
-
-```
-// 示例
-// 参数二为配置类对象
-// 参数三保持空字符串即可
-InferManager manager = new InferManager(context, config, "");
-```
-
-> **注意**
->
-> 1. 同一时刻只能有且唯一有效的 Manager,若要新建一个 Manager,之前创建的 Manager 需先调用 destroy() 销毁;
-> 2. Manager 的任何方法都不能在 UI 线程调用;
-> 3. Manager 的任何成员变量及方法由于线程同步问题,都必须在同一个线程中执行;
-
-### 2.2 预测图像
-
-本节介绍各种模型类型的预测函数及结果解析。
-
-> **注意**
-> 预测函数可以多次调用,但必须在同一个线程中,不支持并发
-> 预测函数中的 confidence 非必需,默认使用模型推荐值。填 0 可返回所有结果
-> 待预测的图像必须为 Bitmap.Config.ARGB_8888 格式的 Bitmap
-
-**图像分类**
-
-```
-// 预测函数
-List classify(Bitmap bitmap) throws BaseException;
-List classify(Bitmap bitmap, float confidence) throws BaseException;
-
-// 返回结果
-ClassificationResultModel
-- label: 分类标签,定义在label_list.txt中
-- labelIndex: 分类标签对应的序号
-- confidence: 置信度,0-1
-```
-
-**物体检测**
-
-```
-// 预测函数
-List detect(Bitmap bitmap) throws BaseException;
-List detect(Bitmap bitmap, float confidence) throws BaseException;
-
-// 返回结果
-DetectionResultModel
-- label: 标签,定义在label_list.txt中
-- confidence: 置信度,0-1
-- bounds: Rect,包含左上角和右下角坐标,指示物体在图像中的位置
-```
-
-**实例分割**
-
-```
-// 预测函数
-List segment(Bitmap bitmap) throws BaseException;
-List segment(Bitmap bitmap, float confidence) throws BaseException;
-
-// 返回结果
-SegmentationResultModel
-- label: 标签,定义在label_list.txt中
-- confidence: 置信度,0-1
-- lableIndex: 标签对应的序号
-- box: Rect,指示物体在图像中的位置
-- mask: byte[],表示原图大小的0,1掩码,绘制1的像素即可得到当前对象区域
-- maskLEcode: mask的游程编码
-```
-
-> 关于 maskLEcode 的解析方式可参考 [http demo](https://github.com/Baidu-AIP/EasyDL-Segmentation-Demo)
-
-**姿态估计**
-
-```
-// 预测函数
-List pose(Bitmap bitmap) throws BaseException;
-
-// 返回结果
-PoseResultModel
-- label: 标签,定义在label_list.txt中
-- confidence: 置信度,0-1
-- points: Pair, 2个点构成一条线
-```
-
-**文字识别**
-
-```
-// 预测函数
-List ocr(Bitmap bitmap) throws BaseException;
-List ocr(Bitmap bitmap, float confidence) throws BaseException;
-
-// 返回结果
-OcrResultModel
-- label: 识别出的文字
-- confidence: 置信度,0-1
-- points: List, 文字所在区域的点位
-```
-
-# 错误码
-
-| 错误码 | 错误描述 | 详细描述及解决方法 |
-| ---- | ------------------------------ | ------------------------------------------------------------------------------------ |
-| 1001 | assets 目录下用户指定的配置文件不存在 | SDK可以使用assets目录下config.json作为配置文件。如果传入的config.json不在assets目录下,则有此报错 |
-| 1002 | 用户传入的配置文件作为json解析格式不准确,如缺少某些字段 | 正常情况下,demo中的config.json不要修改 |
-| 19xx | Sdk内部错误 | 请与百度人员联系 |
-| 2001 | XxxxMANAGER 只允许一个实例 | 如已有XxxxMANAGER对象,请调用destory方法 |
-| 2002 | XxxxMANAGER 已经调用过destory方法 | 在一个已经调用destory方法的DETECT_MANAGER对象上,不允许再调用任何方法 |
-| 2003 | 传入的assets下模型文件路径为null | XxxxConfig.getModelFileAssetPath() 返回为null。由setModelFileAssetPath(null)导致 |
-| 2011 | libedge-xxxx.so 加载失败 | System.loadLibrary("edge-xxxx"); libedge-xxxx.so 没有在apk中。CPU架构仅支持armeabi-v7a arm-v8a |
-| 2012 | JNI内存错误 | heap的内存不够 |
-| 2103 | license过期 | license失效或者系统时间有异常 |
-| 2601 | assets 目录下模型文件打开失败 | 请根据报错信息检查模型文件是否存在 |
-| 2611 | 检测图片时,传递至引擎的图片二进制与长宽不符合 | 具体见报错信息 |
-| 27xx | Sdk内部错误 | 请与百度人员联系 |
-| 28xx | 引擎内部错误 | 请与百度人员联系 |
-| 29xx | Sdk内部错误 | 请与百度人员联系 |
-| 3000 | so加载错误 | 请确认所有so文件存在于apk中 |
-| 3001 | 模型加载错误 | 请确认模型放置于能被加载到的合法路径中,并确保config.json配置正确 |
-| 3002 | 模型卸载错误 | 请与百度人员联系 |
-| 3003 | 调用模型错误 | 在模型未加载正确或者so库未加载正确的情况下调用了分类接口 |
-| 50xx | 在线模式调用异常 | 请与百度人员联系 |
diff --git a/docs/Jetson-Linux-CPP-SDK-Inference.md b/docs/Jetson-Linux-CPP-SDK-Inference.md
deleted file mode 100644
index 512634a1bd..0000000000
--- a/docs/Jetson-Linux-CPP-SDK-Inference.md
+++ /dev/null
@@ -1,382 +0,0 @@
-# 简介
-
-本文档介绍FastDeploy中的模型SDK, 在**Jetson Linux C++** 环境下:(1) 图像和视频 推理部署步骤, (2)介绍推理全流程API,方便开发者了解项目后二次开发。如果开发者对Jetson的服务化部署感兴趣,可以参考[Jetson CPP Serving](./Jetson-Linux-CPP-SDK-Serving.md)文档。
-
-**注意**:OCR目前只支持**图像**推理部署。
-
-
-
-* [简介](#简介)
-
-* [环境要求](#环境要求)
-
-* [快速开始](#快速开始)
-
- * [1. 项目结构说明](#1-项目结构说明)
- * [2. 测试Demo](#2-测试demo)
- * [2.1 预测图像](#21-预测图像)
- * [2.2 预测视频流](#22-预测视频流)
-
-* [预测API流程详解](#预测api流程详解)
-
- * [1. SDK参数运行配置](#1-sdk参数运行配置)
- * [2. 初始化Predictor](#2-初始化predictor)
- * [3. 预测推理](#3-预测推理)
- * [3.1 预测图像](#31-预测图像)
- * [3.2 预测视频](#32-预测视频)
-
-* [FAQ](#faq)
-
-
-
-# 环境要求
-
-* Jetpack: 4.6,安装Jetpack,参考[NVIDIA 官网-Jetpack4.6安装指南](https://developer.nvidia.com/jetpack-sdk-46),或者参考采购的硬件厂商提供的安装方式进行安装。![]()
-
- | 序号 | 硬件 | Jetpack安装方式 | 下载链接 | ---- |
- | --- | ---------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | ---- |
- | 1 | Jetson Xavier NX | SD Card Image | [Download SD Card Image](https://developer.nvidia.com/embedded/l4t/r32_release_v6.1/jetson_xavier_nx/jetson-nx-jp46-sd-card-image.zip) | ---- |
- | 2 | Jetson Nano | SD Card Image | [Download SD Card Image](https://developer.nvidia.com/embedded/l4t/r32_release_v6.1/jeston_nano/jetson-nano-jp46-sd-card-image.zip) | ---- |
- | 3 | Jetson Nano 2GB | SD Card Image | [Download SD Card Image](https://developer.nvidia.com/embedded/l4t/r32_release_v6.1/jeston_nano_2gb/jetson-nano-2gb-jp46-sd-card-image.zip) | ---- |
- | 4 | agx xavier等 | NVIDIA SDK Manager | [Download NVIDIA SDK](https://developer.nvidia.com/nvsdk-manager) | ---- |
- | 5 | 非官方版本,如emmc版 | 参考采购的硬件公司提供的安装指南 | ---- | ---- |
-
- 注意:本项目SDK要求 `CUDA=10.2`、`cuDNN=8.2`、`TensorRT=8.0`、`gcc>=7.5` 、`cmake 在 3.0以上` ,安装 Jetpack4.6系统包后,CUDA、cuDNN、TensorRT、gcc和cmake版本就已经满足要求,无需在进行安装。
-
-# 快速开始
-
-## 1. 项目结构说明
-
-根据开发者模型、部署芯片、操作系统需要,在图像界面[飞桨开源模型](https://ai.baidu.com/easyedge/app/openSource)或[GIthub](https://github.com/PaddlePaddle/FastDeploy)中选择对应的SDK进行下载。解压后SDK目录结构如下:
-
-```
-.EasyEdge-Linux-硬件芯片
-├── RES # 模型资源文件夹,一套模型适配不同硬件、OS和部署方式
-│ ├── conf.json # Android、iOS系统APP名字需要
-│ ├── model # 模型结构文件
-│ ├── params # 模型参数文件
-│ ├── label_list.txt # 模型标签文件
-│ ├── infer_cfg.json # 模型前后处理等配置文件
-├── ReadMe.txt
-├── cpp # C++ SDK 文件结构
- └── baidu_easyedge_linux_cpp_x86_64_CPU.Generic_gcc5.4_v1.4.0_20220325.tar.gz
- ├── ReadMe.txt
- ├── bin # 可直接运行的二进制文件
- ├── include # 二次开发用的头文件
- ├── lib # 二次开发用的所依赖的库
- ├── src # 二次开发用的示例工程
- └── thirdparty # 第三方依赖
-```
-
-## 2. 测试Demo
-
-> 模型资源文件(即压缩包中的RES文件夹)默认已经打包在开发者下载的SDK包中,请先将tar包整体拷贝到具体运行的设备中,再解压缩使用。
-
-SDK中已经包含预先编译的二进制,可直接运行。以下运行示例均是`cd cpp/bin`路径下执行的结果。
-
-### 2.1 预测图像
-
-```bash
-./easyedge_image_inference {模型RES文件夹路径} {测试图片路径}
-```
-
-运行效果示例:
-
-
-
-```bash
- > ./easyedge_image_inference ../../../../RES 2.jpeg
-2019-02-13 16:46:12,659 INFO [EasyEdge] [easyedge.cpp:34] 140606189016192 Baidu EasyEdge Linux Development Kit 0.2.1(20190213)
-2019-02-13 16:46:14,083 INFO [EasyEdge] [paddlev2_edge_predictor.cpp:60] 140606189016192 Allocate graph success.
-2019-02-13 16:46:14,326 DEBUG [EasyEdge] [paddlev2_edge_predictor.cpp:143] 140606189016192 Inference costs 168 ms
-1, 1:txt_frame, p:0.994905 loc: 0.168161, 0.153654, 0.920856, 0.779621
-Done
-```
-
-### 2.2 预测视频流
-
-```
-./easyedge_video_inference {模型RES文件夹路径} {video_type} {video_src_path}
-```
-
-其中 video_type 支持三种:
-
-```
- video_type : 1 // 本地视频文件
- video_type : 2 // 摄像头的index
- video_type : 3 // 网络视频流
-```
-
-video_src_path: 为 video_type 数值所对应的本地视频路径 、本地摄像头id、网络视频流地址,如:
-
-```
- 本地视频文件: ./easyedge_video_inference {模型RES文件夹路径} 1 ~/my_video_file.mp4
- 本地摄像头: ./easyedge_video_inference {模型RES文件夹路径} 2 1 #/dev/video1
- 网络视频流: ./easyedge_video_inference {模型RES文件夹路径} 3 rtmp://192.168.x.x:8733/live/src
-```
-
-注:以上路径是假模拟路径,开发者需要根据自己实际图像/视频,准备测试图像,并填写正确的测试路径。
-
-# 预测API流程详解
-
-本章节主要结合[2.测试Demo](#4)的Demo示例介绍推理API,方便开发者学习并将运行库嵌入到开发者的程序当中,更详细的API请参考`include/easyedge/easyedge*.h`文件。图像、视频的推理包含以下3个API,如代码step注释所示:
-
-> ❗注意:
-> (1)`src`文件夹中包含完整可编译的cmake工程实例,建议开发者先行了解[cmake工程基本知识](https://cmake.org/cmake/help/latest/guide/tutorial/index.html)。
-> (2)请优先参考SDK中自带的Demo工程的使用流程和说明。遇到错误,请优先参考文件中的注释、解释、日志说明。
-
-```cpp
- // step 1: SDK配置运行参数
- EdgePredictorConfig config;
- config.model_dir = {模型文件目录};
-
- // step 2: 创建并初始化Predictor;这这里选择合适的引擎
- auto predictor = global_controller()->CreateEdgePredictor(config);
-
- // step 3-1: 预测图像
- auto img = cv::imread({图片路径});
- std::vector results;
- predictor->infer(img, results);
-
- // step 3-2: 预测视频
- std::vector results;
- FrameTensor frame_tensor;
- VideoConfig video_config;
- video_config.source_type = static_cast(video_type); // source_type 定义参考头文件 easyedge_video.h
- video_config.source_value = video_src;
- /*
- ... more video_configs, 根据需要配置video_config的各选项
- */
- auto video_decoding = CreateVideoDecoding(video_config);
- while (video_decoding->next(frame_tensor) == EDGE_OK) {
- results.clear();
- if (frame_tensor.is_needed) {
- predictor->infer(frame_tensor.frame, results);
- render(frame_tensor.frame, results, predictor->model_info().kind);
- }
- //video_decoding->display(frame_tensor); // 显示当前frame,需在video_config中开启配置
- //video_decoding->save(frame_tensor); // 存储当前frame到视频,需在video_config中开启配置
- }
-```
-
-若需自定义library search path或者gcc路径,修改对应Demo工程下的CMakeList.txt即可。
-
-## 1. SDK参数运行配置
-
-SDK的参数通过`EdgePredictorConfig::set_config`和`global_controller()->set_config`配置。本Demo 中设置了模型路径,其他参数保留默认参数。更详细的支持运行参数等,可以参考开发工具包中的头文件(`include/easyedge/easyedge_xxxx_config.h`)的详细说明。
-
-配置参数使用方法如下:
-
-```
-EdgePredictorConfig config;
-config.model_dir = {模型文件目录};
-```
-
-## 2. 初始化Predictor
-
-* 接口
-
- ```cpp
- auto predictor = global_controller()->CreateEdgePredictor(config);
- predictor->init();
- ```
-
-若返回非0,请查看输出日志排查错误原因。
-
-## 3. 预测推理
-
-### 3.1 预测图像
-
-> 在Demo中展示了预测接口infer()传入cv::Mat& image图像内容,并将推理结果赋值给std::vector& result。更多关于infer()的使用,可以根据参考`easyedge.h`头文件中的实际情况、参数说明自行传入需要的内容做推理
-
-* 接口输入
-
-```cpp
- /**
- * @brief
- * 通用接口
- * @param image: must be BGR , HWC format (opencv default)
- * @param result
- * @return
- */
- virtual int infer(cv::Mat& image, std::vector& result) = 0;
-```
-
- 图片的格式务必为opencv默认的BGR, HWC格式。
-
-* 接口返回
-
- `EdgeResultData`中可以获取对应的分类信息、位置信息。
-
-```cpp
-struct EdgeResultData {
- int index; // 分类结果的index
- std::string label; // 分类结果的label
- float prob; // 置信度
-
- // 物体检测 或 图像分割时使用:
- float x1, y1, x2, y2; // (x1, y1): 左上角, (x2, y2): 右下角; 均为0~1的长宽比例值。
-
- // 图像分割时使用:
- cv::Mat mask; // 0, 1 的mask
- std::string mask_rle; // Run Length Encoding,游程编码的mask
-};
-```
-
-*** 关于矩形坐标 ***
-
-x1 * 图片宽度 = 检测框的左上角的横坐标
-
-y1 * 图片高度 = 检测框的左上角的纵坐标
-
-x2 * 图片宽度 = 检测框的右下角的横坐标
-
-y2 * 图片高度 = 检测框的右下角的纵坐标
-
-*** 关于图像分割mask ***
-
-```
-cv::Mat mask为图像掩码的二维数组
-{
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-}
-其中1代表为目标区域,0代表非目标区域
-```
-
-*** 关于图像分割mask_rle ***
-
-该字段返回了mask的游程编码,解析方式可参考 [http demo](https://github.com/Baidu-AIP/EasyDL-Segmentation-Demo)
-
-以上字段可以参考demo文件中使用opencv绘制的逻辑进行解析
-
-### 3.2 预测视频
-
-SDK 提供了支持摄像头读取、视频文件和网络视频流的解析工具类`VideoDecoding`,此类提供了获取视频帧数据的便利函数。通过`VideoConfig`结构体可以控制视频/摄像头的解析策略、抽帧策略、分辨率调整、结果视频存储等功能。对于抽取到的视频帧可以直接作为SDK infer 接口的参数进行预测。
-
-* 接口输入
-
-class`VideoDecoding`:
-
-```
- /**
- * @brief 获取输入源的下一帧
- * @param frame_tensor
- * @return
- */
- virtual int next(FrameTensor &frame_tensor) = 0;
-
- /**
- * @brief 显示当前frame_tensor中的视频帧
- * @param frame_tensor
- * @return
- */
- virtual int display(const FrameTensor &frame_tensor) = 0;
-
- /**
- * @brief 将当前frame_tensor中的视频帧写为本地视频文件
- * @param frame_tensor
- * @return
- */
- virtual int save(FrameTensor &frame_tensor) = 0;
-
- /**
- * @brief 获取视频的fps属性
- * @return
- */
- virtual int get_fps() = 0;
- /**
- * @brief 获取视频的width属性
- * @return
- */
- virtual int get_width() = 0;
-
- /**
- * @brief 获取视频的height属性
- * @return
- */
- virtual int get_height() = 0;
-```
-
-struct `VideoConfig`
-
-```
-/**
- * @brief 视频源、抽帧策略、存储策略的设置选项
- */
-struct VideoConfig {
- SourceType source_type; // 输入源类型
- std::string source_value; // 输入源地址,如视频文件路径、摄像头index、网络流地址
- int skip_frames{0}; // 设置跳帧,每隔skip_frames帧抽取一帧,并把该抽取帧的is_needed置为true
- int retrieve_all{false}; // 是否抽取所有frame以便于作为显示和存储,对于不满足skip_frames策略的frame,把所抽取帧的is_needed置为false
- int input_fps{0}; // 在采取抽帧之前设置视频的fps
- Resolution resolution{Resolution::kAuto}; // 采样分辨率,只对camera有效
-
- bool enable_display{false}; // 默认不支持。
- std::string window_name{"EasyEdge"};
- bool display_all{false}; // 是否显示所有frame,若为false,仅显示根据skip_frames抽取的frame
-
- bool enable_save{false};
- std::string save_path; // frame存储为视频文件的路径
- bool save_all{false}; // 是否存储所有frame,若为false,仅存储根据skip_frames抽取的frame
-
- std::map conf;
-};
-```
-
-| 序号 | 字段 | 含义 |
-| --- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
-| 1 | `source_type` | 输入源类型,支持视频文件、摄像头、网络视频流三种,值分别为1、2、3 |
-| 2 | `source_value` | 若`source_type`为视频文件,该值为指向视频文件的完整路径;若`source_type`为摄像头,该值为摄像头的index,如对于`/dev/video0`的摄像头,则index为0;若`source_type`为网络视频流,则为该视频流的完整地址。 |
-| 3 | `skip_frames` | 设置跳帧,每隔skip_frames帧抽取一帧,并把该抽取帧的is_needed置为true,标记为is_needed的帧是用来做预测的帧。反之,直接跳过该帧,不经过预测。 |
-| 4 | `retrieve_all` | 若置该项为true,则无论是否设置跳帧,所有的帧都会被抽取返回,以作为显示或存储用。 |
-| 5 | `input_fps` | 用于抽帧前设置fps |
-| 6 | `resolution` | 设置摄像头采样的分辨率,其值请参考`easyedge_video.h`中的定义,注意该分辨率调整仅对输入源为摄像头时有效 |
-| 7 | `conf` | 高级选项。部分配置会通过该map来设置 |
-
-*** 注意:***
-
-1. `VideoConfig`不支持`display`功能。如果需要使用`VideoConfig`的`display`功能,需要自行编译带有GTK选项的OpenCV。
-
-2. 使用摄像头抽帧时,如果通过`resolution`设置了分辨率调整,但是不起作用,请添加如下选项:
-
- ```
- video_config.conf["backend"] = "2";
- ```
-
-3.部分设备上的CSI摄像头尚未兼容,如遇到问题,可以通过工单、QQ交流群或微信交流群反馈。
-
-具体接口调用流程,可以参考SDK中的`demo_video_inference`。
-
-# FAQ
-
-1. 如何处理一些 undefined reference / error while loading shared libraries?
-
- > 如:./easyedge_demo: error while loading shared libraries: libeasyedge.so.1: cannot open shared object file: No such file or directory
-
- 遇到该问题时,请找到具体的库的位置,设置LD_LIBRARY_PATH;或者安装缺少的库。
-
- > 示例一:libverify.so.1: cannot open shared object file: No such file or directory
- > 链接找不到libveirfy.so文件,一般可通过 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../lib 解决(实际冒号后面添加的路径以libverify.so文件所在的路径为准)
-
- > 示例二:libopencv_videoio.so.4.5: cannot open shared object file: No such file or directory
- > 链接找不到libopencv_videoio.so文件,一般可通过 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../thirdparty/opencv/lib 解决(实际冒号后面添加的路径以libopencv_videoio.so所在路径为准)
-
- > 示例三:GLIBCXX_X.X.X not found
- > 链接无法找到glibc版本,请确保系统gcc版本>=SDK的gcc版本。升级gcc/glibc可以百度搜索相关文献。
-
-2. 运行二进制时,提示 libverify.so cannot open shared object file
-
- 可能cmake没有正确设置rpath, 可以设置LD_LIBRARY_PATH为sdk的lib文件夹后,再运行:
-
- ```bash
- LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib ./easyedge_demo
- ```
-
-3. 编译时报错:file format not recognized
-
- 可能是因为在复制SDK时文件信息丢失。请将整个压缩包复制到目标设备中,再解压缩、编译。
diff --git a/docs/Jetson-Linux-CPP-SDK-Serving.md b/docs/Jetson-Linux-CPP-SDK-Serving.md
deleted file mode 100644
index 87b75ac098..0000000000
--- a/docs/Jetson-Linux-CPP-SDK-Serving.md
+++ /dev/null
@@ -1,293 +0,0 @@
-# 简介
-
-本文档介绍FastDeploy中的模型SDK,在**Jetson Linux C++** 环境下:(1) **服务化**推理部署步骤,(2)介绍推理全流程API,方便开发者了解项目后二次开发。如果开发者对Jetson图像/视频部署感兴趣,可以参考[Jetson CPP Inference](./Jetson-Linux-CPP-SDK-Inference.md)文档。
-
-**注意**:OCR目前不支持服务化推理部署。
-
-
-
-* [简介](#简介)
-
-* [环境准备](#环境准备)
-
-* [快速开始](#快速开始)
-
- * [1. 项目结构说明](#1-项目结构说明)
- * [2. 测试 HTTP Demo](#2-测试-http-demo)
- * [2.1 启动HTTP预测服务](#21-启动http预测服务)
-
-* [HTTP API介绍](#http-api介绍)
-
- * [1. 开启http服务](#1-开启http服务)
- * [2. 请求http服务](#2-请求http服务)
- * [2.1 http 请求方式一:不使用图片base64格式](#21-http-请求方式一不使用图片base64格式)
- * [2.2 http 请求方法二:使用图片base64格式](#22-http-请求方法二使用图片base64格式)
- * [3. http 返回数据](#3-http-返回数据)
-
-* [FAQ](#faq)
-
-
-
-# 环境准备
-
-* Jetpack: 4.6 。安装Jetpack 4.6,参考[NVIDIA 官网-Jetpack4.6安装指南](https://developer.nvidia.com/jetpack-sdk-46),或者参考采购的硬件厂商提供的安装方式进行安装。![]()
-
- | 序号 | 硬件 | Jetpack安装方式 | 下载链接 | ---- |
- | --- | ---------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | ---- |
- | 1 | Jetson Xavier NX | SD Card Image | [Download SD Card Image](https://developer.nvidia.com/embedded/l4t/r32_release_v6.1/jetson_xavier_nx/jetson-nx-jp46-sd-card-image.zip) | ---- |
- | 2 | Jetson Nano | SD Card Image | [Download SD Card Image](https://developer.nvidia.com/embedded/l4t/r32_release_v6.1/jeston_nano/jetson-nano-jp46-sd-card-image.zip) | ---- |
- | 3 | Jetson Nano 2GB | SD Card Image | [Download SD Card Image](https://developer.nvidia.com/embedded/l4t/r32_release_v6.1/jeston_nano_2gb/jetson-nano-2gb-jp46-sd-card-image.zip) | ---- |
- | 4 | agx xavier等 | NVIDIA SDK Manager | [Download NVIDIA SDK](https://developer.nvidia.com/nvsdk-manager) | ---- |
- | 5 | 非官方版本,如emmc版 | 参考采购的硬件公司提供的安装指南 | ---- | ---- |
-
- 注意:本项目SDK要求 `CUDA=10.2`、`cuDNN=8.2`、`TensorRT=8.0`、`gcc>=7.5` 、`cmake 在 3.0以上` ,安装 Jetpack4.6系统包后,CUDA、cuDNN、TensorRT、gcc和cmake版本就已经满足要求,无需在进行安装。
-
-# 快速开始
-
-## 1. 项目结构说明
-
-根据开发者模型、部署芯片、操作系统需要,在图像界面[飞桨开源模型](https://ai.baidu.com/easyedge/app/openSource)或[GIthub](https://github.com/PaddlePaddle/FastDeploy)中选择对应的SDK进行下载。解压后SDK目录结构如下:
-
-```
-.EasyEdge-Linux-硬件芯片
-├── RES # 模型资源文件夹,一套模型适配不同硬件、OS和部署方式
-│ ├── conf.json # Android、iOS系统APP名字需要
-│ ├── model # 模型结构文件
-│ ├── params # 模型参数文件
-│ ├── label_list.txt # 模型标签文件
-│ ├── infer_cfg.json # 模型前后处理等配置文件
-├── ReadMe.txt
-├── cpp # C++ SDK 文件结构
- └── baidu_easyedge_linux_cpp_x86_64_CPU.Generic_gcc5.4_v1.4.0_20220325.tar.gz
- ├── ReadMe.txt
- ├── bin # 可直接运行的二进制文件
- ├── include # 二次开发用的头文件
- ├── lib # 二次开发用的所依赖的库
- ├── src # 二次开发用的示例工程
- └── thirdparty # 第三方依赖
-```
-
-## 2. 测试 HTTP Demo
-
-> 模型资源文件(即压缩包中的RES文件夹)默认已经打包在开发者下载的SDK包中,请先将tar包整体拷贝到具体运行的设备中,再解压缩使用。
-
-SDK中已经包含预先编译的二进制,可直接运行。以下运行示例均是`cd cpp/bin`路径下执行的结果。
-
-### 2.1 启动HTTP预测服务
-
-```
-./easyedge_serving {模型RES文件夹路径}
-```
-
-启动后,日志中会显示如下设备IP和24401端口号信息:
-
-```
-HTTP is now serving at 0.0.0.0:24401
-```
-
-此时,开发者可以打开浏览器,输入链接地址`http://0.0.0.0:24401`(这里的`设备IP和24401端口号`根据开发者电脑显示修改),选择图片来进行测试。
-
-
-
-同时,可以调用HTTP接口来访问服务,具体参考下文的[二次开发](#10)接口说明。
-
-# HTTP API介绍
-
-本章节主要结合[2.1 HTTP Demo]()的API介绍,方便开发者学习并将运行库嵌入到开发者的程序当中,更详细的API请参考`include/easyedge/easyedge*.h`文件。http服务包含服务端和客户端,目前支持的能力包括以下几种方式,Demo中提供了不使用图片base格式的`方式一:浏览器请求的方式`,其他几种方式开发者根据个人需要,选择开发。
-
-## 1. 开启http服务
-
-http服务的启动可直接使用`bin/easyedge_serving`,或参考`src/demo_serving.cpp`文件修改相关逻辑
-
-```cpp
- /**
- * @brief 开启一个简单的demo http服务。
- * 该方法会block直到收到sigint/sigterm。
- * http服务里,图片的解码运行在cpu之上,可能会降低推理速度。
- * @tparam ConfigT
- * @param config
- * @param host
- * @param port
- * @param service_id service_id user parameter, uri '/get/service_id' will respond this value with 'text/plain'
- * @param instance_num 实例数量,根据内存/显存/时延要求调整
- * @return
- */
- template
- int start_http_server(
- const ConfigT &config,
- const std::string &host,
- int port,
- const std::string &service_id,
- int instance_num = 1);
-```
-
-## 2. 请求http服务
-
-> 开发者可以打开浏览器,`http://{设备ip}:24401`,选择图片来进行测试。
-
-### 2.1 http 请求方式一:不使用图片base64格式
-
-URL中的get参数:
-
-| 参数 | 说明 | 默认值 |
-| --------- | --------- | ---------------- |
-| threshold | 阈值过滤, 0~1 | 如不提供,则会使用模型的推荐阈值 |
-
-HTTP POST Body即为图片的二进制内容(无需base64, 无需json)
-
-Python请求示例
-
-```Python
-import requests
-
-with open('./1.jpg', 'rb') as f:
- img = f.read()
- result = requests.post(
- 'http://127.0.0.1:24401/',
- params={'threshold': 0.1},
- data=img).json()
-```
-
-### 2.2 http 请求方法二:使用图片base64格式
-
-HTTP方法:POST
-Header如下:
-
-| 参数 | 值 |
-| ------------ | ---------------- |
-| Content-Type | application/json |
-
-**Body请求填写**:
-
-* 分类网络:
- body 中请求示例
-
- ```
- {
- "image": ""
- "top_num": 5
- }
- ```
-
- body中参数详情
-
-| 参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
-| ------- | ---- | ------ | ----- | ----------------------------------------------------------------------------------- |
-| image | 是 | string | - | 图像数据,base64编码,要求base64图片编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 **注意去掉头部** |
-| top_num | 否 | number | - | 返回分类数量,不填该参数,则默认返回全部分类结果 |
-
-* 检测和分割网络:
- Body请求示例:
-
- ```
- {
- "image": ""
- }
- ```
-
- body中参数详情:
-
-| 参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
-| --------- | ---- | ------ | ----- | ----------------------------------------------------------------------------------- |
-| image | 是 | string | - | 图像数据,base64编码,要求base64图片编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 **注意去掉头部** |
-| threshold | 否 | number | - | 默认为推荐阈值,也可自行根据需要进行设置 |
-
-Python请求示例:
-
-```Python
-import base64
-import requests
-def main():
- with open("图像路径", 'rb') as f:
- result = requests.post("http://{服务ip地址}:24401/", json={
- "image": base64.b64encode(f.read()).decode("utf8")
- })
- # print(result.request.body)
- # print(result.request.headers)
- print(result.content)
-
-if __name__ == '__main__':
- main()
-```
-
-## 3. http 返回数据
-
-| 字段 | 类型说明 | 其他 |
-| ---------- | ------ | ------------------------------------ |
-| error_code | Number | 0为成功,非0参考message获得具体错误信息 |
-| results | Array | 内容为具体的识别结果。其中字段的具体含义请参考`预测图像-返回格式`一节 |
-| cost_ms | Number | 预测耗时ms,不含网络交互时间 |
-
-返回示例
-
-```json
-{
- "cost_ms": 52,
- "error_code": 0,
- "results": [
- {
- "confidence": 0.94482421875,
- "index": 1,
- "label": "IronMan",
- "x1": 0.059185408055782318,
- "x2": 0.18795496225357056,
- "y1": 0.14762254059314728,
- "y2": 0.52510076761245728,
- "mask": "...", // 图像分割模型字段
- "trackId": 0, // 目标追踪模型字段
- },
-
- ]
-}
-```
-
-*** 关于矩形坐标 ***
-
-x1 * 图片宽度 = 检测框的左上角的横坐标
-
-y1 * 图片高度 = 检测框的左上角的纵坐标
-
-x2 * 图片宽度 = 检测框的右下角的横坐标
-
-y2 * 图片高度 = 检测框的右下角的纵坐标
-
-*** 关于分割模型 ***
-
-其中,mask为分割模型的游程编码,解析方式可参考 [http demo](https://github.com/Baidu-AIP/EasyDL-Segmentation-Demo)
-
-# FAQ
-
-1. 如何处理一些 undefined reference / error while loading shared libraries?
-
-> 如:./easyedge_demo: error while loading shared libraries: libeasyedge.so.1: cannot open shared object file: No such file or directory
-
-遇到该问题时,请找到具体的库的位置,设置LD_LIBRARY_PATH;或者安装缺少的库。
-
-> 示例一:libverify.so.1: cannot open shared object file: No such file or directory
-> 链接找不到libveirfy.so文件,一般可通过 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../lib 解决(实际冒号后面添加的路径以libverify.so文件所在的路径为准)
-
-> 示例二:libopencv_videoio.so.4.5: cannot open shared object file: No such file or directory
-> 链接找不到libopencv_videoio.so文件,一般可通过 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../thirdparty/opencv/lib 解决(实际冒号后面添加的路径以libopencv_videoio.so所在路径为准)
-
-> 示例三:GLIBCXX_X.X.X not found
-> 链接无法找到glibc版本,请确保系统gcc版本>=SDK的gcc版本。升级gcc/glibc可以百度搜索相关文献。
-
-2. 使用libcurl请求http服务时,速度明显变慢
-
-这是因为libcurl请求continue导致server等待数据的问题,添加空的header即可
-
-```bash
-headers = curl_slist_append(headers, "Expect:");
-```
-
-3. 运行二进制时,提示 libverify.so cannot open shared object file
-
-可能cmake没有正确设置rpath, 可以设置LD_LIBRARY_PATH为sdk的lib文件夹后,再运行:
-
-```bash
-LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib ./easyedge_demo
-```
-
-4. 编译时报错:file format not recognized
-
-可能是因为在复制SDK时文件信息丢失。请将整个压缩包复制到目标设备中,再解压缩、编译。
diff --git a/docs/Linux-CPP-SDK-Inference.md b/docs/Linux-CPP-SDK-Inference.md
deleted file mode 100644
index c8e4eb200a..0000000000
--- a/docs/Linux-CPP-SDK-Inference.md
+++ /dev/null
@@ -1,412 +0,0 @@
-# 简介
-
-本文档介绍FastDeploy中的模型SDK,在 **Intel X86-CPU/ NVIDIA GPU、Linux** 操作系统下的C++ :(1)图像和视频的推理部署步骤,(2)介绍推理全流程API,方便了解项目后二次开发。如果对Linux操作系统下的 Python部署感兴趣,请参考[Linux Python环境下的推理部署](./Linux-Python-SDK-Inference.md)文档。
-
-
-
-* [简介](#简介)
-
-* [环境准备](#环境准备)
-
- * [1. 硬件支持](#1-硬件支持)
- * [2. 软件环境](#2-软件环境)
-
-* [快速开始](#快速开始)
-
- * [1. 项目结构说明](#1-项目结构说明)
- * [2. 测试Demo](#2-测试demo)
- * [2.1. 预测图像](#21-预测图像)
- * [2.2. 预测视频流](#22-预测视频流)
- * [3. 编译Demo](#3-编译demo)
-
-* [预测API流程详解](#预测api流程详解)
-
- * [1. SDK参数运行配置](#1-sdk参数运行配置)
- * [2. 初始化Predictor](#2-初始化predictor)
- * [3. 预测推理](#3-预测推理)
- * [3.1 预测图像](#31-预测图像)
- * [3.2 预测视频](#32-预测视频)
-
-* [FAQ](#faq)
-
-
-
-# 环境准备
-
-## 1.硬件支持
-
-* NVIDIA GPU: x86_64
- * cuda支持版本:CUDA10.0/10.1/10.2 + cuDNN 7 (cuDNN版本>=7.6.5)
- * cuda支持版本:CUDA11.0 + cuDNN v8.0.4
-* CPU:Intel x86_64
-
-## 2. 软件环境
-
-1.运行二进制文件-环境要求
-
-* gcc: 5.4 以上 (GLIBCXX_3.4.22)
- * Linux下查看gcc版本命名(可能因系统差异命令会不同):`gcc --version`;
- * Linux下C++基础库GLIBCXX的命令(可能因系统差异路径会有不同,可检测自己环境下的情况):`strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX`
-* glibc:2.23以上
- * Linux查看命令:`ldd --version`
-
-2.二次开发编译-环境要求
-
-编译源代码时,除了gcc、GLIBCXX、glibc满足`1.运行二进制文件-环境要求`外,还需要cmake满足要求。
-
-* cmake: 3.0 以上
-
- * Linux查看命令:`cmake --version`
-
-# 快速开始
-
-## 1. 项目结构说明
-
-根据开发者模型、部署芯片、操作系统需要,在图像界面[飞桨开源模型](https://ai.baidu.com/easyedge/app/openSource)或[GIthub](https://github.com/PaddlePaddle/FastDeploy)中选择对应的SDK进行下载。SDK目录结构如下:
-
-```
-.EasyEdge-Linux-硬件芯片
-├── RES # 模型资源文件夹,一套模型适配不同硬件、OS和部署方式
-│ ├── conf.json # Android、iOS系统APP名字需要
-│ ├── model # 模型结构文件
-│ ├── params # 模型参数文件
-│ ├── label_list.txt # 模型标签文件
-│ ├── infer_cfg.json # 模型前后处理等配置文件
-├── ReadMe.txt
-├── cpp # C++ SDK 文件结构
- └── baidu_easyedge_linux_cpp_x86_64_CPU.Generic_gcc5.4_v1.4.0_20220325.tar.gz
- ├── ReadMe.txt
- ├── bin # 可直接运行的二进制文件
- ├── include # 二次开发用的头文件
- ├── lib # 二次开发用的所依赖的库
- ├── src # 二次开发用的示例工程
- └── thirdparty # 第三方依赖
-└── python # Python SDK 文件
-```
-
-## 2. 测试Demo
-
-**注意**: OCR算法目前没有提供
-
-> 模型资源文件(即压缩包中的RES文件夹)默认已经打包在开发者下载的SDK包中,请先将tar包整体拷贝到具体运行的设备中,再解压缩使用。
-
-SDK中已经包含预先编译的二进制,可直接运行。以下运行示例均是`cd cpp/bin`路径下执行的结果。
-
-### 2.1. 预测图像
-
-```bash
-./easyedge_image_inference {模型RES文件夹路径} {测试图片路径}
-```
-
-运行效果示例:
-
-
-
-```bash
- > ./easyedge_image_inference ../../../../RES 2.jpeg
-2019-02-13 16:46:12,659 INFO [EasyEdge] [easyedge.cpp:34] 140606189016192 Baidu EasyEdge Linux Development Kit 0.2.1(20190213)
-2019-02-13 16:46:14,083 INFO [EasyEdge] [paddlev2_edge_predictor.cpp:60] 140606189016192 Allocate graph success.
-2019-02-13 16:46:14,326 DEBUG [EasyEdge] [paddlev2_edge_predictor.cpp:143] 140606189016192 Inference costs 168 ms
-1, 1:txt_frame, p:0.994905 loc: 0.168161, 0.153654, 0.920856, 0.779621
-Done
-```
-
-### 2.2. 预测视频流
-
-```
-./easyedge_video_inference {模型RES文件夹路径} {video_type} {video_src_path}
-```
-
-其中 video_type 支持三种:
-
-```
- video_type : 1 // 本地视频文件
- video_type : 2 // 摄像头的index
- video_type : 3 // 网络视频流
-```
-
-video_src_path: 为 video_type 数值所对应的本地视频路径 、本地摄像头id、网络视频流地址,如:
-
-```
- 本地视频文件: ./easyedge_video_inference {模型RES文件夹路径} 1 ~/my_video_file.mp4
- 本地摄像头: ./easyedge_video_inference {模型RES文件夹路径} 2 1 #/dev/video1
- 网络视频流: ./easyedge_video_inference {模型RES文件夹路径} 3 rtmp://192.168.x.x:8733/live/src
-```
-
-注:以上路径是假模拟路径,开发者需要根据自己实际图像/视频,准备测试图像,并填写正确的测试路径。
-
-## 3. 编译Demo
-
-通过[项目结构说明](#3)了解到,`bin`路径下的可执行文件 由`src`下的对应文件编译得到。 通过以下命令,即可完成`src`下的源码编译。
-
-```
-cd src
-mkdir build && cd build
-cmake .. && make
-```
-
-至此,会在build文件夹下生成编译好的可执行文件,如图像推理的二进制文件:`build/demo_image_inference/easyedge_image_inference`。
-
-# 预测API流程详解
-
-本章节主要结合[2.测试Demo](#4)的Demo示例介绍推理API,方便开发者学习并将运行库嵌入到开发者的程序当中,更详细的API请参考`include/easyedge/easyedge*.h`文件。图像、视频的推理包含以下3个API,查看下面的cpp代码中的step注释说明。
-
-> ❗注意:
-> (1)`src`文件夹中包含完整可编译的cmake工程实例,建议开发者先行了解[cmake工程基本知识](https://cmake.org/cmake/help/latest/guide/tutorial/index.html)。
-> (2)请优先参考SDK中自带的Demo工程的使用流程和说明。遇到错误,请优先参考文件中的注释、解释、日志说明。
-
-```cpp
- // step 1: SDK配置运行参数
- EdgePredictorConfig config;
- config.model_dir = {模型文件目录};
-
- // step 2: 创建并初始化Predictor;这这里选择合适的引擎
- auto predictor = global_controller()->CreateEdgePredictor(config);
-
- // step 3-1: 预测图像
- auto img = cv::imread({图片路径});
- std::vector results;
- predictor->infer(img, results);
-
- // step 3-2: 预测视频
- std::vector results;
- FrameTensor frame_tensor;
- VideoConfig video_config;
- video_config.source_type = static_cast(video_type); // source_type 定义参考头文件 easyedge_video.h
- video_config.source_value = video_src;
- /*
- ... more video_configs, 根据需要配置video_config的各选项
- */
- auto video_decoding = CreateVideoDecoding(video_config);
- while (video_decoding->next(frame_tensor) == EDGE_OK) {
- results.clear();
- if (frame_tensor.is_needed) {
- predictor->infer(frame_tensor.frame, results);
- render(frame_tensor.frame, results, predictor->model_info().kind);
- }
- //video_decoding->display(frame_tensor); // 显示当前frame,需在video_config中开启配置
- //video_decoding->save(frame_tensor); // 存储当前frame到视频,需在video_config中开启配置
- }
-```
-
-若需自定义library search path或者gcc路径,修改对应Demo工程下的CMakeList.txt即可。
-
-## 1. SDK参数运行配置
-
-SDK的参数通过`EdgePredictorConfig::set_config`和`global_controller()->set_config`配置。本Demo 中设置了模型路径,其他参数保留默认参数。更详细的支持运行参数等,可以参考开发工具包中的头文件(`include/easyedge/easyedge_xxxx_config.h`)的详细说明。
-
-配置参数使用方法如下:
-
-```
-EdgePredictorConfig config;
-config.model_dir = {模型文件目录};
-```
-
-## 2. 初始化Predictor
-
-* 接口
-
- ```cpp
- auto predictor = global_controller()->CreateEdgePredictor(config);
- predictor->init();
- ```
-
-若返回非0,请查看输出日志排查错误原因。
-
-## 3. 预测推理
-
-### 3.1 预测图像
-
-> 在Demo中展示了预测接口infer()传入cv::Mat& image图像内容,并将推理结果赋值给std::vector& result。更多关于infer()的使用,可以根据参考`easyedge.h`头文件中的实际情况、参数说明自行传入需要的内容做推理
-
-* 接口输入
-
-```cpp
- /**
- * @brief
- * 通用接口
- * @param image: must be BGR , HWC format (opencv default)
- * @param result
- * @return
- */
- virtual int infer(cv::Mat& image, std::vector& result) = 0;
-```
-
- 图片的格式务必为opencv默认的BGR, HWC格式。
-
-* 接口返回
-
- `EdgeResultData`中可以获取对应的分类信息、位置信息。
-
-```cpp
-struct EdgeResultData {
- int index; // 分类结果的index
- std::string label; // 分类结果的label
- float prob; // 置信度
-
- // 物体检测 或 图像分割时使用:
- float x1, y1, x2, y2; // (x1, y1): 左上角, (x2, y2): 右下角; 均为0~1的长宽比例值。
-
- // 图像分割时使用:
- cv::Mat mask; // 0, 1 的mask
- std::string mask_rle; // Run Length Encoding,游程编码的mask
-};
-```
-
-*** 关于矩形坐标 ***
-
-x1 * 图片宽度 = 检测框的左上角的横坐标
-
-y1 * 图片高度 = 检测框的左上角的纵坐标
-
-x2 * 图片宽度 = 检测框的右下角的横坐标
-
-y2 * 图片高度 = 检测框的右下角的纵坐标
-
-*** 关于图像分割mask ***
-
-```
-cv::Mat mask为图像掩码的二维数组
-{
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-}
-其中1代表为目标区域,0代表非目标区域
-```
-
-*** 关于图像分割mask_rle ***
-
-该字段返回了mask的游程编码,解析方式可参考 [http demo](https://github.com/Baidu-AIP/EasyDL-Segmentation-Demo)
-
-以上字段可以参考demo文件中使用opencv绘制的逻辑进行解析
-
-### 3.2 预测视频
-
-SDK 提供了支持摄像头读取、视频文件和网络视频流的解析工具类`VideoDecoding`,此类提供了获取视频帧数据的便利函数。通过`VideoConfig`结构体可以控制视频/摄像头的解析策略、抽帧策略、分辨率调整、结果视频存储等功能。对于抽取到的视频帧可以直接作为SDK infer 接口的参数进行预测。
-
-* 接口输入
-
-class`VideoDecoding`:
-
-```
- /**
- * @brief 获取输入源的下一帧
- * @param frame_tensor
- * @return
- */
- virtual int next(FrameTensor &frame_tensor) = 0;
-
- /**
- * @brief 显示当前frame_tensor中的视频帧
- * @param frame_tensor
- * @return
- */
- virtual int display(const FrameTensor &frame_tensor) = 0;
-
- /**
- * @brief 将当前frame_tensor中的视频帧写为本地视频文件
- * @param frame_tensor
- * @return
- */
- virtual int save(FrameTensor &frame_tensor) = 0;
-
- /**
- * @brief 获取视频的fps属性
- * @return
- */
- virtual int get_fps() = 0;
- /**
- * @brief 获取视频的width属性
- * @return
- */
- virtual int get_width() = 0;
-
- /**
- * @brief 获取视频的height属性
- * @return
- */
- virtual int get_height() = 0;
-```
-
-struct `VideoConfig`
-
-```
-/**
- * @brief 视频源、抽帧策略、存储策略的设置选项
- */
-struct VideoConfig {
- SourceType source_type; // 输入源类型
- std::string source_value; // 输入源地址,如视频文件路径、摄像头index、网络流地址
- int skip_frames{0}; // 设置跳帧,每隔skip_frames帧抽取一帧,并把该抽取帧的is_needed置为true
- int retrieve_all{false}; // 是否抽取所有frame以便于作为显示和存储,对于不满足skip_frames策略的frame,把所抽取帧的is_needed置为false
- int input_fps{0}; // 在采取抽帧之前设置视频的fps
- Resolution resolution{Resolution::kAuto}; // 采样分辨率,只对camera有效
-
- bool enable_display{false}; // 默认不支持。
- std::string window_name{"EasyEdge"};
- bool display_all{false}; // 是否显示所有frame,若为false,仅显示根据skip_frames抽取的frame
-
- bool enable_save{false};
- std::string save_path; // frame存储为视频文件的路径
- bool save_all{false}; // 是否存储所有frame,若为false,仅存储根据skip_frames抽取的frame
-
- std::map conf;
-};
-```
-
-| 序号 | 字段 | 含义 |
-| --- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
-| 1 | `source_type` | 输入源类型,支持视频文件、摄像头、网络视频流三种,值分别为1、2、3 |
-| 2 | `source_value` | 若`source_type`为视频文件,该值为指向视频文件的完整路径;若`source_type`为摄像头,该值为摄像头的index,如对于`/dev/video0`的摄像头,则index为0;若`source_type`为网络视频流,则为该视频流的完整地址。 |
-| 3 | `skip_frames` | 设置跳帧,每隔skip_frames帧抽取一帧,并把该抽取帧的is_needed置为true,标记为is_needed的帧是用来做预测的帧。反之,直接跳过该帧,不经过预测。 |
-| 4 | `retrieve_all` | 若置该项为true,则无论是否设置跳帧,所有的帧都会被抽取返回,以作为显示或存储用。 |
-| 5 | `input_fps` | 用于抽帧前设置fps |
-| 6 | `resolution` | 设置摄像头采样的分辨率,其值请参考`easyedge_video.h`中的定义,注意该分辨率调整仅对输入源为摄像头时有效 |
-| 7 | `conf` | 高级选项。部分配置会通过该map来设置 |
-
-*** 注意:***
-
-1. `VideoConfig`不支持`display`功能。如果需要使用`VideoConfig`的`display`功能,需要自行编译带有GTK选项的OpenCV。
-
-2. 使用摄像头抽帧时,如果通过`resolution`设置了分辨率调整,但是不起作用,请添加如下选项:
-
- ```
- video_config.conf["backend"] = "2";
- ```
-
-3.部分设备上的CSI摄像头尚未兼容,如遇到问题,可以通过工单、QQ交流群或微信交流群反馈。
-
-具体接口调用流程,可以参考SDK中的`demo_video_inference`。
-
-# FAQ
-
-1. 如何处理一些 undefined reference / error while loading shared libraries?
-
- > 如:./easyedge_demo: error while loading shared libraries: libeasyedge.so.1: cannot open shared object file: No such file or directory
-
- 遇到该问题时,请找到具体的库的位置,设置LD_LIBRARY_PATH;或者安装缺少的库。
-
- > 示例一:libverify.so.1: cannot open shared object file: No such file or directory
- > 链接找不到libveirfy.so文件,一般可通过 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../lib 解决(实际冒号后面添加的路径以libverify.so文件所在的路径为准)
-
- > 示例二:libopencv_videoio.so.4.5: cannot open shared object file: No such file or directory
- > 链接找不到libopencv_videoio.so文件,一般可通过 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../thirdparty/opencv/lib 解决(实际冒号后面添加的路径以libopencv_videoio.so所在路径为准)
-
- > 示例三:GLIBCXX_X.X.X not found
- > 链接无法找到glibc版本,请确保系统gcc版本>=SDK的gcc版本。升级gcc/glibc可以百度搜索相关文献。
-
-2. 运行二进制时,提示 libverify.so cannot open shared object file
-
- 可能cmake没有正确设置rpath, 可以设置LD_LIBRARY_PATH为sdk的lib文件夹后,再运行:
-
- ```bash
- LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib ./easyedge_demo
- ```
-
- 3. 编译时报错:file format not recognized
-
- 可能是因为在复制SDK时文件信息丢失。请将整个压缩包复制到目标设备中,再解压缩、编译。
diff --git a/docs/Linux-CPP-SDK-Serving.md b/docs/Linux-CPP-SDK-Serving.md
deleted file mode 100644
index 2e585fe541..0000000000
--- a/docs/Linux-CPP-SDK-Serving.md
+++ /dev/null
@@ -1,329 +0,0 @@
-# 简介
-
-本文档介绍FastDeploy中的模型SDK,在**X86 CPU/ NVIDIA GPU、Linux操作系统** 的C++环境:(1)HTTP服务化推理部署步骤,(2)介绍推理全流程API,方便开发者了解项目后二次开发。
-如果开发者对Python语言的相关能力感兴趣,可以参考Linux Python请参考[Linux Python环境下的推理部署](./Linux-Python-SDK-Serving.md)文档。
-
-**【注意】**:OCR Demo 暂不支持服务化部署。
-
-
-
-* [简介](#简介)
-
-* [安装准备](#安装准备)
-
- * [1. 硬件支持](#1-硬件支持)
- * [2. 软件环境](#2-软件环境)
-
-* [快速开始](#快速开始)
-
- * [1. 项目结构说明](#1-项目结构说明)
- * [2. 测试 HTTP Demo](#2-测试-http-demo)
- * [2.1 启动HTTP预测服务](#21-启动http预测服务)
- * [3. 编译Demo](#3-编译demo)
-
-* [HTTP API流程详解](#http-api流程详解)
-
- * [1. 开启http服务](#1-开启http服务)
- * [2. 请求http服务](#2-请求http服务)
- * [2.1 http 请求方式一:不使用图片base64格式](#21-http-请求方式一不使用图片base64格式)
- * [2.2 http 请求方法二:使用图片base64格式](#22-http-请求方法二使用图片base64格式)
- * [3. http返回数据](#3-http返回数据)
-
-* [FAQ](#faq)
-
-
-
-# 安装准备
-
-## 1.硬件支持
-
-- NVIDIA GPU: x86_64
- - cuda支持版本:CUDA10.0/10.1/10.2 + cuDNN 7 (cuDNN版本>=7.6.5)
- - cuda支持版本:CUDA11.0 + cuDNN v8.0.4
-- CPU:Intel x86_64
-
-## 2. 软件环境
-
-1.运行二进制文件-环境要求
-
-- gcc: 5.4 以上 (GLIBCXX_3.4.22)
- - Linux下查看gcc版本命名(可能因系统差异命令会不同):`gcc --version`;
- - Linux下C++基础库GLIBCXX的命令(可能因系统差异路径会有不同,可检测自己环境下的情况):`strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX`
-- glibc:2.23以上
- - Linux查看命令:`ldd --version`
-
-2.二次开发编译-环境要求
-
-编译源代码时,除了gcc、GLIBCXX、glibc满足`1.运行二进制文件-环境要求`外,还需要cmake满足要求。
-
-- cmake: 3.0 以上
-
- - Linux查看命令:`cmake --version`
-
-# 快速开始
-
-## 1. 项目结构说明
-
-根据开发者模型、部署芯片、操作系统需要,在图像界面[飞桨开源模型](https://ai.baidu.com/easyedge/app/openSource)或[GIthub](https://github.com/PaddlePaddle/FastDeploy)中选择对应的SDK进行下载。SDK目录结构如下:
-
-```
-.EasyEdge-Linux-硬件芯片
-├── RES # 模型资源文件夹,一套模型适配不同硬件、OS和部署方式
-│ ├── conf.json # Android、iOS系统APP名字需要
-│ ├── model # 模型结构文件
-│ ├── params # 模型参数文件
-│ ├── label_list.txt # 模型标签文件
-│ ├── infer_cfg.json # 模型前后处理等配置文件
-├── ReadMe.txt
-├── cpp # C++ SDK 文件结构
- └── baidu_easyedge_linux_cpp_x86_64_CPU.Generic_gcc5.4_v1.4.0_20220325.tar.gz
- ├── ReadMe.txt
- ├── bin # 可直接运行的二进制文件
- ├── include # 二次开发用的头文件
- ├── lib # 二次开发用的所依赖的库
- ├── src # 二次开发用的示例工程
- └── thirdparty # 第三方依赖
-└── python # Python SDK 文件
-```
-
-```
-
-```
-
-## 2. 测试 HTTP Demo
-
-> 模型资源文件(即压缩包中的RES文件夹)默认已经打包在开发者下载的SDK包中,请先将tar包整体拷贝到具体运行的设备中,再解压缩使用。
-
-SDK中已经包含预先编译的二进制,可直接运行。以下运行示例均是`cd cpp/bin`路径下执行的结果。
-
-### 2.1. 启动HTTP预测服务
-
-```
-./easyedge_serving {模型RES文件夹路径}
-```
-
-启动后,日志中会显示如下设备IP和24401端口号信息:
-
-```
-HTTP is now serving at 0.0.0.0:24401
-```
-
-此时,开发者可以打开浏览器,输入链接地址`http://0.0.0.0:24401`(这里的`设备IP和24401端口号`根据开发者电脑显示修改),选择图片来进行测试。
-
-
-
-同时,可以调用HTTP接口来访问服务,具体参考下文的[二次开发](#10)接口说明。
-
-## 3. 编译Demo
-
-通过[项目结构说明](#3)了解到,`bin`路径下的可执行文件是由`src`下的对应文件编译得到的。 该部分说明C++编译命令。
-
-```
-cd src
-mkdir build && cd build
-cmake .. && make
-```
-
-至此,会在build文件夹下生成编译好的可执行文件,如图像推理的二进制文件:`build/demo_serving/easyedge_serving`。
-
-# HTTP API流程详解
-
-本章节主要结合[2.1 HTTP Demo](#4)的API介绍,方便开发者学习并将运行库嵌入到开发者的程序当中,更详细的API请参考`include/easyedge/easyedge*.h`文件。http服务包含服务端和客户端,目前支持的能力包括以下几种方式,Demo中提供了不使用图片base格式的`方式一:浏览器请求的方式`,其他几种方式开发者根据个人需要,选择开发。
-
-## 1. 开启http服务
-
-http服务的启动可直接使用`bin/easyedge_serving`,或参考`src/demo_serving.cpp`文件修改相关逻辑
-
-```cpp
- /**
- * @brief 开启一个简单的demo http服务。
- * 该方法会block直到收到sigint/sigterm。
- * http服务里,图片的解码运行在cpu之上,可能会降低推理速度。
- * @tparam ConfigT
- * @param config
- * @param host
- * @param port
- * @param service_id service_id user parameter, uri '/get/service_id' will respond this value with 'text/plain'
- * @param instance_num 实例数量,根据内存/显存/时延要求调整
- * @return
- */
- template
- int start_http_server(
- const ConfigT &config,
- const std::string &host,
- int port,
- const std::string &service_id,
- int instance_num = 1);
-```
-
-## 2. 请求http服务
-
-> 开发者可以打开浏览器,`http://{设备ip}:24401`,选择图片来进行测试。
-
-### 2.1 http 请求方式一:不使用图片base64格式
-
-URL中的get参数:
-
-| 参数 | 说明 | 默认值 |
-| --------- | --------- | ---------------- |
-| threshold | 阈值过滤, 0~1 | 如不提供,则会使用模型的推荐阈值 |
-
-HTTP POST Body即为图片的二进制内容(无需base64, 无需json)
-
-Python请求示例
-
-```Python
-import requests
-
-with open('./1.jpg', 'rb') as f:
- img = f.read()
- result = requests.post(
- 'http://127.0.0.1:24401/',
- params={'threshold': 0.1},
- data=img).json()
-```
-
-### 2.2 http 请求方法二:使用图片base64格式
-
-HTTP方法:POST
-Header如下:
-
-| 参数 | 值 |
-| ------------ | ---------------- |
-| Content-Type | application/json |
-
-**Body请求填写**:
-
-* 分类网络:
- body 中请求示例
-
- ```
- {
- "image": ""
- "top_num": 5
- }
- ```
-
- body中参数详情
-
-| 参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
-| ------- | ---- | ------ | ----- | ----------------------------------------------------------------------------------- |
-| image | 是 | string | - | 图像数据,base64编码,要求base64图片编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 **注意去掉头部** |
-| top_num | 否 | number | - | 返回分类数量,不填该参数,则默认返回全部分类结果 |
-
-* 检测和分割网络:
- Body请求示例:
-
- ```
- {
- "image": ""
- }
- ```
-
- body中参数详情:
-
-| 参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
-| --------- | ---- | ------ | ----- | ----------------------------------------------------------------------------------- |
-| image | 是 | string | - | 图像数据,base64编码,要求base64图片编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 **注意去掉头部** |
-| threshold | 否 | number | - | 默认为推荐阈值,也可自行根据需要进行设置 |
-
-Python请求示例
-
-```python
-import base64
-import requests
-
-def main():
- with open("图像路径", 'rb') as f:
- result = requests.post("http://{服务ip地址}:24401/", json={
- "image": base64.b64encode(f.read()).decode("utf8")
- })
- # print(result.request.body)
- # print(result.request.headers)
- print(result.content)
-
-if __name__ == '__main__':
- main()
-```
-
-### 3. http返回数据
-
-| 字段 | 类型说明 | 其他 |
-| ---------- | ------ | ------------------------------------ |
-| error_code | Number | 0为成功,非0参考message获得具体错误信息 |
-| results | Array | 内容为具体的识别结果。其中字段的具体含义请参考`预测图像-返回格式`一节 |
-| cost_ms | Number | 预测耗时ms,不含网络交互时间 |
-
-返回示例
-
-```json
-{
- "cost_ms": 52,
- "error_code": 0,
- "results": [
- {
- "confidence": 0.94482421875,
- "index": 1,
- "label": "IronMan",
- "x1": 0.059185408055782318,
- "x2": 0.18795496225357056,
- "y1": 0.14762254059314728,
- "y2": 0.52510076761245728,
- "mask": "...", // 图像分割模型字段
- "trackId": 0, // 目标追踪模型字段
- },
-
- ]
-}
-```
-
-*** 关于矩形坐标 ***
-
-x1 * 图片宽度 = 检测框的左上角的横坐标
-
-y1 * 图片高度 = 检测框的左上角的纵坐标
-
-x2 * 图片宽度 = 检测框的右下角的横坐标
-
-y2 * 图片高度 = 检测框的右下角的纵坐标
-
-*** 关于分割模型 ***
-
-其中,mask为分割模型的游程编码,解析方式可参考 [http demo](https://github.com/Baidu-AIP/EasyDL-Segmentation-Demo)
-
-# FAQ
-
-1. 如何处理一些 undefined reference / error while loading shared libraries?
-
-> 如:./easyedge_demo: error while loading shared libraries: libeasyedge.so.1: cannot open shared object file: No such file or directory
-
-遇到该问题时,请找到具体的库的位置,设置LD_LIBRARY_PATH;或者安装缺少的库。
-
-> 示例一:libverify.so.1: cannot open shared object file: No such file or directory
-> 链接找不到libveirfy.so文件,一般可通过 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../lib 解决(实际冒号后面添加的路径以libverify.so文件所在的路径为准)
-
-> 示例二:libopencv_videoio.so.4.5: cannot open shared object file: No such file or directory
-> 链接找不到libopencv_videoio.so文件,一般可通过 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../thirdparty/opencv/lib 解决(实际冒号后面添加的路径以libopencv_videoio.so所在路径为准)
-
-> 示例三:GLIBCXX_X.X.X not found
-> 链接无法找到glibc版本,请确保系统gcc版本>=SDK的gcc版本。升级gcc/glibc可以百度搜索相关文献。
-
-2. 使用libcurl请求http服务时,速度明显变慢
-
-这是因为libcurl请求continue导致server等待数据的问题,添加空的header即可
-
-```bash
-headers = curl_slist_append(headers, "Expect:");
-```
-
-3. 运行二进制时,提示 libverify.so cannot open shared object file
-
-可能cmake没有正确设置rpath, 可以设置LD_LIBRARY_PATH为sdk的lib文件夹后,再运行:
-
-```bash
-LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib ./easyedge_demo
-```
-
-4. 编译时报错:file format not recognized
-
-可能是因为在复制SDK时文件信息丢失。请将整个压缩包复制到目标设备中,再解压缩、编译。
diff --git a/docs/Linux-Python-SDK-Inference.md b/docs/Linux-Python-SDK-Inference.md
deleted file mode 100644
index 98dbc3a247..0000000000
--- a/docs/Linux-Python-SDK-Inference.md
+++ /dev/null
@@ -1,369 +0,0 @@
-# 简介
-
-本文档介绍FastDeploy中的模型SDK,在**Intel x86_64 / NVIDIA GPU Linux Python** 环境下: (1)图像推理部署步骤; (2)介绍模型推流全流程API,方便开发者了解项目后二次开发。
-其中Linux C++请参考[Linux CPP环境下的推理部署](./Linux-CPP-SDK-Inference.md)文档。
-
-
-
-* [简介](#简介)
-
-* [环境准备](#环境准备)
-
- * [1. SDK下载](#1-sdk下载)
- * [2. Python环境](#2-python环境)
- * [3. 安装依赖](#3-安装依赖)
- * [3.1 安装paddlepaddle](#31-安装paddlepaddle)
- * [3.2 安装EasyEdge Python Wheel 包](#32-安装easyedge-python-wheel-包)
-
-* [快速开始](#快速开始)
-
- * [1. 文件结构说明](#1-文件结构说明)
- * [2. 测试Demo](#2-测试demo)
- * [2.1 预测图像](#21-预测图像)
-
-* [预测API流程详解](#预测api流程详解)
-
- * [1. 基础流程](#1-基础流程)
- * [2. 初始化](#2-初始化)
- * [3. SDK参数配置](#3-sdk参数配置)
- * [4. 预测图像](#4-预测图像)
-
-* [FAQ](#faq)
-
-
-
-# 环境准备
-
-## 1. SDK下载
-
-根据开发者模型、部署芯片、操作系统需要,在图像界面[飞桨开源模型](https://ai.baidu.com/easyedge/app/openSource)或[GIthub](https://github.com/PaddlePaddle/FastDeploy)中选择对应的SDK进行下载。解压后SDK目录结构如下:
-
-```shell
-EasyEdge-Linux-x86-[部署芯片]
-├── RES # 模型文件资源文件夹,可替换为其他模型
-├── README.md
-├── cpp # C++ SDK
-└── python # Python SDK
-```
-
-## 2. Python环境
-
-> 当前SDK仅支持Python 3.5, 3.6, 3.7
-
-使用如下命令获取已安装的Python版本号。如果本机的版本不匹配,建议使用[pyenv](https://github.com/pyenv/pyenv)、[anaconda](https://www.anaconda.com/)等Python版本管理工具对SDK所在目录进行配置。
-
-```shell
-$python3 --version
-```
-
-接着使用如下命令确认pip的版本是否满足要求,要求pip版本为20.2.2或更高版本。详细的pip安装过程可以参考[官网教程](https://pip.pypa.io/en/stable/installation/)。
-
-```shell
-$python3 -m pip --version
-```
-
-## 3. 安装依赖
-
-### 3.1 安装paddlepaddle
-
-根据具体的部署芯片(CPU/GPU)安装对应的PaddlePaddle的whl包。
-
-`x86_64 CPU` 平台可以使用如下命令进行安装:
-
-```shell
-python3 -m pip install paddlepaddle==2.2.2 -i https://mirror.baidu.com/pypi/simple
-```
-
-NVIDIA GPU平台的详细安装教程可以参考[官网Paddle安装教程](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)。
-
-> 使用 NVIDIA GPU 预测时,必须满足:
->
-> 1. 机器已安装 cuda, cudnn
-> 2. 已正确安装对应 cuda 版本的paddle 版本
-> 3. 通过设置环境变量`FLAGS_fraction_of_gpu_memory_to_use`设置合理的初始内存使用比例
-
-### 3.2 安装EasyEdge Python Wheel 包
-
-在`python`目录下,安装特定Python版本的EasyEdge Wheel包。对`x86_64 CPU` 或 `x86_64 Nvidia GPU平台 `可以使用如下命令进行安装,具体名称以 Python SDK 包中的 whl 为准。
-
-```shell
-python3 -m pip install -U BaiduAI_EasyEdge_SDK-{SDK版本号}-cp{Python版本号}-cp{Python版本号}m-linux_x86_64.whl
-```
-
-`armv8 CPU平台`可以使用如下命令进行安装:
-
-```shell
-python3 -m pip install -U BaiduAI_EasyEdge_SDK-{版本号}-cp36-cp36m-linux_aarch64.whl
-```
-
-# 快速开始
-
-## 1. 文件结构说明
-
-Python SDK文件结构如下:
-
-```shell
-EasyEdge-Linux-x86--[部署芯片]
-├──...
-├──python # Linux Python SDK
- ├── # 特定Python版本的EasyEdge Wheel包, 二次开发可使用
- ├── BaiduAI_EasyEdge_SDK-1.2.8-cp35-cp35m-linux_x86_64.whl
- ├── BaiduAI_EasyEdge_SDK-1.2.8-cp36-cp36m-linux_x86_64.whl
- ├── BaiduAI_EasyEdge_SDK-1.2.8-cp37-cp37m-linux_x86_64.whl
- ├── infer_demo # demo体验完整文件
- │ ├── demo_xxx.py # 包含前后处理的端到端推理demo文件
- │ └── demo_serving.py # 提供http服务的demo文件
- ├── tensor_demo # tensor in/out demo文件
- │ └── demo_xxx.py
-```
-
-## 2. 测试Demo
-
-> 模型资源文件默认已经打包在开发者下载的SDK包中, 默认为`RES`目录。
-
-### 2.1 预测图像
-
-使用infer_demo文件夹下的demo文件。
-
-```bash
-python3 demo_x86_cpu.py {模型RES文件夹} {测试图片路径}
-```
-
-运行效果示例:
-
-
-
-```shell
-2022-06-14 14:40:16 INFO [EasyEdge] [demo_nvidia_gpu.py:38] 140518522509120: Init paddlefluid engine...
-2022-06-14 14:40:20 INFO [EasyEdge] [demo_nvidia_gpu.py:38] 140518522509120: Paddle version: 2.2.2
-{'confidence': 0.9012349843978882, 'index': 8, 'label': 'n01514859 hen'}
-```
-
-可以看到,运行结果为`index:8,label:hen`,通过imagenet [类别映射表](https://gist.github.com/yrevar/942d3a0ac09ec9e5eb3a),可以找到对应的类别,即 'hen',由此说明我们的预测结果正确。
-
-# 预测API流程详解
-
-本章节主要结合前文的Demo示例来介绍推理API,方便开发者学习并将运行库嵌入到开发者的程序当中,更详细的API请参考`infer_demo/demo_xx_xx.py`文件,查看下面的Python代码中的step注释说明。
-
-## 1. 基础流程
-
-> ❗注意,请优先参考SDK中自带demo的使用流程和说明。遇到错误,请优先参考文件中的注释、解释、日志说明。
-
-`infer_demo/demo_xx_xx.py`
-
-```python
-# 引入EasyEdge运行库
-import BaiduAI.EasyEdge as edge
-
-# 创建并初始化一个预测Progam;选择合适的引擎
-pred = edge.Program()
-pred.init(model_dir={RES文件夹路径}, device=edge.Device.CPU, engine=edge.Engine.PADDLE_FLUID) # x86_64 CPU
-# pred.init(model_dir=_model_dir, device=edge.Device.GPU, engine=edge.Engine.PADDLE_FLUID) # x86_64 Nvidia GPU
-# pred.init(model_dir=_model_dir, device=edge.Device.CPU, engine=edge.Engine.PADDLE_LITE) # armv8 CPU
-
-# 预测图像
-res = pred.infer_image({numpy.ndarray的图片})
-
-# 关闭结束预测Progam
-pred.close()
-```
-
-`infer_demo/demo_serving.py`
-
-```python
-import BaiduAI.EasyEdge as edge
-from BaiduAI.EasyEdge.serving import Serving
-
-# 创建并初始化Http服务
-server = Serving(model_dir={RES文件夹路径}, license=serial_key)
-
-# 运行Http服务
-# 请参考同级目录下demo_xx_xx.py里:
-# pred.init(model_dir=xx, device=xx, engine=xx, device_id=xx)
-# 对以下参数device\device_id和engine进行修改
-server.run(host=host, port=port, device=edge.Device.CPU, engine=edge.Engine.PADDLE_FLUID) # x86_64 CPU
-# server.run(host=host, port=port, device=edge.Device.GPU, engine=edge.Engine.PADDLE_FLUID) # x86_64 Nvidia GPU
-# server.run(host=host, port=port, device=edge.Device.CPU, engine=edge.Engine.PADDLE_LITE) # armv8 CPU
-```
-
-## 2. 初始化
-
-- 接口
-
-```python
- def init(self,
- model_dir,
- device=Device.CPU,
- engine=Engine.PADDLE_FLUID,
- config_file='conf.json',
- preprocess_file='preprocess_args.json',
- model_file='model',
- params_file='params',
- label_file='label_list.txt',
- infer_cfg_file='infer_cfg.json',
- device_id=0,
- thread_num=1
- ):
- """
- Args:
- model_dir: str
- device: BaiduAI.EasyEdge.Device,比如:Device.CPU
- engine: BaiduAI.EasyEdge.Engine, 比如: Engine.PADDLE_FLUID
- config_file: str
- preprocess_file: str
- model_file: str
- params_file: str
- label_file: str 标签文件
- infer_cfg_file: 包含预处理、后处理信息的文件
- device_id: int 设备ID
- thread_num: int CPU的线程数
-
- Raises:
- RuntimeError, IOError
- Returns:
- bool: True if success
- """
-```
-
-若返回不是True,请查看输出日志排查错误原因。
-
-## 3. SDK参数配置
-
-使用 CPU 预测时,可以通过在 init 中设置 thread_num 使用多线程预测。如:
-
-```python
-pred.init(model_dir=_model_dir, device=edge.Device.CPU, engine=edge.Engine.PADDLE_FLUID, thread_num=4)
-```
-
-使用 GPU 预测时,可以通过在 init 中设置 device_id 指定需要的GPU device id。如:
-
-```python
-pred.init(model_dir=_model_dir, device=edge.Device.GPU, engine=edge.Engine.PADDLE_FLUID, device_id=0)
-```
-
-## 4. 预测图像
-
-- 接口
-
-```python
- def infer_image(self, img,
- threshold=0.3,
- channel_order='HWC',
- color_format='BGR',
- data_type='numpy')
- """
-
- Args:
- img: np.ndarray or bytes
- threshold: float
- only return result with confidence larger than threshold
- channel_order: string
- channel order HWC or CHW
- color_format: string
- color format order RGB or BGR
- data_type: string
- 仅在图像分割时有意义。 'numpy' or 'string'
- 'numpy': 返回已解析的mask
- 'string': 返回未解析的mask游程编码
-
- Returns:
- list
-
- """
-```
-
-| 字段 | 类型 | 取值 | 说明 |
-| ---------- | -------------------- | --------- | ------------------------ |
-| confidence | float | 0~1 | 分类或检测的置信度 |
-| label | string | | 分类或检测的类别 |
-| index | number | | 分类或检测的类别 |
-| x1, y1 | float | 0~1 | 物体检测,矩形的左上角坐标 (相对长宽的比例值) |
-| x2, y2 | float | 0~1 | 物体检测,矩形的右下角坐标(相对长宽的比例值) |
-| mask | string/numpy.ndarray | 图像分割的mask | |
-
-***关于矩形坐标***
-
-x1 * 图片宽度 = 检测框的左上角的横坐标
-
-y1 * 图片高度 = 检测框的左上角的纵坐标
-
-x2 * 图片宽度 = 检测框的右下角的横坐标
-
-y2 * 图片高度 = 检测框的右下角的纵坐标
-
-可以参考 demo 文件中使用 opencv 绘制矩形的逻辑。
-
-***结果示例***
-
-i) 图像分类
-
-```json
-{
- "index": 736,
- "label": "table",
- "confidence": 0.9
-}
-```
-
-ii) 物体检测
-
-```json
-{
- "index": 8,
- "label": "cat",
- "confidence": 1.0,
- "x1": 0.21289,
- "y1": 0.12671,
- "x2": 0.91504,
- "y2": 0.91211,
-}
-```
-
-iii) 图像分割
-
-```json
-{
- "name": "cat",
- "score": 1.0,
- "location": {
- "left": ...,
- "top": ...,
- "width": ...,
- "height": ...,
- },
- "mask": ...
-}
-```
-
-mask字段中,data_type为`numpy`时,返回图像掩码的二维数组
-
-```text
-{
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-}
-其中1代表为目标区域,0代表非目标区域
-```
-
-data_type为`string`时,mask的游程编码,解析方式可参考 [demo](https://github.com/Baidu-AIP/EasyDL-Segmentation-Demo)。
-
-
-# FAQ
-
-1. 执行infer_demo文件时,提示your generated code is out of date and must be regenerated with protoc >= 3.19.0
-
- 进入当前项目,首先卸载protobuf
-
-```shell
-python3 -m pip uninstall protobuf
-```
-
- 安装低版本protobuf
-
-```shell
-python3 -m pip install protobuf==3.19.0
-```
diff --git a/docs/Linux-Python-SDK-Serving.md b/docs/Linux-Python-SDK-Serving.md
deleted file mode 100644
index 56cee55854..0000000000
--- a/docs/Linux-Python-SDK-Serving.md
+++ /dev/null
@@ -1,268 +0,0 @@
-# 简介
-
-本文档以[千分类模型_MobileNetV3](https://ai.baidu.com/easyedge/app/openSource)为例,介绍 FastDeploy中的模型SDK ,在**Intel x86_64 / NVIDIA GPU Linux Python** 环境下: (1)SDK **服务化**推理部署步骤; (2)介绍模型推流全流程API,方便开发者了解项目后二次开发。
-其中Linux C++请参考[Linux C++环境下的服务化推理部署](./Linux-CPP-SDK-Serving.md)文档。
-
-**【注意】**:OCR Demo 暂不支持服务化部署。
-
-
-
-* [简介](#简介)
-
-* [环境准备](#环境准备)
-
- * [1. SDK下载](#1-sdk下载)
- * [2. Python环境](#2-python环境)
- * [3. 安装依赖](#3-安装依赖)
- * [3.1 安装paddlepaddle](#31-安装paddlepaddle)
- * [3.2 安装EasyEdge Python Wheel 包](#32-安装easyedge-python-wheel-包)
-
-* [快速开始](#快速开始)
-
- * [1. 文件结构说明](#1-文件结构说明)
- * [2. 测试Serving服务](#2-测试serving服务)
- * [2.1 启动HTTP预测服务](#21-启动http预测服务)
-
-* [HTTP API流程详解](#http-api流程详解)
-
- * [1. 开启http服务](#1-开启http服务)
- * [2. 请求http服务](#2-请求http服务)
- * [2.1 http 请求方式:不使用图片base64格式](#21-http-请求方式不使用图片base64格式)
- * [3. http 返回数据](#3-http-返回数据)
-
-* [FAQ](#faq)
-
-
-
-# 环境准备
-
-## 1. SDK下载
-
-根据开发者模型、部署芯片、操作系统需要,在图像界面[飞桨开源模型](https://ai.baidu.com/easyedge/app/openSource)或[GIthub](https://github.com/PaddlePaddle/FastDeploy)中选择对应的SDK进行下载。解压后SDK目录结构如下:
-
-```shell
-EasyEdge-Linux-x86-[部署芯片]
-├── RES # 模型文件资源文件夹,可替换为其他模型
-├── README.md
-├── cpp # C++ SDK
-└── python # Python SDK
-```
-
-## 2. Python环境
-
-> 当前SDK仅支持Python 3.5, 3.6, 3.7
-
-使用如下命令获取已安装的Python版本号。如果本机的版本不匹配,建议使用[pyenv](https://github.com/pyenv/pyenv)、[anaconda](https://www.anaconda.com/)等Python版本管理工具对SDK所在目录进行配置。
-
-```shell
-$python3 --version
-```
-
-接着使用如下命令确认pip的版本是否满足要求,要求pip版本为20.2.2或更高版本。详细的pip安装过程可以参考[官网教程](https://pip.pypa.io/en/stable/installation/)。
-
-```shell
-$python3 -m pip --version
-```
-
-## 3. 安装依赖
-
-### 3.1 安装paddlepaddle
-
-根据具体的部署芯片(CPU/GPU)安装对应的PaddlePaddle的whl包。
-
-1.`x86_64 CPU` 平台可以使用如下命令进行安装:
-
- ```shell
- python3 -m pip install paddlepaddle==2.2.2 -i https://mirror.baidu.com/pypi/simple
- ```
-
-2.`x86_64 NVIDIA GPU` 支持的CUDA和CUDNN版本与PaddlePaddle框架保持一致,如下:
-
- * CUDA 工具包10.1/10.2配合cuDNN 7 (cuDNN版本>=7.6.5, 如需多卡支持,需配合NCCL2.7及更高)
- * CUDA 工具包11.0配合cuDNN v8.0.4(如需多卡支持,需配合NCCL2.7及更高)
- * CUDA 工具包11.1配合cuDNN v8.1.1(如需多卡支持,需配合NCCL2.7及更高)
- * CUDA 工具包11.2配合cuDNN v8.1.1(如需多卡支持,需配合NCCL2.7及更高)
-
- 具体安装命令,参考[官网Paddle安装教程](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)。
-
-> 使用 NVIDIA GPU 预测时,必须满足:
->
-> 1. 机器已安装 cuda, cudnn
-> 2. 已正确安装对应 cuda 版本的paddle 版本
-> 3. 通过设置环境变量`FLAGS_fraction_of_gpu_memory_to_use`设置合理的初始内存使用比例
-
-### 3.2 安装EasyEdge Python Wheel 包
-
-在`python`目录下,安装特定Python版本的EasyEdge Wheel包。对`x86_64 CPU` 或 `x86_64 Nvidia GPU平台 `可以使用如下命令进行安装,具体名称以 Python SDK 包中的 whl 为准。
-
-```shell
-python3 -m pip install -U BaiduAI_EasyEdge_SDK-{SDK版本号}-cp{Python版本号}-cp{Python版本号}m-linux_x86_64.whl
-```
-
-`armv8 CPU平台`可以使用如下命令进行安装:
-
-```shell
-python3 -m pip install -U BaiduAI_EasyEdge_SDK-{SDK版本号}-cp36-cp36m-linux_aarch64.whl
-```
-
-# 快速开始
-
-## 1. 文件结构说明
-
-Python SDK文件结构如下:
-
-```shell
-EasyEdge-Linux-x86--[部署芯片]
-├──...
-├──python # Linux Python SDK
- ├── # 特定Python版本的EasyEdge Wheel包, 二次开发可使用
- ├── BaiduAI_EasyEdge_SDK-1.2.8-cp35-cp35m-linux_x86_64.whl
- ├── BaiduAI_EasyEdge_SDK-1.2.8-cp36-cp36m-linux_x86_64.whl
- ├── BaiduAI_EasyEdge_SDK-1.2.8-cp37-cp37m-linux_x86_64.whl
- ├── infer_demo # demo体验完整文件
- │ ├── demo_xxx.py # 包含前后处理的端到端推理demo文件
- │ └── demo_serving.py # 提供http服务的demo文件
- ├── tensor_demo # 学习自定义算法前后处理时使用
- │ └── demo_xxx.py
-```
-
-## 2. 测试Serving服务
-
-> 模型资源文件默认已经打包在开发者下载的SDK包中, 默认为`RES`目录。
-
-### 2.1 启动HTTP预测服务
-
-指定对应的模型文件夹(默认为`RES`)、设备ip和指定端口号,运行如下命令。
-
-```shell
-python3 demo_serving.py {模型RES文件夹} {host, default 0.0.0.0} {port, default 24401}
-```
-
-成功启动后,终端中会显示如下字样。
-
-```shell
-...
-* Running on {host ip}:24401
-```
-
-如果是在局域网内的机器上部署,开发者此时可以打开浏览器,输入`http://{host ip}:24401`,选择图片来进行测试,运行效果如下。
-
-
-
-如果是在远程机器上部署,那么可以参考`demo_serving.py`中的 `http_client_test()函数`请求http服务来执行推理。
-
-# HTTP API流程详解
-
-本章节主要结合前文的Demo示例来对API进行介绍,方便开发者学习并将运行库嵌入到开发者的程序当中,更详细的API请参考对应的Python文件。http服务包含服务端和客户端,Demo中提供了不使用图片base格式的`方式一:浏览器请求的方式`,其他几种方式开发者根据个人需要,选择开发。
-
-## 1. 开启http服务
-
-http服务的启动使用`demo_serving.py`文件
-
-```python
-class Serving(object):
- """ SDK local serving """
-
- def __init__(self, model_dir, license='', model_filename='model', params_filename='params'):
-
- self.program = None
- self.model_dir = model_dir
- self.model_filename = model_filename
- self.params_filename = params_filename
- self.program_lock = threading.Lock()
- self.license_key = license
- # 只有ObjectTracking会初始化video_processor
- self.video_processor = None
-
- def run(self, host, port, device, engine=Engine.PADDLE_FLUID, service_id=0, device_id=0, **kwargs):
- """ Args: host : str port : str device : BaiduAI.EasyEdge.Device,比如:Device.CPU engine : BaiduAI.EasyEdge.Engine, 比如: Engine.PADDLE_FLUID """
- self.run_serving_with_flask(host, port, device, engine, service_id, device_id, **kwargs)
-```
-
-## 2. 请求http服务
-
-> 开发者可以打开浏览器,`http://{设备ip}:24401`,选择图片来进行测试。
-
-### 2.1 http 请求方式:不使用图片base64格式
-
-URL中的get参数:
-
-| 参数 | 说明 | 默认值 |
-| --------- | --------- | ---------------- |
-| threshold | 阈值过滤, 0~1 | 如不提供,则会使用模型的推荐阈值 |
-
-HTTP POST Body即为图片的二进制内容。
-
-Python请求示例
-
-```python
-import requests
-
-with open('./1.jpg', 'rb') as f:
- img = f.read()
- result = requests.post(
- 'http://127.0.0.1:24401/',
- params={'threshold': 0.1},
- data=img).json()
-```
-
-## 3. http 返回数据
-
-| 字段 | 类型说明 | 其他 |
-| ---------- | ------ | ------------------------------------ |
-| error_code | Number | 0为成功,非0参考message获得具体错误信息 |
-| results | Array | 内容为具体的识别结果。其中字段的具体含义请参考`预测图像-返回格式`一节 |
-| cost_ms | Number | 预测耗时ms,不含网络交互时间 |
-
-返回示例
-
-```json
-{
- "cost_ms": 52,
- "error_code": 0,
- "results": [
- {
- "confidence": 0.94482421875,
- "index": 1,
- "label": "IronMan",
- "x1": 0.059185408055782318,
- "x2": 0.18795496225357056,
- "y1": 0.14762254059314728,
- "y2": 0.52510076761245728,
- "mask": "...", // 图像分割模型字段
- "trackId": 0, // 目标追踪模型字段
- },
-
- ]
-}
-```
-
-***关于矩形坐标***
-
-x1 * 图片宽度 = 检测框的左上角的横坐标
-
-y1 * 图片高度 = 检测框的左上角的纵坐标
-
-x2 * 图片宽度 = 检测框的右下角的横坐标
-
-y2 * 图片高度 = 检测框的右下角的纵坐标
-
-***关于分割模型***
-
-其中,mask为分割模型的游程编码,解析方式可参考 [demo](https://github.com/Baidu-AIP/EasyDL-Segmentation-Demo)。
-
-# FAQ
-
-1. 执行infer_demo文件时,提示your generated code is out of date and must be regenerated with protoc >= 3.19.0
-
-进入当前项目,首先卸载protobuf
-
-```shell
-python3 -m pip uninstall protobuf
-```
-
-安装低版本protobuf
-
-```shell
-python3 -m pip install protobuf==3.19.0
-```
diff --git a/docs/Replace-Model-With-Anther-One.md b/docs/Replace-Model-With-Anther-One.md
deleted file mode 100644
index 1e6f7436a1..0000000000
--- a/docs/Replace-Model-With-Anther-One.md
+++ /dev/null
@@ -1,266 +0,0 @@
-
-# 简介
-
-本文档介绍如何将FastDeploy的Demo模型,替换成开发者自己训练的AI模型。(**注意**:FastDeploy下载的SDK和Demo仅支持相同算法模型的替换)。本文档要求开发者已经将Demo和SDK运行跑通,如果要了解运行跑通Demo和SDK指导文档,可以参考[SDK使用文档](https://github.com/PaddlePaddle/FastDeploy/blob/develop/README.md#sdk使用)
-
-* [简介](#0)
-* [模型替换](#1)
- * [1.模型准备](#2)
- * [1.1 Paddle模型](#3)
- * [1.2 Paddle OCR模型增加一步特殊转换](#4)
- * [1.2.1 下载模型转换工具](#5)
- * [1.2.2 下载模型转换工具](#6)
- * [1.3 其他框架模型](#7)
- * [2.模型名修改和label文件准备](#8)
- * [2.1 非OCR模型名修改](#9)
- * [2.2 OCR模型名修改](#10)
- * [2.3 模型label文件](#11)
- * [3.修改配置文件](#12)
-* [测试效果](#13)
-* [完整配置文件说明](#14)
- * [1.配置文件字段含义](#15)
- * [2.预处理顺序](#16)
-* [FAQ](#17)
-
-**注意事项:**
-
-1. PP-PicoDet模型: 在FastDeploy中,支持PP-Picodet模型,是将后处理写到网络里面的方式(即后处理+NMS都在网络结构里面)。Paddle Detection导出静态模型时,有3种方法,选择将后处理和NMS导入到网络里面即可(参考[导出部分](https://github.com/PaddlePaddle/PaddleDetection/tree/release/2.4/configs/picodet#%E5%AF%BC%E5%87%BA%E5%8F%8A%E8%BD%AC%E6%8D%A2%E6%A8%A1%E5%9E%8B))。详细网络区别,可以通过netron工具对比。
-
-2. PP-Picodet模型:在FastDeploy中,支持PP-Picodet模型,是将前处理写在网络外面的方式。Paddle Detection中的TinyPose算法中,会将PP-PicoDet模型的前处理写入网络中。如果要使用FastDeploy的SDK进行模型替换,需要将前处理写到网络外面。(参考[Detection中的导出命令](https://github.com/PaddlePaddle/PaddleDetection/tree/release/2.4/configs/keypoint/tiny_pose#%E5%B0%86%E8%AE%AD%E7%BB%83%E7%9A%84%E6%A8%A1%E5%9E%8B%E5%AE%9E%E7%8E%B0%E7%AB%AF%E4%BE%A7%E9%83%A8%E7%BD%B2),将TestReader.fuse_normalize=False即可)。
-
-
-
-# 模型替换
-
-开发者从PaddleDetection、PaddleClas、PaddleOCR、PaddleSeg等飞桨开发套件导出来的对应模型,完成 [1.模型准备](#)、[1.模型名修改和模型label](#)、[3.修改配置文件](#) 3步操作(需要相同算法才可替换),可完成自定义模型的模型文件,运行时指定新的模型文件,即可在自己训练的模型上实现相应的预测推理任务。
-
-* Linux下模型资源文件夹路径:`EasyEdge-Linux-**/RES/` 。
-* Windows下模型资源文件夹路径:`EasyEdge-Windows-**/data/model/`。
-* Android下模型资源文件夹路径:`EasyEdge-Android-**/app/src/assets/infer/` 和 ` app/src/assets/demo/conf.json`
-* iOS下模型资源文件夹路径:`EasyEdge-iOS-**/RES/easyedge/`
-
-主要涉及到下面4个模型相关的文件(mode、params、label_list.txt、infer_cfg.json)和一个APP名相关的配置文件(仅Android、iOS、HTTP需要,APP名字,非必需。)
-
-* ```
- ├── RES、model、infer # 模型资源文件夹,一套模型适配不同硬件、OS和部署方式
- │ ├── conf.json # Android、iOS系统APP名字需要
- │ ├── model # 模型结构文件
- │ ├── params # 模型参数文件
- │ ├── label_list.txt # 模型标签文件
- │ ├── infer_cfg.json # 模型前后处理等配置文件
- ```
-
- > ❗注意:OCR模型在ARM CPU硬件上(包括Android、Linux、iOS 三款操作系统),因为任务的特殊性,替换在 [1.模型准备](#)、[1.模型名修改和模型label](#) 不同于其他任务模型,详细参考下面步骤。
-
-
-
-## 1.模型准备
-
-
-
-### 1.1 Paddle模型
-
-* 通过PaddleDetection、PaddleClas、PaddleOCR、PaddleSeg等导出来飞桨模型文件,包括如下文件(可能存在导出时修改了名字的情况,后缀`.pdmodel`为模型网络结构文件,后缀`.pdiparams`为模型权重文件):
-
-```
-model.pdmodel # 模型网络结构
-model.pdiparams # 模型权重
-model.yml # 模型的配置文件(包括预处理参数、模型定义等)
-```
-
-
-
-### 1.2 OCR模型特殊转换(仅在ARM CPU上需要)
-
-因为推理引擎版本的问题,OCR模型需要在[1.1 Paddle模型](#3)导出`.pdmodel`和`.pdiparams`模型后,多增加一步模型转换的特殊处理,主要执行下面2步:
-
-
-
-#### 1.2.1 下载模型转换工具
-
-Linux 模型转换工具下载链接:[opt_linux](https://github.com/PaddlePaddle/Paddle-Lite/releases/download/v2.11/opt_linux)
-M1 模型转换工具下载链接:[opt_m1](https://github.com/PaddlePaddle/Paddle-Lite/releases/download/v2.11/opt_m1)
-mac 模型转换工具下载链接:[opt_mac](https://github.com/PaddlePaddle/Paddle-Lite/releases/download/v2.11/opt_mac)
-
-
-
-#### 1.2.2 模型转换
-
-以下命令,以mac为例,完成模型转换。
-
-```
-* 转换 OCR 检测模型命名:
-./opt_mac --model_dir=./ch_PP-OCRv3_det_infer/ --valid_targets=arm --optimize_out_type=naive_buffer --optimize_out=./ocr_det
-
-* 转换 OCR 识别模型命名:
-./opt_mac --model_dir=./ch_PP-OCRv3_rec_infer/ --valid_targets=arm --optimize_out_type=naive_buffer --optimize_out=./ocr_rec
-```
-
-产出:
-
-
-
-
-
-### 1.3 其他框架模型
-
-* 如果开发着是PyTorch、TensorFLow、Caffe、ONNX等其他框架模型,可以参考[X2Paddle](https://github.com/PaddlePaddle/X2Paddle)官网完成模型转换,即可得到对应的`model.pdmodel`和`model.pdiparams`模型文件。
-
-
-
-## 2.模型名修改和label文件准备
-
-
-
-### 2.1 非OCR模型名修改
-
-按照下面的规则,修改套件导出来的模型名和标签文件,并替换到模型资源文件中。
-
-```
-1. model.pdmodel 修改成 model
-2. model.pdiparams 修改成 params
-```
-
-
-
-### 2.2 OCR模型名修改
-
-```
-1. ocr_det.nb 修改成 model # 将 检测模型 修改名称成 model
-2. ocr_rec.nb 修改成 params # 将 识别模型 修改名称成 model
-```
-
-
-
-### 2.3 模型label文件
-
-同时需要准备模型文件对应的label文件`label_list.txt`。label文件可以参考原Demo中`label_list.txt`的格式准备。
-
-
-
-## 3. 修改模型相关配置文件
-
-(1)infer_cfg.json 文件修改
-
-所有程序开发者都需要关注该配置文件。开发者在自己数据/任务中训练模型,可能会修改输入图像尺寸、修改阈值等操作,因此需要根据训练情况修改`Res文件夹下的infer_cfg.json`文件中的对应。CV任务涉及到的配置文件修改包括如下字段:
-
-```
-1. "best_threshold": 0.3, #网络输出的阈值,根据开发者模型实际情况修改
-2. "resize": [512, 512], #[w, h]网络输入图像尺寸,用户根据实际情况修改。
-```
-
-(2)conf.json 文件修改
-仅Android、iOS、HTTP服务应用开发者,需要关注该配置文件。开发者根据自己应用程序命名需要,参考已有`conf.json`即可。
-
-通常,开发者修改FastDeploy项目中的模型,涉及到主要是这几个配置信息的修改。FastDeploy详细的配置文件介绍参考[完整配置文件说明](#8)。
-
-
-
-# 测试效果
-
-将自定义准备的`RES`文件,按照第2、3步完成修改后,参考可以参考[SDK使用文档](https://github.com/PaddlePaddle/FastDeploy/blob/develop/README.md#sdk%E4%BD%BF%E7%94%A8)完成自己模型上的不同预测体验。
-
-
-
-# 完整配置文件说明
-
-
-
-## 1. 配置文件字段含义
-
-模型资源文件`infer_cfg.json`涉及到大量不同算法的前后处理等信息,下表是相关的字段介绍,通常开发者如果没有修改算法前出处理,不需要关心这些字段。非标记【必须】的可不填。
-
-```json
-{
- "version": 1,
- "model_info": {
- "best_threshold": 0.3, // 默认0.3
- "model_kind": 1, // 【必须】 1-分类,2-检测,6-实例分割,12-追踪,14-语义分割,401-人脸,402-姿态,10001-决策
- },
- "pre_process": { // 【必须】
- // 归一化, 预处理会把图像 (origin_img - mean) * scale
- "skip_norm": false, // 默认为false, 如果设置为true,不做mean scale处理
- "mean": [123, 123, 123], // 【必须,一般不需要动】图像均值,已经根据Paddle套件均值做了转换处理,开发者如果没有修改套件参数,可以不用关注。(X-mean)/ scale
- "scale": [0.017, 0.017, 0.017], // 【必须,一般不需要动】
- "color_format": "RGB", // BGR 【必须,一般不需要动】
- "channel_order": "CHW", // HWC
- // 大小相关
- "resize": [300, 300], // w, h 【必须】
- "rescale_mode": "keep_size", // 默认keep_size, keep_ratio, keep_ratio2, keep_raw_size, warp_affine
- "max_size": 1366, // keep_ratio 用。如果没有提供,则用 resize[0]
- "target_size": 800, // keep_ratio 用。如果没有提供,则用 resize[1]
- "raw_size_range": [100, 10000], // keep_raw_size 用
- "warp_affine_keep_res": // warp_affine模式使用,默认为false
- "center_crop_size": [224, 224], // w, h, 如果需要做center_crop,则提供,否则,无需提供该字段
- "padding": false,
- "padding_mode": "padding_align32", // 【非必须】默认padding_align32, 其他可指定:padding_fill_size
- "padding_fill_size": [416, 416], // 【非必须】仅padding_fill_size模式下需要提供, [fill_size_w, fill_size_h], 这里padding fill对齐paddle detection实现,在bottom和right方向实现补齐
- "padding_fill_value": [114, 114, 114] // 【非必须】仅padding_fill_size模式下需要提供
- // 其他
- "letterbox": true,
- },
- "post_process": {
- "box_normed": true, // 默认为true, 如果为false 则表示该模型的box坐标输出不是归一化的
- }
-}
-```
-
-
-
-## 2. 预处理顺序(没有的流程自动略过)
-
-1. 灰度图 -> rgb图变换
-2. resize 尺寸变换
-3. center_crop
-4. rgb/bgr变换
-5. padding_fill_size
-6. letterbox(画个厚边框,填上黑色)
-7. chw/hwc变换
-8. 归一化:mean, scale
-9. padding_align32
-
-rescale_mode说明:
-
-* keep_size: 将图片缩放到resize指定的大小
-* keep_ratio:将图片按比例缩放,长边不超过max_size,短边不超过target_size
-* keep_raw_size:保持原图尺寸,但必须在raw_size_range之间
-* warp_affine: 仿射变换,可以设置warp_affine_keep_res指定是否keep_res,在keep_res为false场景下,宽高通过resize字段指定
-
-
-
-# FAQ
-
-### 1. 如何处理一些 undefined reference / error while loading shared libraries?
-
-> 如:./easyedge_demo: error while loading shared libraries: libeasyedge.so.1: cannot open shared object file: No such file or directory
-
-遇到该问题时,请找到具体的库的位置,设置LD_LIBRARY_PATH;或者安装缺少的库。
-
-> 示例一:libverify.so.1: cannot open shared object file: No such file or directory
-> 链接找不到libveirfy.so文件,一般可通过 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../lib 解决(实际冒号后面添加的路径以libverify.so文件所在的路径为准)
-
-> 示例二:libopencv_videoio.so.4.5: cannot open shared object file: No such file or directory
-> 链接找不到libopencv_videoio.so文件,一般可通过 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../../thirdparty/opencv/lib 解决(实际冒号后面添加的路径以libopencv_videoio.so所在路径为准)
-
-> 示例三:GLIBCXX_X.X.X not found
-> 链接无法找到glibc版本,请确保系统gcc版本>=SDK的gcc版本。升级gcc/glibc可以百度搜索相关文献。
-
-### 2. 使用libcurl请求http服务时,速度明显变慢
-
-这是因为libcurl请求continue导致server等待数据的问题,添加空的header即可
-
-```bash
-headers = curl_slist_append(headers, "Expect:");
-```
-
-### 3. 运行二进制时,提示 libverify.so cannot open shared object file
-
-可能cmake没有正确设置rpath, 可以设置LD_LIBRARY_PATH为sdk的lib文件夹后,再运行:
-
-```bash
-LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib ./easyedge_demo
-```
-
-### 4. 编译时报错:file format not recognized
-
-可能是因为在复制SDK时文件信息丢失。请将整个压缩包复制到目标设备中,再解压缩、编译
diff --git a/docs/Windows-CPP-SDK-Inference.md b/docs/Windows-CPP-SDK-Inference.md
deleted file mode 100644
index 02a5a4b9fc..0000000000
--- a/docs/Windows-CPP-SDK-Inference.md
+++ /dev/null
@@ -1,389 +0,0 @@
-# 简介
-
-本文档以[千分类模型_MobileNetV3](https://ai.baidu.com/easyedge/app/openSource)为例,介绍FastDeploy中的模型SDK ,在**Intel x86_64 / NVIDIA GPU Windows C++** 环境下:(1)SDK 图像和视频推理部署步骤;(2)介绍模型推流全流程API,方便开发者了解项目后二次开发。
-其中Windows Python请参考[Windows Python环境下的推理部署](./Windows-Python-SDK-Inference.md)文档。
-
-
-
-* [简介](#简介)
-
-* [环境准备](#环境准备)
-
- * [1. SDK下载](#1-sdk下载)
- * [2. CPP环境](#2-cpp环境)
-
-* [快速开始](#快速开始)
-
- * [1. 项目结构说明](#1-项目结构说明)
- * [2. 测试EasyEdge服务](#2-测试easyedge服务)
- * [3. 预测图像](#3-预测图像)
- * [4. 预测视频流](#4-预测视频流)
- * [5. 编译Demo](#5-编译demo)
-
-* [预测API流程详解](#预测api流程详解)
-
- * [1. SDK参数运行配置](#1-sdk参数运行配置)
- * [2. 初始化Predictor](#2-初始化predictor)
- * [3. 预测推理](#3-预测推理)
- * [3.1 预测图像](#31-预测图像)
- * [3.2 预测视频](#32-预测视频)
-
-* [FAQ](#faq)
-
-
-
-# 环境准备
-
-## 1. SDK下载
-
-根据开发者模型、部署芯片、操作系统需要,在图像界面[飞桨开源模型](https://ai.baidu.com/easyedge/app/openSource)或[GIthub](https://github.com/PaddlePaddle/FastDeploy)中选择对应的SDK进行下载。解压缩后的文件结构如`快速开始`中[1项目介绍说明](#1-项目结构说明)介绍。
-
-## 2. CPP环境
-
-> 建议使用Microsoft Visual Studio 2015及以上版本,获取核心 C 和 C++ 支持,安装时请选择“使用 C++ 的桌面开发”工作负载。
-
-# 快速开始
-
-## 1. 项目结构说明
-
-```shell
-EasyEdge-win-xxx
- ├── data
- │ ├── model # 模型文件资源文件夹,可替换为其他模型
- │ └── config # 配置文件
- ├── bin # demo二进制程序
- │ ├── xxx_image # 预测图像demo
- │ ├── xxx_video # 预测视频流demo
- │ └── xxx_serving # 启动http预测服务demo
- ├── dll # demo二进制程序依赖的动态库
- ├── ... # 二次开发依赖的文件
- ├── python # Python SDK文件
- ├── EasyEdge.exe # EasyEdge服务
- └── README.md # 环境说明
-```
-
-## 2. 测试EasyEdge服务
-
-> 模型资源文件默认已经打包在开发者下载的SDK包中,请先将zip包整体拷贝到具体运行的设备中,再解压缩使用。
-
-SDK下载完成后,双击打开EasyEdge.exe启动推理服务,输入要绑定的Host ip及端口号Port,点击启动服务。
-
-
-

-
-
-服务启动后,打开浏览器输入`http://{Host ip}:{Port}`,添加图片或者视频来进行测试。
-
-
-

-
-
-## 3. 预测图像
-
-除了通过上述方式外,您还可以使用bin目录下的可执行文件来体验单一的功能。在dll目录下,点击右键,选择"在终端打开",执行如下命令。
-
-> 需要将bin目录下的可执行文件移动到dll目录下执行,或者将dll目录添加到系统环境变量中。
-
-```bash
-.\easyedge_image_inference {模型model文件夹} {测试图片路径}
-```
-
-运行效果示例:
-
-
-
-```shell
-2022-06-20 10:36:57,602 INFO [EasyEdge] 9788 EasyEdge Windows Development Kit 1.5.2(Build CPU.Generic 20220607) Release
-e[37m--- Fused 0 subgraphs into layer_norm op.e[0m
-2022-06-20 10:36:58,008 INFO [EasyEdge] 9788 Allocate graph success.
-Results of image ..\demo.jpg:
-8, n01514859 hen, p:0.953429
-save result image to ..\demo.jpg.result-cpp.jpg
-Done
-```
-
-可以看到,运行结果为`index:8,label:hen`,通过imagenet [类别映射表](https://gist.github.com/yrevar/942d3a0ac09ec9e5eb3a),可以找到对应的类别,即 'hen',由此说明我们的预测结果正确。
-
-## 4. 预测视频流
-
-```
-.\easyedge_video_inference {模型model文件夹} {video_type} {video_src}
-```
-
-其中video_type支持三种视频流类型,它们分别是:(1)本地视频文件 (2)本地摄像头id(3)网络视频流地址。
-
-```
-/**
- * @brief 输入源类型
- */
-enum class SourceType {
- kVideoFile = 1, // 本地视频文件
- kCameraId = 2, // 摄像头的index
- kNetworkStream = 3, // 网络视频流
-};
-```
-
-video_src 即为文件路径。
-
-## 5. 编译Demo
-
-在[项目结构说明](#1-项目结构说明)中,`bin`路径下的可执行文件是由`src`下的对应文件编译得到的,具体的编译命令如下。
-
-```
-cd src
-mkdir build && cd build
-cmake .. && make
-```
-
-编译完成后,在build文件夹下会生成编译好的可执行文件,如图像推理的二进制文件:`build/demo_serving/easyedge_serving`。
-
-# 预测API流程详解
-
-本章节主要结合前文的Demo示例来介绍推理API,方便开发者学习并将运行库嵌入到开发者的程序当中,更详细的API请参考`include/easyedge/easyedge*.h`文件。图像、视频的推理包含以下3个API,查看下面的cpp代码中的step注释说明。
-
-> ❗注意:
-> (1)`src`文件夹中包含完整可编译的cmake工程实例,建议开发者先行了解[cmake工程基本知识](https://cmake.org/cmake/help/latest/guide/tutorial/index.html)。
-> (2)请优先参考SDK中自带的Demo工程的使用流程和说明。遇到错误,请优先参考文件中的注释、解释、日志说明。
-
-```cpp
- // step 1: SDK配置运行参数
- EdgePredictorConfig config;
- config.model_dir = {模型文件目录};
-
- // step 2: 创建并初始化Predictor;这这里选择合适的引擎
- auto predictor = global_controller()->CreateEdgePredictor(config);
-
- // step 3-1: 预测图像
- auto img = cv::imread({图片路径});
- std::vector results;
- predictor->infer(img, results);
-
- // step 3-2: 预测视频
- std::vector results;
- FrameTensor frame_tensor;
- VideoConfig video_config;
- video_config.source_type = static_cast(video_type); // source_type 定义参考头文件 easyedge_video.h
- video_config.source_value = video_src;
- /*
- ... more video_configs, 根据需要配置video_config的各选项
- */
- auto video_decoding = CreateVideoDecoding(video_config);
- while (video_decoding->next(frame_tensor) == EDGE_OK) {
- results.clear();
- if (frame_tensor.is_needed) {
- predictor->infer(frame_tensor.frame, results);
- render(frame_tensor.frame, results, predictor->model_info().kind);
- }
- //video_decoding->display(frame_tensor); // 显示当前frame,需在video_config中开启配置
- //video_decoding->save(frame_tensor); // 存储当前frame到视频,需在video_config中开启配置
- }
-```
-
-若需自定义library search path或者gcc路径,修改对应Demo工程下的CMakeList.txt即可。
-
-## 1. SDK参数运行配置
-
-SDK的参数通过`EdgePredictorConfig::set_config`和`global_controller()->set_config`配置。本Demo 中设置了模型路径,其他参数保留默认参数。更详细的支持运行参数等,可以参考开发工具包中的头文件(`include/easyedge/easyedge_xxxx_config.h`)的详细说明。
-
-配置参数使用方法如下:
-
-```
-EdgePredictorConfig config;
-config.model_dir = {模型文件目录};
-```
-
-## 2. 初始化Predictor
-
-- 接口
-
- ```cpp
- auto predictor = global_controller()->CreateEdgePredictor(config);
- predictor->init();
- ```
-
-若返回非0,请查看输出日志排查错误原因。
-
-## 3. 预测推理
-
-### 3.1 预测图像
-
-> 在Demo中展示了预测接口infer()传入cv::Mat& image图像内容,并将推理结果赋值给std::vector& result。更多关于infer()的使用,可以根据参考`easyedge.h`头文件中的实际情况、参数说明自行传入需要的内容做推理
-
-- 接口输入
-
-```cpp
- /**
- * @brief
- * 通用接口
- * @param image: must be BGR , HWC format (opencv default)
- * @param result
- * @return
- */
- virtual int infer(cv::Mat& image, std::vector& result) = 0;
-```
-
-图片的格式务必为opencv默认的BGR, HWC格式。
-
-- 接口返回
-
- `EdgeResultData`中可以获取对应的分类信息、位置信息。
-
-```cpp
-struct EdgeResultData {
- int index; // 分类结果的index
- std::string label; // 分类结果的label
- float prob; // 置信度
-
- // 物体检测 或 图像分割时使用:
- float x1, y1, x2, y2; // (x1, y1): 左上角, (x2, y2): 右下角; 均为0~1的长宽比例值。
-
- // 图像分割时使用:
- cv::Mat mask; // 0, 1 的mask
- std::string mask_rle; // Run Length Encoding,游程编码的mask
-};
-```
-
-*** 关于矩形坐标 ***
-
-x1 * 图片宽度 = 检测框的左上角的横坐标
-
-y1 * 图片高度 = 检测框的左上角的纵坐标
-
-x2 * 图片宽度 = 检测框的右下角的横坐标
-
-y2 * 图片高度 = 检测框的右下角的纵坐标
-
-*** 关于图像分割mask ***
-
-```
-cv::Mat mask为图像掩码的二维数组
-{
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-}
-其中1代表为目标区域,0代表非目标区域
-```
-
-*** 关于图像分割mask_rle ***
-
-该字段返回了mask的游程编码,解析方式可参考 [http demo](https://github.com/Baidu-AIP/EasyDL-Segmentation-Demo)。
-
-以上字段可以参考demo文件中使用opencv绘制的逻辑进行解析。
-
-### 3.2 预测视频
-
-SDK 提供了支持摄像头读取、视频文件和网络视频流的解析工具类`VideoDecoding`,此类提供了获取视频帧数据的便利函数。通过`VideoConfig`结构体可以控制视频/摄像头的解析策略、抽帧策略、分辨率调整、结果视频存储等功能。对于抽取到的视频帧可以直接作为SDK infer 接口的参数进行预测。
-
-- 接口输入
-
-class`VideoDecoding`:
-
-```
- /**
- * @brief 获取输入源的下一帧
- * @param frame_tensor
- * @return
- */
- virtual int next(FrameTensor &frame_tensor) = 0;
-
- /**
- * @brief 显示当前frame_tensor中的视频帧
- * @param frame_tensor
- * @return
- */
- virtual int display(const FrameTensor &frame_tensor) = 0;
-
- /**
- * @brief 将当前frame_tensor中的视频帧写为本地视频文件
- * @param frame_tensor
- * @return
- */
- virtual int save(FrameTensor &frame_tensor) = 0;
-
- /**
- * @brief 获取视频的fps属性
- * @return
- */
- virtual int get_fps() = 0;
- /**
- * @brief 获取视频的width属性
- * @return
- */
- virtual int get_width() = 0;
-
- /**
- * @brief 获取视频的height属性
- * @return
- */
- virtual int get_height() = 0;
-```
-
-struct `VideoConfig`
-
-```
-/**
- * @brief 视频源、抽帧策略、存储策略的设置选项
- */
-struct VideoConfig {
- SourceType source_type; // 输入源类型
- std::string source_value; // 输入源地址,如视频文件路径、摄像头index、网络流地址
- int skip_frames{0}; // 设置跳帧,每隔skip_frames帧抽取一帧,并把该抽取帧的is_needed置为true
- int retrieve_all{false}; // 是否抽取所有frame以便于作为显示和存储,对于不满足skip_frames策略的frame,把所抽取帧的is_needed置为false
- int input_fps{0}; // 在采取抽帧之前设置视频的fps
- Resolution resolution{Resolution::kAuto}; // 采样分辨率,只对camera有效
-
- bool enable_display{false}; // 默认不支持。
- std::string window_name{"EasyEdge"};
- bool display_all{false}; // 是否显示所有frame,若为false,仅显示根据skip_frames抽取的frame
-
- bool enable_save{false};
- std::string save_path; // frame存储为视频文件的路径
- bool save_all{false}; // 是否存储所有frame,若为false,仅存储根据skip_frames抽取的frame
-
- std::map conf;
-};
-```
-
-| 序号 | 字段 | 含义 |
-| --- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
-| 1 | `source_type` | 输入源类型,支持视频文件、摄像头、网络视频流三种,值分别为1、2、3 |
-| 2 | `source_value` | 若`source_type`为视频文件,该值为指向视频文件的完整路径;若`source_type`为摄像头,该值为摄像头的index,如对于`/dev/video0`的摄像头,则index为0;若`source_type`为网络视频流,则为该视频流的完整地址。 |
-| 3 | `skip_frames` | 设置跳帧,每隔skip_frames帧抽取一帧,并把该抽取帧的is_needed置为true,标记为is_needed的帧是用来做预测的帧。反之,直接跳过该帧,不经过预测。 |
-| 4 | `retrieve_all` | 若置该项为true,则无论是否设置跳帧,所有的帧都会被抽取返回,以作为显示或存储用。 |
-| 5 | `input_fps` | 用于抽帧前设置fps |
-| 6 | `resolution` | 设置摄像头采样的分辨率,其值请参考`easyedge_video.h`中的定义,注意该分辨率调整仅对输入源为摄像头时有效 |
-| 7 | `conf` | 高级选项。部分配置会通过该map来设置 |
-
-*** 注意:***
-
-1. `VideoConfig`不支持`display`功能。如果需要使用`VideoConfig`的`display`功能,需要自行编译带有GTK选项的OpenCV。
-
-2. 使用摄像头抽帧时,如果通过`resolution`设置了分辨率调整,但是不起作用,请添加如下选项:
-
- ```
- video_config.conf["backend"] = "2";
- ```
-
-3. 部分设备上的CSI摄像头尚未兼容,如遇到问题,可以通过工单、QQ交流群或微信交流群反馈。
-
-具体接口调用流程,可以参考SDK中的`demo_video_inference`。
-
-# FAQ
-
-1. 执行infer_demo文件时,提示your generated code is out of date and must be regenerated with protoc >= 3.19.0
-
-进入当前项目,首先卸载protobuf
-
-```shell
-python3 -m pip uninstall protobuf
-```
-
-安装低版本protobuf
-
-```shell
-python3 -m pip install protobuf==3.19.0
-```
diff --git a/docs/Windows-CPP-SDK-Serving.md b/docs/Windows-CPP-SDK-Serving.md
deleted file mode 100644
index e2215466bd..0000000000
--- a/docs/Windows-CPP-SDK-Serving.md
+++ /dev/null
@@ -1,275 +0,0 @@
-# 简介
-
-本文档以[千分类模型_MobileNetV3](https://ai.baidu.com/easyedge/app/openSource)为例,本文档介绍FastDeploy中的模型SDK,在**Intel x86_64 / NVIDIA GPU、Windows操作系统** 的C++环境:(1)HTTP服务化推理部署步骤,(2)介绍推理全流程API,方便开发者了解项目后二次开发。
-如果开发者对Python语言的相关能力感兴趣,可以参考Windows Python请参考[Windows Python环境下的推理部署](./Windows-Python-SDK-Serving.md)文档。
-
-
-
-* [简介](#简介)
-
-* [环境准备](#环境准备)
-
- * [1. SDK下载](#1-sdk下载)
- * [2. CPP环境](#2-cpp环境)
-
-* [快速开始](#快速开始)
-
- * [1. 项目结构说明](#1-项目结构说明)
- * [2. 测试EasyEdge服务](#2-测试easyedge服务)
- * [3. 启动HTTP预测服务](#3-启动http预测服务)
- * [4. 编译Demo](#4-编译demo)
-
-* [HTTP API流程详解](#http-api流程详解)
-
- * [1. 开启http服务](#1-开启http服务)
- * [2. 请求http服务](#2-请求http服务)
- * [2.1 http 请求方式一:不使用图片base64格式](#21-http-请求方式一不使用图片base64格式)
- * [2.2 http 请求方法二:使用图片base64格式](#22-http-请求方法二使用图片base64格式)
- * [3. http 返回数据](#3-http-返回数据)
-
-* [FAQ](#faq)
-
-
-
-# 环境准备
-
-## 1. SDK下载
-
-根据开发者模型、部署芯片、操作系统需要,在图像界面[飞桨开源模型](https://ai.baidu.com/easyedge/app/openSource)或[GIthub](https://github.com/PaddlePaddle/FastDeploy)中选择对应的SDK进行下载。解压缩后的文件结构如`快速开始`中[1项目介绍说明](#1-%E9%A1%B9%E7%9B%AE%E7%BB%93%E6%9E%84%E8%AF%B4%E6%98%8E)介绍。
-
-```shell
-
-```
-
-## 2. CPP环境
-
-> 建议使用Microsoft Visual Studio 2015及以上版本,获取核心 C 和 C++ 支持,安装时请选择“使用 C++ 的桌面开发”工作负载。
-
-# 快速开始
-
-## 1. 项目结构说明
-
-```shell
-EasyEdge-win-xxx
- ├── data
- │ ├── model # 模型文件资源文件夹,可替换为其他模型
- │ └── config # 配置文件
- ├── bin # demo二进制程序
- │ ├── xxx_image # 预测图像demo
- │ ├── xxx_video # 预测视频流demo
- │ └── xxx_serving # 启动http预测服务demo
- ├── dll # demo二进制程序依赖的动态库
- ├── ... # 二次开发依赖的文件
- ├── python # Python SDK文件
- ├── EasyEdge.exe # EasyEdge服务
- └── README.md # 环境说明
-```
-
-## 2. 测试EasyEdge服务
-
-> 模型资源文件默认已经打包在开发者下载的SDK包中,请先将zip包整体拷贝到具体运行的设备中,再解压缩使用。
-
-SDK下载完成后,双击打开EasyEdge.exe启动推理服务,输入要绑定的Host ip及端口号Port,点击启动服务。
-
-
-

-
-
-服务启动后,打开浏览器输入`http://{Host ip}:{Port}`,添加图片或者视频来进行测试。
-
-
-

-
-## 3. 启动HTTP预测服务
-
-除了通过上述方式外,您还可以使用bin目录下的可执行文件来体验单一的功能。在dll目录下,点击右键,选择"在终端打开",执行如下命令。
-
-> 需要将bin目录下的可执行文件移动到dll目录下执行,或者将dll目录添加到系统环境变量中。
-
-```
-.\easyedge_serving {模型model文件夹路径}
-```
-
-启动后,日志中会显示如下字样。
-
-```
-HTTP is now serving at 0.0.0.0:24401
-```
-
-此时,开发者可以打开浏览器,`http://127.0.0.1:24401`,执行和之前一样的操作即可。
-
-
-
-## 4. 编译Demo
-
-在[项目结构说明](#1项目结构说明)中,`bin`路径下的可执行文件是由`src`下的对应文件编译得到的,具体的编译命令如下。
-
-```
-cd src
-mkdir build && cd build
-cmake .. && make
-```
-
-编译完成后,在build文件夹下会生成编译好的可执行文件,如图像推理的二进制文件:`build/demo_serving/easyedge_serving`。
-
-# HTTP API流程详解
-
-本章节主要结合[2.1 HTTP Demo](#4)的API介绍,方便开发者学习并将运行库嵌入到开发者的程序当中,更详细的API请参考`include/easyedge/easyedge*.h`文件。http服务包含服务端和客户端,目前支持的能力包括以下几种方式,Demo中提供了不使用图片base格式的`方式一:浏览器请求的方式`,其他几种方式开发者根据个人需要,选择开发。
-
-## 1. 开启http服务
-
-http服务的启动可直接使用`bin/easyedge_serving`,或参考`src/demo_serving.cpp`文件修改相关逻辑
-
-```cpp
- /**
- * @brief 开启一个简单的demo http服务。
- * 该方法会block直到收到sigint/sigterm。
- * http服务里,图片的解码运行在cpu之上,可能会降低推理速度。
- * @tparam ConfigT
- * @param config
- * @param host
- * @param port
- * @param service_id service_id user parameter, uri '/get/service_id' will respond this value with 'text/plain'
- * @param instance_num 实例数量,根据内存/显存/时延要求调整
- * @return
- */
- template
- int start_http_server(
- const ConfigT &config,
- const std::string &host,
- int port,
- const std::string &service_id,
- int instance_num = 1);
-```
-
-## 2. 请求http服务
-
-> 开发者可以打开浏览器,`http://{设备ip}:24401`,选择图片来进行测试。
-
-### 2.1 http 请求方式一:不使用图片base64格式
-
-URL中的get参数:
-
-| 参数 | 说明 | 默认值 |
-| --------- | --------- | ---------------- |
-| threshold | 阈值过滤, 0~1 | 如不提供,则会使用模型的推荐阈值 |
-
-HTTP POST Body即为图片的二进制内容(无需base64, 无需json)
-
-Python请求示例
-
-```Python
-import requests
-
-with open('./1.jpg', 'rb') as f:
- img = f.read()
- result = requests.post(
- 'http://127.0.0.1:24401/',
- params={'threshold': 0.1},
- data=img).json()
-```
-
-### 2.2 http 请求方法二:使用图片base64格式
-
-HTTP方法:POST
-Header如下:
-
-| 参数 | 值 |
-| ------------ | ---------------- |
-| Content-Type | application/json |
-
-**Body请求填写**:
-
-- 分类网络:
- body 中请求示例
-
- ```
- {
- "image": ""
- "top_num": 5
- }
- ```
-
- body中参数详情
-
-| 参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
-| ------- | ---- | ------ | ----- | ----------------------------------------------------------------------------------- |
-| image | 是 | string | - | 图像数据,base64编码,要求base64图片编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 **注意去掉头部** |
-| top_num | 否 | number | - | 返回分类数量,不填该参数,则默认返回全部分类结果 |
-
-- 检测和分割网络:
- Body请求示例:
-
- ```
- {
- "image": ""
- }
- ```
-
- body中参数详情:
-
-| 参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
-| --------- | ---- | ------ | ----- | ----------------------------------------------------------------------------------- |
-| image | 是 | string | - | 图像数据,base64编码,要求base64图片编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 **注意去掉头部** |
-| threshold | 否 | number | - | 默认为推荐阈值,也可自行根据需要进行设置 |
-
-## 3. http 返回数据
-
-| 字段 | 类型说明 | 其他 |
-| ---------- | ------ | ------------------------------------ |
-| error_code | Number | 0为成功,非0参考message获得具体错误信息 |
-| results | Array | 内容为具体的识别结果。其中字段的具体含义请参考`预测图像-返回格式`一节 |
-| cost_ms | Number | 预测耗时ms,不含网络交互时间 |
-
-返回示例
-
-```json
-{
- "cost_ms": 52,
- "error_code": 0,
- "results": [
- {
- "confidence": 0.94482421875,
- "index": 1,
- "label": "IronMan",
- "x1": 0.059185408055782318,
- "x2": 0.18795496225357056,
- "y1": 0.14762254059314728,
- "y2": 0.52510076761245728,
- "mask": "...", // 图像分割模型字段
- "trackId": 0, // 目标追踪模型字段
- },
-
- ]
-}
-```
-
-*** 关于矩形坐标 ***
-
-x1 * 图片宽度 = 检测框的左上角的横坐标
-
-y1 * 图片高度 = 检测框的左上角的纵坐标
-
-x2 * 图片宽度 = 检测框的右下角的横坐标
-
-y2 * 图片高度 = 检测框的右下角的纵坐标
-
-*** 关于分割模型 ***
-
-其中,mask为分割模型的游程编码,解析方式可参考 [http demo](https://github.com/Baidu-AIP/EasyDL-Segmentation-Demo)。
-
-# FAQ
-
-1. 执行infer_demo文件时,提示your generated code is out of date and must be regenerated with protoc >= 3.19.0
-
-进入当前项目,首先卸载protobuf
-
-```shell
-python3 -m pip uninstall protobuf
-```
-
-安装低版本protobuf
-
-```shell
-python3 -m pip install protobuf==3.19.0
-```
diff --git a/docs/Windows-Python-SDK-Inference.md b/docs/Windows-Python-SDK-Inference.md
deleted file mode 100644
index 877488c22e..0000000000
--- a/docs/Windows-Python-SDK-Inference.md
+++ /dev/null
@@ -1,381 +0,0 @@
-# 简介
-
-本文档以[千分类模型_MobileNetV3](https://ai.baidu.com/easyedge/app/openSource)为例,介绍 FastDeploy中的模型SDK ,在**Intel x86_64 / NVIDIA GPU Windows Python** 环境下: (1)图像推理部署步骤; (2)介绍模型推流全流程API,方便开发者了解项目后二次开发。
-其中Windows Python请参考[Windows C++环境下的推理部署](./Windows-CPP-SDK-Inference.md)文档。
-
-
-
-* [简介](#简介)
-
-* [环境准备](#环境准备)
-
- * [1. SDK下载](#1-sdk下载)
- * [2. Python环境](#2-python环境)
- * [3. 安装依赖](#3-安装依赖)
- * [3.1 安装paddlepaddle](#31-安装paddlepaddle)
- * [3.2 安装EasyEdge Python Wheel 包](#32-安装easyedge-python-wheel-包)
-
-* [快速开始](#快速开始)
-
- * [1. 文件结构说明](#1-文件结构说明)
- * [2. 测试Demo](#2-测试demo)
- * [2.1 预测图像](#21-预测图像)
-
-* [预测API流程详解](#预测api流程详解)
-
- * [1. 基础流程](#1-基础流程)
- * [2. 初始化](#2-初始化)
- * [3. SDK参数配置](#3-sdk参数配置)
- * [4. 预测图像](#4-预测图像)
-
-* [FAQ](#faq)
-
-
-
-# 环境准备
-
-## 1. SDK下载
-
-根据开发者模型、部署芯片、操作系统需要,在图像界面[飞桨开源模型](https://ai.baidu.com/easyedge/app/openSource)或[GIthub](https://github.com/PaddlePaddle/FastDeploy)中选择对应的SDK进行下载。解压缩后的文件结构如下所示:
-
-```shell
-EasyEdge-win-[部署芯片]
-├── data # 模型文件资源文件夹,可替换为其他模型
-├── ... # C++/C# 相关文件
-├── python # Python SDK文件
-├── EasyEdge.exe # 主程序
-└── README.md # 环境说明
-```
-
-
-
-## 2. Python环境
-
-> 当前SDK仅支持Python 3.7
-
-打开命令行工具,使用如下命令获取已安装的Python版本号。如果还没有安装Python环境,可以前往[官网](https://www.python.org/)下载Python 3.7对应的安装程序,特别要注意勾上`Add Python 3.7 to PATH`,然后点“Install Now”即可完成安装。
-
-```shell
-python --version
-```
-
-如果本机的版本不匹配,建议使用[pyenv](https://github.com/pyenv/pyenv)、[anaconda](https://www.anaconda.com/)等Python版本管理工具对Python SDK所在目录进行配置。
-
-接着使用如下命令确认pip的版本是否满足要求,要求pip版本为20.2.2或更高版本。详细的pip安装过程可以参考[官网教程](https://pip.pypa.io/en/stable/installation/)。
-
-```shell
-python -m pip --version
-```
-
-## 3. 安装依赖
-
-### 3.1 安装paddlepaddle
-
-根据具体的部署芯片(CPU/GPU)安装对应的PaddlePaddle的whl包。`x86_64 CPU` 平台可以使用如下命令进行安装:
-
-```shell
-python -m pip install paddlepaddle==2.2.2 -i https://mirror.baidu.com/pypi/simple
-```
-
-`NVIDIA GPU平台`的详细安装教程可以参考[官网Paddle安装教程](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)。
-
-> 使用 NVIDIA GPU 预测时,必须满足:
->
-> 1. 机器已安装 cuda, cudnn
->
-> 2. 已正确安装对应 cuda 版本的paddle 版本
-> 3. 通过设置环境变量`FLAGS_fraction_of_gpu_memory_to_use`设置合理的初始内存使用比例
-
-
-
-### 3.2 安装EasyEdge Python Wheel 包
-
-在`python`目录下,安装Python3.7版本对应的EasyEdge Wheel包。对`x86_64 CPU` 或 `x86_64 Nvidia GPU平台 `可以使用如下命令进行安装,具体名称以 Python SDK 包中的 whl 为准。
-
-```shell
-python -m pip install -U BaiduAI_EasyEdge_SDK-{SDK版本号}-cp37-cp37m-win_amd64.whl
-```
-
-
-
-# 快速开始
-
-
-
-## 1. 文件结构说明
-
-Python SDK文件结构如下:
-
-```shell
-EasyEdge-win-[部署芯片]
-├── data # 模型文件资源文件夹,可替换为其他模型
-│ ├── model # 模型文件资源文件夹,可替换为其他模型
-│ └── config # 配置文件
-├── ... # C++/C# 相关文件
-├── python # Python SDK文件
-│ ├── # 特定Python 3.7版本的EasyEdge Wheel包, 二次开发可使用
-│ ├── BaiduAI_EasyEdge_SDK-${SDK版本号}-cp37-cp37m-win_amd64.whl
-│ ├── requirements.txt #
-│ ├── infer_demo # demo体验完整文件
-│ │ ├── demo_xxx.py # 包含前后处理的端到端推理demo文件
-│ │ └── demo_serving.py # 提供http服务的demo文件
-│ └── tensor_demo # tensor in/out demo文件
-```
-
-
-
-## 2. 测试Demo
-
-
-
-### 2.1 预测图像
-
-根据部署平台,使用infer_demo文件夹下的demo文件,执行如下命令。
-
-```shell
-python demo_x86_cpu.py {模型model文件夹} {测试图片路径}
-```
-
-运行效果示例:
-
-
-
-```shell
-2022-06-14 18:35:44 DEBUG [EasyEdge] [demo_x86_cpu.py:41] 19424: Config:: w: 256, h: 256; mean: [123.675, 116.28, 103.53]; scale: [0.01712475 0.017507 0.01742919]
-2022-06-14 18:35:44 INFO [EasyEdge] [demo_x86_cpu.py:41] 19424: Init paddlefluid engine...
-2022-06-14 18:35:45 INFO [EasyEdge] [demo_x86_cpu.py:41] 19424: Paddle version: 2.2.2
-2022-06-14 18:35:45 DEBUG [EasyEdge] [demo_x86_cpu.py:41] 19424: CPU thread num set to 1
-2022-06-14 18:35:45 DEBUG [EasyEdge] [demo_x86_cpu.py:55] 19424: resize to w257, h256
-2022-06-14 18:35:45 DEBUG [EasyEdge] [demo_x86_cpu.py:55] 19424: Switch to CHW
-2022-06-14 18:35:45 DEBUG [EasyEdge] [demo_x86_cpu.py:55] 19424: Infer cost: 70.1(66.1) ms
-{'confidence': 0.9012351036071777, 'index': 8, 'label': 'n01514859 hen'}
-```
-
-可以看到,运行结果为`index:8,label:hen`,通过imagenet [类别映射表](https://gist.github.com/yrevar/942d3a0ac09ec9e5eb3a),可以找到对应的类别,即 'hen',由此说明我们的预测结果正确。
-
-# 预测API流程详解
-
-本章节主要结合前文的Demo示例来介绍推理API,方便开发者学习并将运行库嵌入到开发者的程序当中,更详细的API请参考`infer_demo/demo_xx_xx.py`文件,查看下面的Python代码中的step注释说明。
-
-## 1. 基础流程
-
-> ❗注意,请优先参考SDK中自带demo的使用流程和说明。遇到错误,请优先参考文件中的注释、解释、日志说明。
-
-`infer_demo/demo_xx_xx.py`
-
-```python
-# 引入EasyEdge运行库
-import BaiduAI.EasyEdge as edge
-
-# 创建并初始化一个预测Progam;选择合适的引擎
-pred = edge.Program()
-pred.init(model_dir={RES文件夹路径}, device=edge.Device.CPU, engine=edge.Engine.PADDLE_FLUID) # x86_64 CPU
-# pred.init(model_dir=_model_dir, device=edge.Device.GPU, engine=edge.Engine.PADDLE_FLUID) # x86_64 Nvidia GPU
-# pred.init(model_dir=_model_dir, device=edge.Device.CPU, engine=edge.Engine.PADDLE_LITE) # armv8 CPU
-
-# 预测图像
-res = pred.infer_image({numpy.ndarray的图片})
-
-# 关闭结束预测Progam
-pred.close()
-```
-
-`infer_demo/demo_serving.py`
-
-```python
-import BaiduAI.EasyEdge as edge
-from BaiduAI.EasyEdge.serving import Serving
-
-# 创建并初始化Http服务
-server = Serving(model_dir={RES文件夹路径}, license=serial_key)
-
-# 运行Http服务
-# 请参考同级目录下demo_xx_xx.py里:
-# pred.init(model_dir=xx, device=xx, engine=xx, device_id=xx)
-# 对以下参数device\device_id和engine进行修改
-server.run(host=host, port=port, device=edge.Device.CPU, engine=edge.Engine.PADDLE_FLUID) # x86_64 CPU
-# server.run(host=host, port=port, device=edge.Device.GPU, engine=edge.Engine.PADDLE_FLUID) # x86_64 Nvidia GPU
-# server.run(host=host, port=port, device=edge.Device.CPU, engine=edge.Engine.PADDLE_LITE) # armv8 CPU
-```
-
-## 2. 初始化
-
-- 接口
-
-```python
- def init(self,
- model_dir,
- device=Device.CPU,
- engine=Engine.PADDLE_FLUID,
- config_file='conf.json',
- preprocess_file='preprocess_args.json',
- model_file='model',
- params_file='params',
- label_file='label_list.txt',
- infer_cfg_file='infer_cfg.json',
- device_id=0,
- thread_num=1
- ):
- """
- Args:
- model_dir: str
- device: BaiduAI.EasyEdge.Device,比如:Device.CPU
- engine: BaiduAI.EasyEdge.Engine, 比如: Engine.PADDLE_FLUID
- config_file: str
- preprocess_file: str
- model_file: str
- params_file: str
- label_file: str 标签文件
- infer_cfg_file: 包含预处理、后处理信息的文件
- device_id: int 设备ID
- thread_num: int CPU的线程数
-
- Raises:
- RuntimeError, IOError
- Returns:
- bool: True if success
- """
-```
-
-若返回不是True,请查看输出日志排查错误原因。
-
-## 3. SDK参数配置
-
-使用 CPU 预测时,可以通过在 init 中设置 thread_num 使用多线程预测。如:
-
-```python
-pred.init(model_dir=_model_dir, device=edge.Device.CPU, engine=edge.Engine.PADDLE_FLUID, thread_num=4)
-```
-
-使用 GPU 预测时,可以通过在 init 中设置 device_id 指定需要的GPU device id。如:
-
-```python
-pred.init(model_dir=_model_dir, device=edge.Device.GPU, engine=edge.Engine.PADDLE_FLUID, device_id=0)
-```
-
-## 4. 预测图像
-
-- 接口
-
-```python
- def infer_image(self, img,
- threshold=0.3,
- channel_order='HWC',
- color_format='BGR',
- data_type='numpy')
- """
-
- Args:
- img: np.ndarray or bytes
- threshold: float
- only return result with confidence larger than threshold
- channel_order: string
- channel order HWC or CHW
- color_format: string
- color format order RGB or BGR
- data_type: string
- 仅在图像分割时有意义。 'numpy' or 'string'
- 'numpy': 返回已解析的mask
- 'string': 返回未解析的mask游程编码
-
- Returns:
- list
-
- """
-```
-
-| 字段 | 类型 | 取值 | 说明 |
-| ---------- | -------------------- | --------- | ------------------------ |
-| confidence | float | 0~1 | 分类或检测的置信度 |
-| label | string | | 分类或检测的类别 |
-| index | number | | 分类或检测的类别 |
-| x1, y1 | float | 0~1 | 物体检测,矩形的左上角坐标 (相对长宽的比例值) |
-| x2, y2 | float | 0~1 | 物体检测,矩形的右下角坐标(相对长宽的比例值) |
-| mask | string/numpy.ndarray | 图像分割的mask | |
-
-***关于矩形坐标***
-
-x1 * 图片宽度 = 检测框的左上角的横坐标
-
-y1 * 图片高度 = 检测框的左上角的纵坐标
-
-x2 * 图片宽度 = 检测框的右下角的横坐标
-
-y2 * 图片高度 = 检测框的右下角的纵坐标
-
-可以参考 demo 文件中使用 opencv 绘制矩形的逻辑。
-
-***结果示例***
-
-i) 图像分类
-
-```json
-{
- "index": 736,
- "label": "table",
- "confidence": 0.9
-}
-```
-
-ii) 物体检测
-
-```json
-{
- "index": 8,
- "label": "cat",
- "confidence": 1.0,
- "x1": 0.21289,
- "y1": 0.12671,
- "x2": 0.91504,
- "y2": 0.91211,
-}
-```
-
-iii) 图像分割
-
-```json
-{
- "name": "cat",
- "score": 1.0,
- "location": {
- "left": ...,
- "top": ...,
- "width": ...,
- "height": ...,
- },
- "mask": ...
-}
-```
-
-mask字段中,data_type为`numpy`时,返回图像掩码的二维数组
-
-```text
-{
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-}
-其中1代表为目标区域,0代表非目标区域
-```
-
-data_type为`string`时,mask的游程编码,解析方式可参考 [demo](https://github.com/Baidu-AIP/EasyDL-Segmentation-Demo)。
-
-
-# FAQ
-
-1. 执行infer_demo文件时,提示your generated code is out of date and must be regenerated with protoc >= 3.19.0
-
-进入当前项目,首先卸载protobuf
-
-```shell
-python3 -m pip uninstall protobuf
-```
-
-安装低版本protobuf
-
-```shell
-python3 -m pip install protobuf==3.19.0
-```
diff --git a/docs/Windows-Python-SDK-Serving.md b/docs/Windows-Python-SDK-Serving.md
deleted file mode 100644
index 36999b45a1..0000000000
--- a/docs/Windows-Python-SDK-Serving.md
+++ /dev/null
@@ -1,262 +0,0 @@
-# 简介
-
-本文档以[千分类模型_MobileNetV3](https://ai.baidu.com/easyedge/app/openSource)为例,介绍FastDeploy中的模型SDK,在**Intel x86_64 /NVIDIA GPU、Windows操作系统** 的Python环境:(1)HTTP服务化推理部署步骤,(2)介绍推理全流程API,方便开发者了解项目后二次开发。
-如果开发者对C++语言的相关能力感兴趣,可以参考Windows C++请参考[Windows C++环境下的推理部署](./Windows-CPP-SDK-Serving.md)文档。
-
-
-
-* [简介](#简介)
-
-* [环境准备](#环境准备)
-
- * [1. SDK下载](#1-sdk下载)
- * [2. Python环境](#2-python环境)
- * [3. 安装依赖](#3-安装依赖)
- * [3.1 安装paddlepaddle](#31-安装paddlepaddle)
- * [3.2 安装EasyEdge Python Wheel 包](#32-安装easyedge-python-wheel-包)
-
-* [快速开始](#快速开始)
-
- * [1. 文件结构说明](#1-文件结构说明)
- * [2. 测试Demo](#2-测试demo)
- * [2.1 启动HTTP预测服务](#21-启动http预测服务)
-
-* [HTTP API流程详解](#http-api流程详解)
-
- * [1. 开启http服务](#1-开启http服务)
-
- * [2. 请求http服务](#2-请求http服务)
-
- * [2.1 http 请求方式:不使用图片base64格式](#21-http-请求方式不使用图片base64格式)
-
- * [3. http返回数据](#3-http返回数据)
-
-
-
-# 环境准备
-
-## 1. SDK下载
-
-根据开发者模型、部署芯片、操作系统需要,在图像界面[飞桨开源模型](https://ai.baidu.com/easyedge/app/openSource)或[GIthub](https://github.com/PaddlePaddle/FastDeploy)中选择对应的SDK进行下载。解压缩后的文件结构如下所示:
-
-```shell
-EasyEdge-win-[部署芯片]
-├── data # 模型文件资源文件夹,可替换为其他模型
-├── ... # C++/C# 相关文件
-├── python # Python SDK文件
-├── EasyEdge.exe # 主程序
-└── README.md # 环境说明
-```
-
-## 2. Python环境
-
-> 当前SDK仅支持Python 3.7
-
-打开命令行工具,使用如下命令获取已安装的Python版本号。如果还没有安装Python环境,可以前往[官网](https://www.python.org/)下载Python 3.7对应的安装程序,特别要注意勾上`Add Python 3.7 to PATH`,然后点“Install Now”即可完成安装。
-
-```shell
-python --version
-```
-
-如果本机的版本不匹配,建议使用[pyenv](https://github.com/pyenv/pyenv)、[anaconda](https://www.anaconda.com/)等Python版本管理工具对Python SDK所在目录进行配置。
-
-接着使用如下命令确认pip的版本是否满足要求,要求pip版本为20.2.2或更高版本。详细的pip安装过程可以参考[官网教程](https://pip.pypa.io/en/stable/installation/)。
-
-```shell
-python -m pip --version
-```
-
-## 3. 安装依赖
-
-### 3.1 安装paddlepaddle
-
-根据具体的部署芯片(CPU/GPU)安装对应的PaddlePaddle的whl包。`x86_64 CPU` 平台可以使用如下命令进行安装:
-
-```shell
-python -m pip install paddlepaddle==2.2.2 -i https://mirror.baidu.com/pypi/simple
-```
-
-`NVIDIA GPU平台`的详细安装教程可以参考[官网Paddle安装教程](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)。
-
-> 使用 NVIDIA GPU 预测时,必须满足:
->
-> 1. 机器已安装 cuda, cudnn
->
-> 2. 已正确安装对应 cuda 版本的paddle 版本
-> 3. 通过设置环境变量`FLAGS_fraction_of_gpu_memory_to_use`设置合理的初始内存使用比例
-
-### 3.2 安装EasyEdge Python Wheel 包
-
-在`python`目录下,安装Python3.7版本对应的EasyEdge Wheel包。对`x86_64 CPU` 或 `x86_64 Nvidia GPU平台 `可以使用如下命令进行安装,具体名称以 Python SDK 包中的 whl 为准。
-
-```shell
-python -m pip install -U BaiduAI_EasyEdge_SDK-{SDK版本号}-cp37-cp37m-win_amd64.whl
-```
-
-# 快速开始
-
-## 1. 文件结构说明
-
-Python SDK文件结构如下:
-
-```shell
-EasyEdge-win-[部署芯片]
-├── data # 模型文件资源文件夹,可替换为其他模型
-│ ├── model # 模型文件资源文件夹,可替换为其他模型
-│ └── config # 配置文件
-├── ... # C++/C# 相关文件
-├── python # Python SDK文件
-│ ├── # 特定Python 3.7版本的EasyEdge Wheel包, 二次开发可使用
-│ ├── BaiduAI_EasyEdge_SDK-${SDK版本号}-cp37-cp37m-win_amd64.whl
-│ ├── requirements.txt #
-│ ├── infer_demo # demo体验完整文件
-│ │ ├── demo_xxx.py # 包含前后处理的端到端推理demo文件
-│ │ └── demo_serving.py # 提供http服务的demo文件
-│ └── tensor_demo # tensor in/out demo文件
-```
-
-## 2. 测试Demo
-
-### 2.1 启动HTTP预测服务
-
-```shell
-python demo_serving.py {模型model文件夹} {host, default 0.0.0.0} {port, default 24401}
-```
-
-成功启动后,终端中会显示如下字样。
-
-```shell
-2022-06-14 18:45:15 INFO [EasyEdge] [demo_serving.py:50] 21212: Init paddlefluid engine...
-2022-06-14 18:45:16 INFO [EasyEdge] [demo_serving.py:50] 21212: Paddle version: 2.2.2
- * Serving Flask app 'Serving' (lazy loading)
- * Environment: production
- WARNING: This is a development server. Do not use it in a production deployment.
- Use a production WSGI server instead.
- * Debug mode: off
- * Running on all addresses (0.0.0.0)
- WARNING: This is a development server. Do not use it in a production deployment.
- * Running on http://127.0.0.1:24401
- * Running on http://192.168.3.17:24401 (Press CTRL+C to quit)
-```
-
-开发者此时可以打开浏览器,输入`http://{host ip}:24401`,选择图片或者视频来进行测试,运行效果如下。
-
-
-

-
-
-# HTTP API流程详解
-
-本章节主要结合前文的Demo示例来对API进行介绍,方便开发者学习并将运行库嵌入到开发者的程序当中,更详细的API请参考对应的Python文件。http服务包含服务端和客户端,Demo中提供了不使用图片base格式的`方式一:浏览器请求的方式`,其他几种方式开发者根据个人需要,选择开发。
-
-## 1. 开启http服务
-
-http服务的启动使用`demo_serving.py`文件
-
-```python
-class Serving(object):
- """ SDK local serving """
-
- def __init__(self, model_dir, license='', model_filename='model', params_filename='params'):
-
- self.program = None
- self.model_dir = model_dir
- self.model_filename = model_filename
- self.params_filename = params_filename
- self.program_lock = threading.Lock()
- self.license_key = license
- # 只有ObjectTracking会初始化video_processor
- self.video_processor = None
-
- def run(self, host, port, device, engine=Engine.PADDLE_FLUID, service_id=0, device_id=0, **kwargs):
- """ Args: host : str port : str device : BaiduAI.EasyEdge.Device,比如:Device.CPU engine : BaiduAI.EasyEdge.Engine, 比如: Engine.PADDLE_FLUID """
- self.run_serving_with_flask(host, port, device, engine, service_id, device_id, **kwargs)
-```
-
-## 2. 请求http服务
-
-> 开发者可以打开浏览器,`http://{设备ip}:24401`,选择图片来进行测试。
-
-### 2.1 http 请求方式:不使用图片base64格式
-
-URL中的get参数:
-
-| 参数 | 说明 | 默认值 |
-| --------- | --------- | ---------------- |
-| threshold | 阈值过滤, 0~1 | 如不提供,则会使用模型的推荐阈值 |
-
-HTTP POST Body即为图片的二进制内容。
-
-Python请求示例
-
-```python
-import requests
-
-with open('./1.jpg', 'rb') as f:
- img = f.read()
- result = requests.post(
- 'http://127.0.0.1:24401/',
- params={'threshold': 0.1},
- data=img).json()
-```
-
-## 3. http返回数据
-
-| 字段 | 类型说明 | 其他 |
-| ---------- | ------ | ------------------------------------ |
-| error_code | Number | 0为成功,非0参考message获得具体错误信息 |
-| results | Array | 内容为具体的识别结果。其中字段的具体含义请参考`预测图像-返回格式`一节 |
-| cost_ms | Number | 预测耗时ms,不含网络交互时间 |
-
-返回示例
-
-```json
-{
- "cost_ms": 52,
- "error_code": 0,
- "results": [
- {
- "confidence": 0.94482421875,
- "index": 1,
- "label": "IronMan",
- "x1": 0.059185408055782318,
- "x2": 0.18795496225357056,
- "y1": 0.14762254059314728,
- "y2": 0.52510076761245728,
- "mask": "...", // 图像分割模型字段
- "trackId": 0, // 目标追踪模型字段
- },
-
- ]
-}
-```
-
-***关于矩形坐标***
-
-x1 * 图片宽度 = 检测框的左上角的横坐标
-
-y1 * 图片高度 = 检测框的左上角的纵坐标
-
-x2 * 图片宽度 = 检测框的右下角的横坐标
-
-y2 * 图片高度 = 检测框的右下角的纵坐标
-
-***关于分割模型***
-
-其中,mask为分割模型的游程编码,解析方式可参考 [demo](https://github.com/Baidu-AIP/EasyDL-Segmentation-Demo)。
-
-**FAQ**
-
-1. 执行infer_demo文件时,提示your generated code is out of date and must be regenerated with protoc >= 3.19.0
-
-进入当前项目,首先卸载protobuf
-
-```shell
-python3 -m pip uninstall protobuf
-```
-
-安装低版本protobuf
-
-```shell
-python3 -m pip install protobuf==3.19.0
-```
diff --git a/docs/compile/README.md b/docs/compile/README.md
new file mode 100644
index 0000000000..909ac893ca
--- /dev/null
+++ b/docs/compile/README.md
@@ -0,0 +1,17 @@
+# FastDeploy编译
+
+本文档说明编译C++预测库、Python预测库两种编译过程,根据编译的平台参考如下文档
+
+- [Linux & Mac 编译](linux_and_mac.md)
+- [Windows编译](windows.md)
+
+其中编译过程中,各平台上编译选项如下表所示
+
+| 选项 | 作用 | 备注 |
+|:---- | :--- | :--- |
+| ENABLE_ORT_BACKEND | 启用ONNXRuntime推理后端,默认ON | - |
+| WIGH_GPU | 是否开启GPU使用,默认OFF | 当设为TRUE时,须通过CUDA_DIRECTORY指定cuda目录,如/usr/local/cuda; Mac上不支持设为ON |
+| ENABLE_TRT_BACKEND | 启用TensorRT推理后端,默认OFF | 当设为TRUE时,需通过TRT_DIRECTORY指定tensorrt目录,如/usr/downloads/TensorRT-8.4.0.1; Mac上不支持设为ON|
+| ENABLE_VISION | 编译集成视觉模型模块,包括OpenCV的编译集成,默认OFF | - |
+| ENABLE_PADDLE_FRONTEND | 编译集成Paddle2ONNX,默认ON | - |
+| ENABLE_DEBUG | 当为ON时,支持输出DEBUG信息,但可能会有性能损耗,默认OFF | - |
diff --git a/docs/compile/linux_and_mac.md b/docs/compile/linux_and_mac.md
new file mode 100644
index 0000000000..93e2db580e
--- /dev/null
+++ b/docs/compile/linux_and_mac.md
@@ -0,0 +1,32 @@
+# Linux & Mac编译
+
+## 编译C++
+```
+git clone https://gitee.com/jiangjiajun/FastDeploy.git
+cd FastDeploy
+git submodule init
+git submodule update
+mkdir build & cd build
+cmake .. -DENABLE_ORT_BACKEND=ON \
+ -DENABLE_VISION=ON \
+ -DCMAKE_INSTALL_PREFIX=${PWD}/fastdeploy-0.0.3
+make -j8
+make install
+```
+编译后的预测库即在当前目录下的`fastdeploy-0.0.3`
+
+## 编译Python安装包
+```
+git clone https://gitee.com/jiangjiajun/FastDeploy.git
+cd FastDeploy
+git submodule init
+git submodule update
+# Python通过export环境变量设置编译选项
+export ENABLE_ORT_BACKEND=ON
+export ENABLE_VISION=ON
+python setup.py build
+python setup.py bdist_wheel
+```
+编译后的wheel包即在当前目录下的`dist`目录中
+
+编译选项说明参考[编译指南](./README.md)
diff --git a/docs/compile/windows.md b/docs/compile/windows.md
new file mode 100644
index 0000000000..78a9209cdf
--- /dev/null
+++ b/docs/compile/windows.md
@@ -0,0 +1,3 @@
+# Windows编译
+
+还没写
diff --git a/docs/cpp/README.md b/docs/cpp/README.md
new file mode 100644
index 0000000000..72524b214e
--- /dev/null
+++ b/docs/cpp/README.md
@@ -0,0 +1,110 @@
+# C++部署
+
+## 准备预测库
+
+参考编译文档[FastDeploy编译](../compile/README.md)进行编译,或直接使用如下预编译库
+
+| 编译库 | 平台 | 支持设备 | 说明 |
+|:------ | :---- | :------- | :----- |
+|[fastdeploy-linux-x64-0.0.3.tgz](https://bj.bcebos.com/paddle2onnx/fastdeploy/fastdeploy-linux-x64-0.0.3.tgz) | Linux | CPU | 集成ONNXRuntime |
+|[fastdeploy-linux-x64-gpu-0.0.3.tgz](https://bj.bcebos.com/paddle2onnx/fastdeploy/fastdeploy-linux-x64-gpu-0.0.3.tgz) | Linux | CPU/GPU | 集成ONNXRuntime, TensorRT |
+|[fastdeploy-osx-x86_64-0.0.3.tgz](https://bj.bcebos.com/paddle2onnx/fastdeploy/fastdeploy-osx-x86_64-0.0.3.tgz) | Mac OSX Intel CPU | CPU | 集成ONNXRuntime |
+|[fastdeploy-osx-arm64-0.0.3.tgz](https://bj.bcebos.com/paddle2onnx/fastdeploy/fastdeploy-osx-arm64-0.0.3.tgz) | Mac OSX M1 CPU | CPU | 集成ONNXRuntime |
+
+
+## 使用
+
+FastDeploy提供了多种领域内的模型,可快速完成模型的部署,本文档以YOLOv5在Linux上的部署为例
+
+```
+# 下载库并解压
+wget https://bj.bcebos.com/paddle2onnx/fastdeploy/fastdeploy-linux-x64-0.0.3.tgz
+tar xvf fastdeploy-linux-x64-0.0.3.tgz
+
+# 下载模型和测试图片
+wget https://github.com/ultralytics/yolov5/releases/download/v6.0/yolov5s.onnx
+wget https://raw.githubusercontent.com/ultralytics/yolov5/master/data/images/bus.jpg
+```
+
+### YOLOv5预测代码
+
+准备如下`yolov5.cc`代码
+```
+#include "fastdeploy/vision.h"
+
+int main() {
+ typedef vis = fastdeploy::vision;
+
+ auto model = vis::ultralytics::YOLOv5("yolov5s.onnx"); // 加载模型
+
+ if (!model.Initialized()) { // 判断模型是否初始化成功
+ std::cerr << "Initialize failed." << std::endl;
+ return -1;
+ }
+
+ cv::Mat im = cv::imread("bus.jpg"); // 读入图片
+
+ vis::DetectionResult res;
+ if (!model.Predict(&im, &res)) { // 预测图片
+ std::cerr << "Prediction failed." << std::endl;
+ return -1;
+ }
+
+ std::cout << res.Str() << std::endl; // 输出检测结果
+ return 0;
+}
+```
+
+### 编译代码
+
+编译前先完成CMakeLists.txt的开发,在`yolov5.cc`同级目录创建`CMakeLists.txt`文件,内容如下
+```
+PROJECT(yolov5_demo C CXX)
+CMAKE_MINIMUM_REQUIRED (VERSION 3.16)
+# 在低版本ABI环境中,可通过如下代码进行兼容性编译
+# add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
+
+# 在下面指定下载解压后的fastdeploy库路径
+set(FASTDEPLOY_INSTALL_DIR /ssd1/download/fastdeploy-linux-x64-0.0.3/)
+
+include(${FASTDEPLOY_INSTALL_DIR}/FastDeploy.cmake)
+
+# 添加FastDeploy依赖头文件
+include_directories(${FASTDEPLOY_INCS})
+
+add_executable(yolov5_demo ${PROJECT_SOURCE_DIR}/yolov5.cc)
+message(${FASTDEPLOY_LIBS})
+# 添加FastDeploy库依赖
+target_link_libraries(yolov5_demo ${FASTDEPLOY_LIBS})
+~
+```
+
+此时当前目录结构如下所示
+```
+- demo_directory
+|___fastdeploy-linux-x64-0.0.3/ # 预测库解压
+|___yolov5.cc # 示例代码
+|___CMakeLists.txt # cmake文件
+|___yolov5s.onnx # 模型文件
+|___bus.jpeg # 测试图片
+```
+
+执行如下命令进行编译
+```
+cmake .
+make -j
+```
+编译后可执行二进制即为当前目录下的`yolov5_demo`,使用如下命令执行
+```
+./yolov5_demo
+```
+
+即会加载模型进行推理,得到结果如下
+```
+DetectionResult: [xmin, ymin, xmax, ymax, score, label_id]
+223.395126,403.948669, 345.337189, 867.339050, 0.856906, 0
+668.301758,400.781372, 808.441772, 882.534973, 0.829716, 0
+50.210758,398.571289, 243.123383, 905.016846, 0.805375, 0
+23.768217,214.979355, 802.627869, 778.840820, 0.756311, 5
+0.737200,552.281006, 78.617218, 890.945007, 0.363471, 0
+```
diff --git a/docs/iOS-SDK.md b/docs/iOS-SDK.md
deleted file mode 100644
index 5a1fa0ffca..0000000000
--- a/docs/iOS-SDK.md
+++ /dev/null
@@ -1,212 +0,0 @@
-# 简介
-
-本文档介绍FastDeploy中的模型SDK,在iOS环境下:(1)推理部署步骤;(2)介绍SDK使用说明,方便开发者了解项目后二次开发。
-
-
-
-* [简介](#简介)
-
-* [系统支持说明](#系统支持说明)
-
- * [1. 系统支持说明](#1-系统支持说明)
- * [2. SDK大小说明](#2-sdk大小说明)
-
-* [快速开始](#快速开始)
-
- * [1. 项目结构说明](#1-项目结构说明)
- * [2. 测试Demo](#2-测试demo)
-
-* [SDK使用说明](#sdk使用说明)
-
- * [1. 集成指南](#1-集成指南)
- * [1.1 依赖库集成](#11-依赖库集成)
- * [2. 调用流程示例](#2-调用流程示例)
- * [2.1 初始化](#21-初始化)
- * [2.2 预测图像](#22-预测图像)
-
-* [FAQ](#faq)
-
-
-
-# 系统支持说明
-
-## 1. 系统支持说明
-
-1. 系统支持:iOS 9.0及以上。
-
-2. 硬件支持:支持 arm64 (Starndard architectures),暂不支持模拟器。
-
- * 官方验证过的手机机型:大部分ARM 架构的手机、平板及开发板。
-
-3.其他说明
-
- * 3.1 【图像分割类模型】(1)图像分割类Demo暂未提供实时摄像头录制拍摄的能力,开发者可根据自己需要,进行安卓开发完成;(2)PP-Humanseg-Lite模型设计初衷为横屏视频会议等场景,本次安卓开发仅支持述评场景,开发者可根据自己需要,开发横屏的Android功能。
-
- * 3.2 【OCR模型】OCR任务第一次启动任务,第一张推理时间久,属于正常情况(因为涉及到模型加载、预处理等工作)。
-
-## 2. SDK大小说明
-
-1. 模型资源文件大小影响 SDK 大小
-2. SDK 包及 IPA 安装包虽然比较大,但最终安装到设备后所占大小会缩小很多。这与 multi architechtures、bitcode 和 AppStore 的优化有关。
-
-# 快速开始
-
-## 1. 项目结构说明
-
-根据开发者模型、部署芯片、操作系统需要,在图像界面[飞桨开源模型](https://ai.baidu.com/easyedge/app/openSource)或[GIthub](https://github.com/PaddlePaddle/FastDeploy)中选择对应的SDK进行下载。SDK目录结构如下:
-
-```
-.EasyEdge-iOS-SDK
-├── EasyDLDemo # Demo工程文件
-├── LIB # 依赖库
-├── RES
-│ ├── easyedge # 模型资源文件夹,一套模型适配不同硬件、OS和部署方式
-│ ├── conf.json # Android、iOS系统APP名字需要
-│ ├── model # 模型结构文件
-│ ├── params # 模型参数文件
-│ ├── label_list.txt # 模型标签文件
-│ ├── infer_cfg.json # 模型前后处理等配置文件
-└── DOC # 文档
-```
-
-## 2. 测试Demo
-
-按如下步骤可直接运行 SDK 体验 Demo:
-步骤一:用 Xcode 打开 `EasyDLDemo/EasyDLDemo.xcodeproj`
-步骤二:配置开发者自己的签名(不了解签名机制的,可以看FAQ [iOS签名介绍](#100))
-步骤三:连接手机运行,不支持模拟器
-
-检测模型运行示例:
-
-
-
-# SDK使用说明
-
-本节介绍如何将 SDK 接入开发者的项目中使用。
-
-## 1. 集成指南
-
-步骤一:依赖库集成
-步骤二:`import `
-
-### 1.1 依赖库集成
-
-1. 复制 LIB 目录至项目合适的位置
-2. 配置 Build Settings 中 Search paths: 以 SDK 中 LIB 目录路径为例
-- Framework Search Paths:`${PROJECT_DIR}/../LIB/lib`
-- Header Search Paths:`${PROJECT_DIR}/../LIB/include`
-- Library Search Paths:`${PROJECT_DIR}/../LIB/lib`
-
-> 集成过程如出现错误,请参考 Demo 工程对依赖库的引用
-
-## 2. 调用流程示例
-
-以通用ARM的图像分类预测流程为例,详细说明请参考后续章节:
-
-```
-NSError *err;
-
-// step 1: 初始化模型
-EasyDLModel *model = [[EasyDLModel alloc] initModelFromResourceDirectory:@"easyedge" withError:&err];
-
-// step 2: 准备待预测的图像
-UIImage *image = ...;
-
-// step 3: 预测图像
-NSArray *results = [model detectUIImage:image withFilterScore:0 andError:&err];
-
-// step 4: 解析结果
-for (id res in results) {
- EasyDLClassfiData *clsData = (EasyDLClassfiData *) res;
- NSLog(@"labelIndex=%d, labelName=%@, confidence=%f", clsData.category, clsData.label, clsData.accuracy);
-}
-```
-
-### 2.1 初始化
-
-```
-// 示例
-// 参数一为模型资源文件夹名称
-EasyDLModel *model = [[EasyDLModel alloc] initModelFromResourceDirectory:@"easyedge" withError:&err];
-```
-
-> 模型资源文件夹需以 folder reference 方式加入 Xcode 工程,如 `RES/easyedge` 文件夹在 Demo 工程中表现为蓝色
-
-### 2.2 预测图像
-
-所有模型类型通过以下接口获取预测结果:
-
-```
-// 返回的数组类型不定
-NSArray *results = [model detectUIImage:image withFilterScore:0 andError:&err];
-```
-
-返回的数组类型如下,具体可参考 `EasyDLResultData.h` 中的定义:
-| 模型类型 | 类型 |
-| --- | ---- |
-| 图像分类 | EasyDLClassfiData |
-| 物体检测/人脸检测 | EasyDLObjectDetectionData |
-| 实例分割 | EasyDLObjSegmentationData |
-| 姿态估计 | EasyDLPoseData |
-| 文字识别 | EasyDLOcrData |
-
-# FAQ
-
-1. 如何多线程并发预测?
-
-SDK内部已经能充分利用多核的计算能力。不建议使用并发来预测。
-
-如果开发者想并发使用,请务必注意`EasyDLModel`所有的方法都不是线程安全的。请初始化多个实例进行并发使用,如
-
-```c
-- (void)testMultiThread {
- UIImage *img = [UIImage imageNamed:@"1.jpeg"];
- NSError *err;
- EasyDLModel * model1 = [[EasyDLModel alloc] initModelFromResourceDirectory:@"easyedge" withError:&err];
- EasyDLModel * model2 = [[EasyDLModel alloc] initModelFromResourceDirectory:@"easyedge" withError:&err];
-
- dispatch_queue_t queue1 = dispatch_queue_create("testQueue", DISPATCH_QUEUE_CONCURRENT);
- dispatch_queue_t queue2 = dispatch_queue_create("testQueue2", DISPATCH_QUEUE_CONCURRENT);
-
- dispatch_async(queue1, ^{
- NSError *detectErr;
- for(int i = 0; i < 1000; ++i) {
- NSArray * res = [model1 detectUIImage:img withFilterScore:0 andError:&detectErr];
- NSLog(@"1: %@", res[0]);
- }
- });
-
- dispatch_async(queue2, ^{
- NSError *detectErr;
- for(int i = 0; i < 1000; ++i) {
- NSArray * res = [model2 detectUIImage:img withFilterScore:0 andError:&detectErr];
- NSLog(@"2: %@", res[0]);
- }
- });
-}
-```
-
-2. 编译时出现 Undefined symbols for architecture arm64: ...
-* 出现 `cxx11, vtable` 字样:请引入 `libc++.tbd`
-* 出现 `cv::Mat` 字样:请引入 `opencv2.framework`
-* 出现 `CoreML`, `VNRequest` 字样:请引入`CoreML.framework` 并务必`#import `
-3. 运行时报错 Image not found: xxx ...
-
-请Embed具体报错的库。
-
-4. 编译时报错:Invalid bitcode version
-
-这个可能是开发者使用的 Xcode 低于12导致,可以升级至12版本。
-
-5. 错误说明
-
-SDK 的方法会返回 NSError,直接返回的 NSError 的错误码定义在 `EasyDLDefine.h - EEasyDLErrorCode` 中。NSError 附带 message (有时候会附带 NSUnderlyingError),开发者可根据 code 和 message 进行错误判断和处理。
-
-6. iOS签名说明
-
-iOS 签名是苹果生态对 APP 开发者做的限定,对于个人开发者是免费的,对于企业开发者(譬如APP要上架应用市场),是收费的。此处,仅简单说明作为普通开发者,第一次尝试使用 Xcode编译代码,需要进行的签名操作。
-(1)在Xcode/Preferences/Accounts 中添加个人Apple ID;
-(2)在对应的EasyDLDemo中做如下图设置:
-
-
-(3)(2)后会在手机上安装好对应APP,还需要在手机上`设置/通用/设备管理/开发者应用/信任appleID`,才能运行该 APP。
diff --git a/docs/tech/design.md b/docs/tech/design.md
new file mode 100644
index 0000000000..ec85692266
--- /dev/null
+++ b/docs/tech/design.md
@@ -0,0 +1,24 @@
+# FastDeploy
+
+FastDeploy分为`Runtime`和`应用`模块。
+
+## Runtime
+`Runtime`对应于不同硬件上的不同后端,大部分情况下,一种硬件对应于一种后端,但对于CPU、GPU, 存在多种后端,用户可根据自己的需求进行选择。
+
+| Runtime | 后端 |
+| :------ | :---- |
+| CPU(x86_64) | `fastdeploy::Backend::ORT` |
+| GPU(Nvidia) | `fastdeploy::Backend::ORT` / `fastdeploy::Backend::TRT` |
+
+具体文档参考 [Runtime文档](runtime.md)
+
+
+## 应用
+
+应用是基于`Runtime`提供的上层模型推理,集成了模型端到端的推理功能
+
+- Vision
+- Text
+- Audio
+
+具体文档参考 [Vision文档](vision.md)
diff --git a/docs/tech/models.md b/docs/tech/models.md
new file mode 100644
index 0000000000..07b57c8b1c
--- /dev/null
+++ b/docs/tech/models.md
@@ -0,0 +1,63 @@
+# 模型开发
+
+以`ultralytics/yolov5`为例,在`fastdeploy/vision`目录下新增`ultralytics`目录,并创建代码`yolov5.h`
+
+定义`YOLOv5`类
+
+```
+class YOLOv5 : public FastDeployModel {
+ public:
+ // 构造函数指定模型路径,并默认为ONNX格式
+ YOLOv5(const std::string& model_file)
+ : FastDeployModel(model_file, "", Frontend::ONNX) {
+ size = {640, 640}; // 图像预处理resize大小
+ // 图像填充值
+ padding_value = {114.0, 114.0, 114.0};
+ // 是否只填充到满足stride的最小方框即可
+ bool is_mini_pad = false;
+ // 是否支持图像resize超过原图尺寸
+ bool is_scale_up = true;
+ // 步长,padding到长宽为stride的倍数
+ stride = 32;
+
+ // 通过下面的两个参数,来说明模型在CPU/GPU上支持的后端种类
+ // 指定Device后,默认情况下,会优先选择最前的后端
+ valid_cpu_backends = {Backend::ORT};
+ valid_gpu_backends = {Backend::ORT, Backend::TRT};
+ }
+
+ std::string ModelName() const; // 返回模型名
+
+ // 模型初始化, 须在此函数中主动调用基类的`InitBackend()`函数
+ // 来初始化runtime
+ // 一些模型前后处理的初始化也可在此函数中,如ppdet/ppcls创建一个
+ // 数据预处理pipeline
+ bool Init();
+
+ // 预处理,其中输入是vision::Mat结构,输出是FDTensor
+ // 输出提供给runtime进行推理使用
+ bool Preprocess(Mat* mat, FDTensor* output);
+
+ // 后处理,输入是runtime的输入FDTensor
+ // 一些跟模型相关的预处理参数
+ bool Postprocess(FDTensor& tensor, DetectionResult* res, float conf_thresh, float nms_iou_thresh);
+
+ // 端到端的推理函数,包含前后处理
+ // 因此一般也建议将后处理的部分参数放在这个接口中
+ bool Predict(cv::Mat* im, DetectionResult* result, float conf_thresh = 0.25, float nms_iou_thresh = 0.5);
+};
+```
+
+模型的实现上,并没有特别强的规范约束,但是
+- 1. 一定要继承`FastDeployModel`
+- 2. 确定可用的`valid_cpu_backends`和`valid_gpu_backends`
+- 3. 要实现`Init()`/`ModelName()`/`Predict()`三个接口
+- 4. 建议统一为`Preprocess`和`Postprocess`两个接口作为前后处理所用
+
+
+## 其它
+
+在`vision`中,会提供几类基础的数据结构使用,包括`vision::ClassifyResult`、`vision::DetectionResult`、`vision::SegmentationResult`等作为模型常见的输出结构。 但难免会遇到新的输出结构不在这几类中,对于一定要定制化的数据结构,默认按照下面方式处理
+
+- 1. 如果是大量模型通用的结构,仍然实现在`vision/common.h`中,作为通用的输出结构
+- 2. 如果只是某个模型需要,则实现在如`vision/ultralytics/yolov5.h`中,同时需要自行为此结构体进行pybind封装
diff --git a/docs/tech/runtime.md b/docs/tech/runtime.md
new file mode 100644
index 0000000000..946b4a0246
--- /dev/null
+++ b/docs/tech/runtime.md
@@ -0,0 +1,135 @@
+# fastdeploy::Runtime
+
+## FDTensor Runtime的输入输出数据结构
+
+```
+struct FDTensor {
+ std::vector shape; // 形状
+ std::string name; // 命名
+ FDDataType dtype; // 数据类型
+ Device device = Device::CPU; // 数据存放设备
+
+ void* MutableData(); // 获取tensor内存buffer指针
+
+ // 获取tensor数据,如若tensor数据在其它设备
+ // 此函数会先将数据拷贝至CPU,再返回指向
+ // CPU内存buffer的指针
+ void* Data();
+
+ // 初始化Tensor,并复用外部数据指针
+ // Tensor的内存buffer将由外部的调用者来创建或释放
+ void SetExternalData(const std::vector& new_shape,
+ const FDDataType& data_type,
+ void* data_buffer
+ const Device& dev);
+
+ int Nbytes() const; // 返回tensor数据字节大小
+
+ int Numel() const; // 返回tensor元素个数
+
+ // Debug函数,打印tensor的信息,包含mean、max、min等
+ void PrintInfo(const std::string& prefix = "TensorInfo");
+};
+```
+
+FDTensor是前后处理与`Runtime`进行对接的数据结构,大多情况下建议通过`SetExternalData`来共享用户传入的数据,减小内存拷贝带来的开销。
+
+## Runtime 多后端推理引擎
+
+### RuntimeOption 引擎配置
+```
+struct RuntimeOption {
+ // 模型文件和权重文件
+ std::string model_file;
+ std::string params_file;
+ // 模型格式,当前可支持Frontend::PADDLE / Frontend::ONNX
+ Frontend model_format = Frontend::PADDLE;
+ Backend backend = Backend::ORT:
+
+ // CPU上运行时的线程数
+ int cpu_thread_num = 8;
+
+ // 推理硬件,当前支持Device::CPU / Device::GPU
+ // 在CPU/GPU上需与backend进行搭配选择
+ Device device;
+
+ // Backend::ORT的参数
+ int ort_graph_opt_level;
+ int ort_inter_op_num_threads;
+ int ort_execution_mode;
+
+ // Backend::TRT的参数
+ std::map> trt_fixed_shape;
+ std::map> trt_max_shape;
+ std::map> trt_min_shape;
+ std::map> trt_opt_shape;
+ std::string trt_serialize_file = "";
+ bool trt_enable_fp16 = false;
+ bool trt_enable_int8 = false;
+ size_t trt_max_batch_size = 32;
+};
+```
+
+
+### Runtime 引擎
+
+```
+struct Runtime {
+ // 加载模型,引擎初始化
+ bool Init(const RuntimeOption& _option);
+
+ // 进行推理
+ // 其中输入须正确配置tensor中的name
+ bool Infer(std::vector& inputs, std::vector* outputs);
+
+ int NumInputs(); // 输入个数
+ int NumOutputs(); // 输出个数
+
+ TensorInfo GetInputInfo(int index) // 获取输入信息,包括shape, dtype, name
+ TensorInfo GetOutputInfo(int index) // 获取输出信息,包括shape, dtype, name
+
+ RuntimeOption option; // 引擎的配置信息
+};
+```
+
+
+## Runtime使用示例
+
+### C++
+
+```
+#include "fastdeploy/fastdeploy_runtime.h"
+
+int main() {
+ auto option = fastdeploy::RuntimeOption();
+ option.model_file = "resnet50/inference.pdmodel";
+ option.params_file = "resnet50/inference.pdiparams";
+
+ auto runtime = fastdeploy::Runtime();
+ assert(runtime.Init(option));
+
+ // 需准备好输入tensor
+ std::vector inputs;
+
+ std::vector outputs;
+ assert(runtime.Infer(tensors, &outputs));
+
+ // 输出tensor的debug信息查看
+ outputs[0].PrintInfo();
+}
+```
+
+### Python
+
+```
+import fastdeploy as fd
+import numpy as np
+
+option = fd.RuntimeOption();
+option.model_file = "resnet50/inference.pdmodel"
+option.params_file = "resnet50/inference.pdiparams";
+
+runtime = fd.Runtime(option)
+
+result = runtime.infer({"image": np.random.rand(1, 3, 224, 224)});
+```
diff --git a/docs/tech/vision.md b/docs/tech/vision.md
new file mode 100644
index 0000000000..90f4c43fa9
--- /dev/null
+++ b/docs/tech/vision.md
@@ -0,0 +1,74 @@
+# Vision
+
+Vision是FastDeploy中的视觉模型模块,包含`processors`和`utils`两个公共模块,以及模型模块。
+
+## processors 图像处理模块
+
+`processors`提供了常见的图像处理操作,并为各操作实现不同的后端,如当前支持的CPU以及GPU两种处理方式,在模型中预算中,开发者调用`processors`提供的API,即可快速在不同的处理后端进行切换。
+
+默认在CPU上进行处理
+```
+namespace vis = fastdeploy::vision;
+
+im = cv2.imread("test.jpg");
+
+vis::Mat mat(im);
+assert(vis::Resize::Run(&mat, 224, 224));
+assert(vis::Normalize::Run(&mat, {0.5, 0.5, 0.5}, {0.5, 0.5, 0.5}));
+assert(vis::HWC2CHW::Run(&mat));
+```
+
+切换为CUDA GPU进行处理
+```
+namespace vis = fastdeploy::vision;
+vis::Processor::default_lib = vis::ProcessorLib::OPENCV_CUDA;
+
+im = cv2.imread("test.jpg");
+
+vis::Mat mat(im);
+assert(vis::Resize::Run(&mat, 224, 224));
+assert(vis::Normalize::Run(&mat, {0.5, 0.5, 0.5}, {0.5, 0.5, 0.5}));
+assert(vis::HWC2CHW::Run(&mat));
+```
+
+在处理过程中,通过`fastdeploy::vision::Mat`作为传递的数据结构
+```
+struct Mat {
+ Mat(cv::Mat); // 通过`cv::Mat`进行构造
+ FDDataType Type(); // 数值类型
+ int Channels(); // 通道数
+ int Width(); // 宽
+ int Height(); // 高
+
+ // 获取图像,如Mat在GPU上,则会拷贝到CPU上再返回
+ cv::Mat GetCpuMat();
+
+ // 获取图像,如Mat在CPU上,则会拷贝到GPU上再返回
+ cv::cuda::GpuMat GetGpuMat();
+
+ void ShareWithTensor(FDTensor* tensor); // 构造一个FDTensor,并共享内存
+ bool CopyToTensor(FDTensor* tensor); // 构造一个CPU上的FDTensor,并将数据拷贝过去
+
+ Layout layout; // 数据排布,支持Layout::HWC / Layout::CHW
+ Device device; // 数据存放设备,支持Device::CPU / Device::GPU
+};
+```
+
+## utilities模块 工具模块
+
+提供一些常见的函数,如分类模型常用的`TopK`选择,检测模型的`NMS`操作。同样后面可以考虑将后处理的实现也有不同后端
+
+
+## visualize 可视化模块
+
+提供一些可视化函数,如检测、分割、OCR都需要这种函数来看可视化的效果
+
+## 模型模块
+
+这个是`Vision`中最重要的模块,所有的模块均通过`域名` + `模型名`来划分,如
+
+- vision::ppdet::YOLOv3 // PaddleDetection的YOLOv3模型
+- vision::ppdet::RCNN // PaddleDetection的RCNN类模型
+- vision::ultralytics::YOLOv5 // https://github.com/ultralytics/yolov5 YOLOv5模型
+
+模型的增加参考[模型开发](models.md)
diff --git a/docs/usage/model.md b/docs/usage/model.md
new file mode 100644
index 0000000000..d5326b3c11
--- /dev/null
+++ b/docs/usage/model.md
@@ -0,0 +1,57 @@
+# FastDeploy模型
+
+目前支持的模型如下
+- [fastdeploy.vision.ppcls.Model](vision/ppcls.md) PaddleClas里的所有分类模型
+- [fastdeploy.vision.ultralytics/YOLOv5](vision/ultralytics.md) [ultralytics/yolov5](https://github.com/ultralytics/yolov5)模型
+
+具体模型使用方式可参考各模型文档API和示例说明。 各模型在运行时均有默认的Runtime配置,本文档说明如何修改模型的后端配置,其中如下代码为跑YOLOv5的模型Python示例代码
+```
+import fastdeploy as fd
+model = fd.vision.ulttralytics.YOLOv5("yolov5s.onnx")
+
+import cv2
+im = cv2.imread('bus.jpg')
+
+result = model.predict(im)
+
+print(model.runtime_option)
+```
+通过`print(model.runtime_option)`可以看到如下信息
+```
+RuntimeOption(
+ backend : Backend.ORT # 当前推理后端为ONNXRuntime
+ cpu_thread_num : 8 # 推理时CPU线程数设置(仅当模型在CPU上推理时有效)
+ device : Device.GPU # 当前推理设备为GPU
+ device_id : 0 # 当前推理设备id为0
+ model_file : yolov5s.onnx # 模型文件路径
+ model_format : Frontend.ONNX # 模型格式,当前为ONNX格式
+ ort_execution_mode : -1 # ONNXRuntime后端的配置参数,-1表示默认
+ ort_graph_opt_level : -1 # ONNXRuntime后端的配置参数, -1表示默认
+ ort_inter_op_num_threads : -1 # ONNXRuntime后端的配置参数,-1表示默认
+ params_file : # 参数文件(ONNX模型无此文件)
+ trt_enable_fp16 : False # TensorRT参数
+ trt_enable_int8 : False # TensorRT参数
+ trt_fixed_shape : {} # TensorRT参数
+ trt_max_batch_size : 32 # TensorRT参数
+ trt_max_shape : {} # TensorRT参数
+ trt_max_workspace_size : 1073741824 # TensorRT参数
+ trt_min_shape : {} # TensorRT参数
+ trt_opt_shape : {} # TensorRT参数
+ trt_serialize_file : # TensorRT参数
+)
+```
+
+会注意到参数名以`ort`开头的,均为ONNXRuntime后端专有的参数;以`trt`的则为TensorRT后端专有的参数。各后端与参数的配置,可参考[RuntimeOption](runtime_option.md)说明。
+
+## 切换模型推理方式
+
+一般而言,用户只需关注推理是在哪种Device下即可。 当然有更进一步需求,可以再为Device选择不同的Backend,但配置时注意Device与Backend的搭配。 如Backend::TRT只支持Device为GPU, 而Backend::ORT则同时支持CPU和GPU
+
+```
+import fastdeploy as fd
+option = fd.RuntimeOption()
+option.device = fd.Device.CPU
+option.cpu_thread_num = 12
+model = fd.vision.ulttralytics.YOLOv5("yolov5s.onnx", option)
+print(model.runtime_option)
+```
diff --git a/docs/usage/vision/ppcls.md b/docs/usage/vision/ppcls.md
new file mode 100644
index 0000000000..fc795fae5c
--- /dev/null
+++ b/docs/usage/vision/ppcls.md
@@ -0,0 +1,104 @@
+# PaddleClas分类模型推理
+
+PaddleClas模型导出参考[PaddleClas](https://github.com/PaddlePaddle/PaddleClas.git)
+
+## Python API说明
+
+### Model类
+```
+fastdeploy.vision.ppcls.Model(model_file, params_file, config_file, runtime_option=None, model_format=fastdeploy.Frontend.PADDLE)
+```
+
+**参数**
+
+> * **model_file**(str): 模型文件,如resnet50/inference.pdmodel
+> * **params_file**(str): 参数文件,如resnet50/inference.pdiparams
+> * **config_file**(str): 配置文件,来源于PaddleClas提供的推理配置文件,如[inference_cls.yaml](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.3/deploy/configs/inference_cls.yaml)
+> * **runtime_option**(fd.RuntimeOption): 后端推理的配置, 默认为None,即采用默认配置
+> * **model_format**(fd.Frontend): 模型格式说明,PaddleClas的模型格式均为Frontend.PADDLE
+
+#### predict接口
+```
+Model.predict(image_data, topk=1)
+```
+
+> **参数**
+>
+> > * **image_data**(np.ndarray): 输入数据, 注意需为HWC,RGB格式
+> > * **topk**(int): 取前top的分类
+
+> **返回结果**
+>
+> > * **result**(ClassifyResult):结构体包含`label_ids`和`scores`两个list成员变量,表示类别,和各类别对应的置信度
+
+### 示例
+
+> ```
+> import fastdeploy.vision as vis
+> import cv2
+> model = vis.ppcls.Model("resnet50/inference.pdmodel", "resnet50/inference.pdiparams", "resnet50/inference_cls.yaml")
+> im = cv2.imread("test.jpeg")
+> result = model.predict(im, topk=5)
+> print(result.label_ids[0], result.scores[0])
+> ```
+
+## C++ API说明
+
+需添加头文件`#include "fastdeploy/vision.h"`
+
+### Model类
+
+```
+fastdeploy::vision::ppcls::Model(
+ const std::string& model_file,
+ const std::string& params_file,
+ const std::string& config_file,
+ const RuntimeOption& custom_option = RuntimeOption(),
+ const Frontend& model_format = Frontend::PADDLE)
+```
+
+**参数**
+> * **model_file**: 模型文件,如resnet50/inference.pdmodel
+> * **params_file**: 参数文件,如resnet50/inference.pdiparams
+> * **config_file**: 配置文件,来源于PaddleClas提供的推理配置文件,如[inference_cls.yaml](https://github.com/PaddlePaddle/PaddleClas/blob/release/2.3/deploy/configs/inference_cls.yaml)
+> * **runtime_option**: 后端推理的配置, 不设置的情况下,采用默认配置
+> * **model_format**: 模型格式说明,PaddleClas的模型格式均为Frontend.PADDLE
+
+#### Predict接口
+```
+bool Model::Predict(cv::Mat* im, ClassifyResult* result, int topk = 1)
+```
+
+> **参数**
+> > * **im**: 输入图像数据,须为HWC,RGB格式(注意传入的im在预处理过程中会被修改)
+> > * **result**: 分类结果
+> > * **topk**: 取分类结果前topk
+
+> **返回结果**
+> > true或false,表示预测成功与否
+
+### 示例
+> ```
+> #include "fastdeploy/vision.h"
+>
+> int main() {
+> typedef vis = fastdeploy::vision;
+> auto model = vis::ppcls::Model("resnet50/inference.pdmodel", "resnet50/inference.pdiparams", "resnet50/inference_cls.yaml");
+>
+> if (!model.Initialized()) {
+> std::cerr << "Initialize failed." << std::endl;
+> return -1;
+> }
+>
+> cv::Mat im = cv::imread("test.jpeg");
+>
+> vis::ClassifyResult res;
+> if (!model.Predict(&im, &res, 5)) {
+> std::cerr << "Prediction failed." << std::endl;
+> return -1;
+> }
+>
+> std::cout << res.label_ids[0] << " " << res.scores[0] << std::endl;
+> return 0;
+> }
+```
diff --git a/external/onnxruntime.cmake b/external/onnxruntime.cmake
new file mode 100644
index 0000000000..3e50c804f2
--- /dev/null
+++ b/external/onnxruntime.cmake
@@ -0,0 +1,90 @@
+# 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(ExternalProject)
+
+set(ONNXRUNTIME_PROJECT "extern_onnxruntime")
+set(ONNXRUNTIME_PREFIX_DIR ${THIRD_PARTY_PATH}/onnxruntime)
+set(ONNXRUNTIME_SOURCE_DIR
+ ${THIRD_PARTY_PATH}/onnxruntime/src/${ONNXRUNTIME_PROJECT})
+set(ONNXRUNTIME_INSTALL_DIR ${THIRD_PARTY_PATH}/install/onnxruntime)
+set(ONNXRUNTIME_INC_DIR
+ "${ONNXRUNTIME_INSTALL_DIR}/include"
+ CACHE PATH "onnxruntime include directory." FORCE)
+set(ONNXRUNTIME_LIB_DIR
+ "${ONNXRUNTIME_INSTALL_DIR}/lib"
+ CACHE PATH "onnxruntime lib directory." FORCE)
+set(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}" "${ONNXRUNTIME_LIB_DIR}")
+
+set(ONNXRUNTIME_VERSION "1.11.1")
+set(ONNXRUNTIME_URL_PREFIX "https://bj.bcebos.com/paddle2onnx/libs/")
+
+if(WIN32)
+ if(WITH_GPU)
+ set(ONNXRUNTIME_FILENAME "onnxruntime-win-x64-gpu-${ONNXRUNTIME_VERSION}.zip")
+ else()
+ set(ONNXRUNTIME_FILENAME "onnxruntime-win-x64-${ONNXRUNTIME_VERSION}.zip")
+ endif()
+elseif(APPLE)
+ if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64")
+ set(ONNXRUNTIME_FILENAME "onnxruntime-osx-arm64-${ONNXRUNTIME_VERSION}.tgz")
+ else()
+ set(ONNXRUNTIME_FILENAME "onnxruntime-osx-x86_64-${ONNXRUNTIME_VERSION}.tgz")
+ endif()
+else()
+ if(WITH_GPU)
+ set(ONNXRUNTIME_FILENAME "onnxruntime-linux-x64-gpu-${ONNXRUNTIME_VERSION}.tgz")
+ else()
+ set(ONNXRUNTIME_FILENAME "onnxruntime-linux-x64-${ONNXRUNTIME_VERSION}.tgz")
+ endif()
+endif()
+set(ONNXRUNTIME_URL "${ONNXRUNTIME_URL_PREFIX}${ONNXRUNTIME_FILENAME}")
+
+include_directories(${ONNXRUNTIME_INC_DIR}
+)# For ONNXRUNTIME code to include internal headers.
+
+if(WIN32)
+ set(ONNXRUNTIME_LIB
+ "${ONNXRUNTIME_INSTALL_DIR}/lib/onnxruntime.lib"
+ CACHE FILEPATH "ONNXRUNTIME static library." FORCE)
+elseif(APPLE)
+ set(ONNXRUNTIME_LIB
+ "${ONNXRUNTIME_INSTALL_DIR}/lib/libonnxruntime.dylib"
+ CACHE FILEPATH "ONNXRUNTIME static library." FORCE)
+else()
+ set(ONNXRUNTIME_LIB
+ "${ONNXRUNTIME_INSTALL_DIR}/lib/libonnxruntime.so"
+ CACHE FILEPATH "ONNXRUNTIME static library." FORCE)
+endif()
+
+ExternalProject_Add(
+ ${ONNXRUNTIME_PROJECT}
+ ${EXTERNAL_PROJECT_LOG_ARGS}
+ URL ${ONNXRUNTIME_URL}
+ PREFIX ${ONNXRUNTIME_PREFIX_DIR}
+ DOWNLOAD_NO_PROGRESS 1
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ""
+ UPDATE_COMMAND ""
+ INSTALL_COMMAND
+ ${CMAKE_COMMAND} -E remove_directory ${ONNXRUNTIME_INSTALL_DIR} &&
+ ${CMAKE_COMMAND} -E make_directory ${ONNXRUNTIME_INSTALL_DIR} &&
+ ${CMAKE_COMMAND} -E rename ${ONNXRUNTIME_SOURCE_DIR}/lib/ ${ONNXRUNTIME_INSTALL_DIR}/lib &&
+ ${CMAKE_COMMAND} -E copy_directory ${ONNXRUNTIME_SOURCE_DIR}/include
+ ${ONNXRUNTIME_INC_DIR}
+ BUILD_BYPRODUCTS ${ONNXRUNTIME_LIB})
+
+add_library(external_onnxruntime STATIC IMPORTED GLOBAL)
+set_property(TARGET external_onnxruntime PROPERTY IMPORTED_LOCATION ${ONNXRUNTIME_LIB})
+add_dependencies(external_onnxruntime ${ONNXRUNTIME_PROJECT})
diff --git a/external/opencv.cmake b/external/opencv.cmake
new file mode 100644
index 0000000000..8ce8c56cc7
--- /dev/null
+++ b/external/opencv.cmake
@@ -0,0 +1,121 @@
+# 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.
+
+if(WIN32)
+ find_package(OpenCV REQUIRED PATHS ${OpenCV_DIR})
+ list(APPEND DEPEND_LIBS ${OpenCV_LIBS})
+else()
+
+include(ExternalProject)
+
+set(OPENCV_PROJECT "extern_opencv")
+set(OPENCV_PREFIX_DIR ${THIRD_PARTY_PATH}/opencv)
+set(OPENCV_SOURCE_DIR
+ ${THIRD_PARTY_PATH}/opencv/src/${OPENCV_PROJECT})
+set(OPENCV_INSTALL_DIR ${THIRD_PARTY_PATH}/install/opencv)
+set(OPENCV_INC_DIR
+ "${OPENCV_INSTALL_DIR}/include/"
+ CACHE PATH "opencv include directory." FORCE)
+set(OPENCV_LIB_DIR
+ "${OPENCV_INSTALL_DIR}/lib"
+ CACHE PATH "opencv lib directory." FORCE)
+set(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}" "${OPENCV_LIB_DIR}")
+
+if(WIN32)
+ message(FATAL_ERROR "NOT SUPPORT WINDOWS NOW, OPENCV")
+elseif(APPLE)
+ if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64")
+ set(OPENCV_URL "https://bj.bcebos.com/paddle2onnx/libs/opencv-osx-arm64-3.4.16.tgz")
+ else()
+ set(OPENCV_URL "https://bj.bcebos.com/paddle2onnx/libs/opencv-osx-x86_64-3.4.16.tgz")
+ endif()
+else()
+ set(OPENCV_URL "https://bj.bcebos.com/paddle2onnx/libs/opencv-linux-x64-3.4.16.tgz")
+ if(ENABLE_OPENCV_CUDA)
+ set(OPENCV_URL "https://bj.bcebos.com/paddle2onnx/libs/opencv-linux-x64-gpu-3.4.16.tgz")
+ endif()
+endif()
+
+include_directories(${OPENCV_INC_DIR}
+)# For OPENCV code to include internal headers.
+
+set(OPENCV_SOURCE_LIB ${OPENCV_SOURCE_DIR}/lib/)
+if(WIN32)
+ message(FATAL_ERROR "NOT SUPPORT WEINDOWS, OPENCV")
+elseif(APPLE)
+ set(OPENCV_CORE_LIB ${OPENCV_INSTALL_DIR}/lib/libopencv_core.dylib)
+ set(OPENCV_HIGHGUI_LIB ${OPENCV_INSTALL_DIR}/lib/libopencv_highgui.dylib)
+ set(OPENCV_IMGPROC_LIB ${OPENCV_INSTALL_DIR}/lib/libopencv_imgproc.dylib)
+ set(OPENCV_IMGCODESC_LIB ${OPENCV_INSTALL_DIR}/lib/libopencv_imgcodecs.dylib)
+else()
+ set(OPENCV_SOURCE_LIB ${OPENCV_SOURCE_DIR}/lib64)
+ set(OPENCV_CORE_LIB ${OPENCV_INSTALL_DIR}/lib/libopencv_core.so)
+ set(OPENCV_HIGHGUI_LIB ${OPENCV_INSTALL_DIR}/lib/libopencv_highgui.so)
+ set(OPENCV_IMGPROC_LIB ${OPENCV_INSTALL_DIR}/lib/libopencv_imgproc.so)
+ set(OPENCV_IMGCODESC_LIB ${OPENCV_INSTALL_DIR}/lib/libopencv_imgcodecs.so)
+ set(OPENCV_CUDAARITHM_LIB ${OPENCV_INSTALL_DIR}/lib/libopencv_cudaarithm.so)
+ set(OPENCV_CUDAIMGPROC_LIB ${OPENCV_INSTALL_DIR}/lib/libopencv_cudaimgproc.so)
+ set(OPENCV_CUDAWARPING_LIB ${OPENCV_INSTALL_DIR}/lib/libopencv_cudawarping.so)
+endif()
+
+if(WIN32)
+ message(FATAL_ERROR "NOT SUPPORT WINDOWS, OPENCV")
+else()
+ ExternalProject_Add(
+ ${OPENCV_PROJECT}
+ ${EXTERNAL_PROJECT_LOG_ARGS}
+ URL ${OPENCV_URL}
+ PREFIX ${OPENCV_PREFIX_DIR}
+ DOWNLOAD_NO_PROGRESS 1
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ""
+ UPDATE_COMMAND ""
+ INSTALL_COMMAND
+ ${CMAKE_COMMAND} -E remove_directory ${OPENCV_INSTALL_DIR} &&
+ ${CMAKE_COMMAND} -E make_directory ${OPENCV_INSTALL_DIR} &&
+ ${CMAKE_COMMAND} -E rename ${OPENCV_SOURCE_LIB} ${OPENCV_INSTALL_DIR}/lib &&
+ ${CMAKE_COMMAND} -E copy_directory ${OPENCV_SOURCE_DIR}/include/
+ ${OPENCV_INC_DIR}
+ BUILD_BYPRODUCTS ${OPENCV_LIB})
+endif()
+
+add_library(external_opencv_core STATIC IMPORTED GLOBAL)
+set_property(TARGET external_opencv_core PROPERTY IMPORTED_LOCATION ${OPENCV_CORE_LIB})
+add_library(external_opencv_highgui STATIC IMPORTED GLOBAL)
+set_property(TARGET external_opencv_highgui PROPERTY IMPORTED_LOCATION ${OPENCV_HIGHGUI_LIB})
+add_library(external_opencv_imgproc STATIC IMPORTED GLOBAL)
+set_property(TARGET external_opencv_imgproc PROPERTY IMPORTED_LOCATION ${OPENCV_IMGPROC_LIB})
+add_library(external_opencv_imgcodesc STATIC IMPORTED GLOBAL)
+set_property(TARGET external_opencv_imgcodesc PROPERTY IMPORTED_LOCATION ${OPENCV_IMGCODESC_LIB})
+
+add_dependencies(external_opencv_core ${OPENCV_PROJECT})
+add_dependencies(external_opencv_highgui ${OPENCV_PROJECT})
+add_dependencies(external_opencv_imgproc ${OPENCV_PROJECT})
+add_dependencies(external_opencv_imgcodesc ${OPENCV_PROJECT})
+
+list(APPEND DEPEND_LIBS external_opencv_core external_opencv_highgui external_opencv_imgproc external_opencv_imgcodesc)
+
+if(ENABLE_OPENCV_CUDA)
+ add_library(extern_opencv_cudawarping STATIC IMPORTED GLOBAL)
+ set_property(TARGET extern_opencv_cudawarping PROPERTY IMPORTED_LOCATION ${OPENCV_CUDAWARPING_LIB})
+ add_dependencies(extern_opencv_cudawarping ${OPENCV_PROJECT})
+ add_library(extern_opencv_cudaarithm STATIC IMPORTED GLOBAL)
+ set_property(TARGET extern_opencv_cudaarithm PROPERTY IMPORTED_LOCATION ${OPENCV_CUDAARITHM_LIB})
+ add_dependencies(extern_opencv_cudaarithm ${OPENCV_PROJECT})
+ add_library(extern_opencv_cudaimgproc STATIC IMPORTED GLOBAL)
+ set_property(TARGET extern_opencv_cudaimgproc PROPERTY IMPORTED_LOCATION ${OPENCV_CUDAIMGPROC_LIB})
+ add_dependencies(extern_opencv_cudaimgproc ${OPENCV_PROJECT})
+ list(APPEND DEPEND_LIBS extern_opencv_cudawarping extern_opencv_cudaarithm extern_opencv_cudaimgproc)
+endif()
+endif(WIN32)
diff --git a/external/paddle2onnx.cmake b/external/paddle2onnx.cmake
new file mode 100644
index 0000000000..b9847830a3
--- /dev/null
+++ b/external/paddle2onnx.cmake
@@ -0,0 +1,80 @@
+# 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(ExternalProject)
+
+set(PADDLE2ONNX_PROJECT "extern_paddle2onnx")
+set(PADDLE2ONNX_PREFIX_DIR ${THIRD_PARTY_PATH}/paddle2onnx)
+set(PADDLE2ONNX_SOURCE_DIR
+ ${THIRD_PARTY_PATH}/paddle2onnx/src/${PADDLE2ONNX_PROJECT})
+set(PADDLE2ONNX_INSTALL_DIR ${THIRD_PARTY_PATH}/install/paddle2onnx)
+set(PADDLE2ONNX_INC_DIR
+ "${PADDLE2ONNX_INSTALL_DIR}/include"
+ CACHE PATH "paddle2onnx include directory." FORCE)
+set(PADDLE2ONNX_LIB_DIR
+ "${PADDLE2ONNX_INSTALL_DIR}/lib/"
+ CACHE PATH "onnxruntime lib directory." FORCE)
+set(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}"
+ "${PADDLE2ONNX_LIB_DIR}")
+
+include_directories(${PADDLE2ONNX_INC_DIR})
+if(WIN32)
+ set(PADDLE2ONNX_COMPILE_LIB
+ "${PADDLE2ONNX_INSTALL_DIR}/lib/paddle2onnx.lib"
+ CACHE FILEPATH "paddle2onnx compile library." FORCE)
+elseif(APPLE)
+ set(PADDLE2ONNX_COMPILE_LIB
+ "${PADDLE2ONNX_INSTALL_DIR}/lib/libpaddle2onnx.dylib"
+ CACHE FILEPATH "paddle2onnx compile library." FORCE)
+else()
+ set(PADDLE2ONNX_COMPILE_LIB
+ "${PADDLE2ONNX_INSTALL_DIR}/lib/libpaddle2onnx.so"
+ CACHE FILEPATH "paddle2onnx compile library." FORCE)
+endif(WIN32)
+
+set(PADDLE2ONNX_URL_BASE "https://bj.bcebos.com/paddle2onnx/libs/")
+set(PADDLE2ONNX_VERSION "0.9.9")
+if(WIN32)
+ set(PADDLE2ONNX_FILE "paddle2onnx-win-x64-${PADDLE2ONNX_VERSION}.zip")
+elseif(APPLE)
+ if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64")
+ set(PADDLE2ONNX_FILE "paddle2onnx-osx-arm64-${PADDLE2ONNX_VERSION}.tgz")
+ else()
+ set(PADDLE2ONNX_FILE "paddle2onnx-osx-x86_64-${PADDLE2ONNX_VERSION}.tgz")
+ endif()
+else()
+ set(PADDLE2ONNX_FILE "paddle2onnx-linux-x64-${PADDLE2ONNX_VERSION}.tgz")
+endif()
+set(PADDLE2ONNX_URL "${PADDLE2ONNX_URL_BASE}${PADDLE2ONNX_FILE}")
+
+ExternalProject_Add(
+ ${PADDLE2ONNX_PROJECT}
+ ${EXTERNAL_PROJECT_LOG_ARGS}
+ URL ${PADDLE2ONNX_URL}
+ PREFIX ${PADDLE2ONNX_PREFIX_DIR}
+ DOWNLOAD_NO_PROGRESS 1
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ""
+ UPDATE_COMMAND ""
+ INSTALL_COMMAND
+ ${CMAKE_COMMAND} -E remove_directory ${PADDLE2ONNX_INSTALL_DIR} &&
+ ${CMAKE_COMMAND} -E make_directory ${PADDLE2ONNX_INSTALL_DIR} &&
+ ${CMAKE_COMMAND} -E rename ${PADDLE2ONNX_SOURCE_DIR}/lib/
+ ${PADDLE2ONNX_LIB_DIR} && ${CMAKE_COMMAND} -E copy_directory
+ ${PADDLE2ONNX_SOURCE_DIR}/include ${PADDLE2ONNX_INC_DIR}
+ BUILD_BYPRODUCTS ${PADDLE2ONNX_COMPILE_LIB})
+
+add_library(external_paddle2onnx STATIC IMPORTED GLOBAL)
+set_property(TARGET external_paddle2onnx PROPERTY IMPORTED_LOCATION
+ ${PADDLE2ONNX_COMPILE_LIB})
+add_dependencies(external_paddle2onnx ${PADDLE2ONNX_PROJECT})
diff --git a/external/summary.cmake b/external/summary.cmake
new file mode 100644
index 0000000000..3c2393eda6
--- /dev/null
+++ b/external/summary.cmake
@@ -0,0 +1,44 @@
+# 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.
+
+function(fastdeploy_summary)
+ message(STATUS "")
+ message(STATUS "*************FastDeploy Building Summary**********")
+ message(STATUS " CMake version : ${CMAKE_VERSION}")
+ message(STATUS " CMake command : ${CMAKE_COMMAND}")
+ message(STATUS " System : ${CMAKE_SYSTEM_NAME}")
+ message(STATUS " C++ compiler : ${CMAKE_CXX_COMPILER}")
+ message(STATUS " C++ compiler version : ${CMAKE_CXX_COMPILER_VERSION}")
+ message(STATUS " CXX flags : ${CMAKE_CXX_FLAGS}")
+ message(STATUS " Build type : ${CMAKE_BUILD_TYPE}")
+ get_directory_property(tmp DIRECTORY ${PROJECT_SOURCE_DIR} COMPILE_DEFINITIONS)
+ message(STATUS " Compile definitions : ${tmp}")
+ message(STATUS " CMAKE_PREFIX_PATH : ${CMAKE_PREFIX_PATH}")
+ message(STATUS " CMAKE_INSTALL_PREFIX : ${CMAKE_INSTALL_PREFIX}")
+ message(STATUS " CMAKE_MODULE_PATH : ${CMAKE_MODULE_PATH}")
+ message(STATUS "")
+ message(STATUS " FastDeploy version : ${FASTDEPLOY_VERSION}")
+ message(STATUS " Paddle2ONNX version : ${PADDLE2ONNX_VERSION}")
+ message(STATUS " ONNXRuntime version : ${ONNXRUNTIME_VERSION}")
+ message(STATUS " ENABLE_ORT_BACKEND : ${ENABLE_ORT_BACKEND}")
+ if(WITH_GPU)
+ message(STATUS " WITH_GPU : ${WITH_GPU}")
+ message(STATUS " ENABLE_TRT_BACKEND : ${ENABLE_TRT_BACKEND}")
+ message(STATUS " CUDA_DIRECTORY : ${CUDA_DIRECTORY}")
+ message(STATUS " TRT_DRECTORY : ${TRT_DIRECTORY}")
+ endif()
+ message(STATUS " ENABLE_VISION : ${ENABLE_VISION}")
+ message(STATUS " ENABLE_DEBUG : ${ENABLE_DEBUG}")
+ message(STATUS " ENABLE_VISION_VISUALIZE : ${ENABLE_VISION_VISUALIZE}")
+endfunction()
diff --git a/external/utils.cmake b/external/utils.cmake
new file mode 100644
index 0000000000..3e6d70b42d
--- /dev/null
+++ b/external/utils.cmake
@@ -0,0 +1,15 @@
+# This function comes from https://blog.csdn.net/yindongjie1221/article/details/90614261
+function(redefine_file_macro targetname)
+ get_target_property(source_files "${targetname}" SOURCES)
+ foreach(sourcefile ${source_files})
+ get_property(defs SOURCE "${sourcefile}"
+ PROPERTY COMPILE_DEFINITIONS)
+ get_filename_component(filepath "${sourcefile}" ABSOLUTE)
+ string(REPLACE ${PROJECT_SOURCE_DIR}/ "" relpath ${filepath})
+ list(APPEND defs "__REL_FILE__=\"${relpath}\"")
+ set_property(
+ SOURCE "${sourcefile}"
+ PROPERTY COMPILE_DEFINITIONS ${defs}
+ )
+ endforeach()
+endfunction()
diff --git a/fastdeploy/CMakeLists.txt b/fastdeploy/CMakeLists.txt
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/fastdeploy/LICENSE b/fastdeploy/LICENSE
new file mode 100644
index 0000000000..261eeb9e9f
--- /dev/null
+++ b/fastdeploy/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
diff --git a/fastdeploy/ThirdPartyNotices.txt b/fastdeploy/ThirdPartyNotices.txt
new file mode 100644
index 0000000000..5842b9a717
--- /dev/null
+++ b/fastdeploy/ThirdPartyNotices.txt
@@ -0,0 +1,734 @@
+This project depends on some open source projects, list as below
+
+--------
+1. https://github.com/protocolbuffers/protobuf
+
+Copyright 2008 Google Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Code generated by the Protocol Buffer compiler is owned by the owner
+of the input file used when generating it. This code is not
+standalone and requires a support library to be linked with it. This
+support library is itself covered by the above license.
+
+--------
+2. https://github.com/onnx/onnx
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
+--------
+3. https://github.com/microsoft/onnxruntime
+
+MIT License
+
+Copyright (c) Microsoft Corporation
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+--------
+4. https://github.com/pybind/pybind11
+
+Copyright (c) 2016 Wenzel Jakob , All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Please also refer to the file .github/CONTRIBUTING.md, which clarifies licensing of
+external contributions to this project including patches, pull requests, etc.
+
+--------
+4. https://github.com/onnx/onnx-tensorrt
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2021 NVIDIA Corporation
+
+ 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.
+
+--------
+5. https://github.com/opencv/opencv
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
+--------
+6. https://github.com/jbeder/yaml-cpp
+
+Copyright (c) 2008-2015 Jesse Beder.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/fastdeploy/__init__.py b/fastdeploy/__init__.py
index 73f2b94c50..a9c16e9fea 100644
--- a/fastdeploy/__init__.py
+++ b/fastdeploy/__init__.py
@@ -11,189 +11,31 @@
# 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.
-
from __future__ import absolute_import
-from six import text_type as _text_type
-from .download import download, download_and_decompress
-
-import argparse
-
-# Since the source code is not fully open sourced,
-# currently we will provide the prebuilt library
-# and demo codes
-import os
-
-__version__ = "0.1.0"
-
-
-def parse_arguments():
- parser = argparse.ArgumentParser()
- parser.add_argument(
- '--model',
- type=_text_type,
- default=None,
- help='Name of model, which can be listed by --list_models')
- parser.add_argument(
- '--platform',
- type=_text_type,
- default=None,
- help='Define platform, supports Windows/Linux/Android/iOS.')
- parser.add_argument(
- '--soc',
- type=_text_type,
- default=None,
- help='Define soc for the platform, supports x86/x86-NVIDIA_GPU/ARM/jetson.'
- )
- parser.add_argument(
- '--save_dir',
- type=_text_type,
- default=".",
- help='Path to download and extract deployment SDK.')
- parser.add_argument(
- '--list_models',
- required=False,
- action="store_true",
- default=False,
- help='List all the supported models.')
- parser.add_argument(
- '--download_sdk',
- required=False,
- action="store_true",
- default=False,
- help='List all the supported models.')
-
- return parser.parse_args()
-
-
-def read_sources():
- user_dir = os.path.expanduser('~')
- print("Updating the newest sdk information...")
- source_cfgs = "https://bj.bcebos.com/paddlehub/fastdeploy/fastdeploy_newest_sources.cfg.1"
- if os.path.exists(os.path.join(user_dir, "fastdeploy_newest_sources.cfg.1")):
- os.remove(os.path.join(user_dir, "fastdeploy_newest_sources.cfg.1"))
- download(source_cfgs, user_dir)
- categories = dict()
- res = dict()
- with open(os.path.join(user_dir, "fastdeploy_newest_sources.cfg.1")) as f:
- for line in f:
- if line.strip().startswith("#"):
- continue
- if line.strip() == "":
- continue
- category, model, plat, soc, url = line.strip().split('\t')
- if category not in categories:
- categories[category] = set()
- categories[category].add(model)
- if model not in res:
- res[model] = dict()
- if plat not in res[model]:
- res[model][plat] = dict()
- if soc not in res[model][plat]:
- res[model][plat][soc] = dict()
- res[model][plat][soc] = url
- return categories, res
-
-
-def main():
- args = parse_arguments()
-
- if not args.list_models and not args.download_sdk:
- print(
- "Please use flag --list_models to show all the supported models, or use flag --download_sdk to download the specify SDK to deploy you model."
- )
- return
-
- categories, all_sources = read_sources()
- all_models = list(all_sources.keys())
- all_models.sort()
-
- if args.list_models:
- print("Currently, FastDeploy supports {} models, list as below,\n".format(
- len(all_models)))
-
- for k, v in categories.items():
- print("\nModel Category: {}".format(k))
- print("_"*100)
- models = list(categories[k])
- models.sort()
- i = 0
- while i < len(models):
- if i == len(models) - 1:
- print(models[i].center(30))
- i += 1
- elif i == len(models) - 2:
- print(models[i].center(30), models[i+1].center(30))
- i += 2
- else:
- print(models[i].center(30), models[i+1].center(30), models[i+2].center(30))
- i += 3
- return
-
- if not os.path.exists(args.save_dir):
- print("The specified save_dir: {} is not exist.".format(args.save_dir))
- return
-
- if args.model is None or args.model == "":
- print(
- "Please define --model to choose which kind of model to deploy, use --list_models to show all the supported models."
- )
- return
-
- if args.model not in all_sources:
- print(
- "{} is not supported, use --list_models to list all the models FastDeploy supported.".
- format(args.model))
- return
-
- if args.platform is None or args.platform == "":
- print(
- "Please define --platform to choose which platform to deploy, supports windows/linux/android/ios."
- )
- return
-
- if args.platform not in all_sources[args.model]:
- print(
- "The model:{} only supports platform of {}, {} is not supported now.".
- format(args.model,
- list(all_sources[args.model].keys()), args.platform))
- return
+import logging
+from .fastdeploy_main import Frontend, Backend, FDDataType, TensorInfo, RuntimeOption, Device
+from .fastdeploy_runtime import *
+from . import fastdeploy_main as C
+from . import vision
- if args.soc is None or args.soc == "":
- print(
- "Please define --soc to choose which hardware to deploy, for model:{} and platform:{}, the available socs are {}.".
- format(args.model, args.platform,
- list(all_sources[args.model][args.platform].keys())))
- return
- if args.soc not in all_sources[args.model][args.platform]:
- print(
- "The model:{} in platform:{} only supports soc of {}, {} is not supported now.".
- format(args.model, args.platform,
- list(all_sources[args.model][args.platform].keys()),
- args.soc))
- return
+def TensorInfoStr(tensor_info):
+ message = "TensorInfo(name : '{}', dtype : '{}', shape : '{}')".format(
+ tensor_info.name, tensor_info.dtype, tensor_info.shape)
+ return message
- print("\nDownloading SDK:",
- all_sources[args.model][args.platform][args.soc])
- save_dir = args.save_dir
- sdk_name = os.path.split(all_sources[args.model][args.platform][args.soc])[
- -1].strip()
- if all_sources[args.model][args.platform][args.soc].count(".zip") > 0:
- sdk_name = os.path.split(all_sources[args.model][args.platform][
- args.soc])[-1].strip().split(".zip")[0]
- new_save_dir = os.path.join(args.save_dir, sdk_name)
- if not os.path.exists(new_save_dir):
- os.mkdir(new_save_dir)
- save_dir = new_save_dir
- download_and_decompress(
- all_sources[args.model][args.platform][args.soc],
- new_save_dir,
- rename=sdk_name + ".zip")
- os.remove(os.path.join(new_save_dir, sdk_name + ".zip"))
- print("Done. All the files of SDK have been extracted in {}.".format(
- new_save_dir))
+def RuntimeOptionStr(runtime_option):
+ attrs = dir(runtime_option)
+ message = "RuntimeOption(\n"
+ for attr in attrs:
+ if attr.startswith("__"):
+ continue
+ message += " {} : {}\t\n".format(attr, getattr(runtime_option, attr))
+ message.strip("\n")
+ message += ")"
+ return message
-if __name__ == "__main__":
- main()
+C.TensorInfo.__repr__ = TensorInfoStr
+C.RuntimeOption.__repr__ = RuntimeOptionStr
diff --git a/fastdeploy/backends/backend.h b/fastdeploy/backends/backend.h
new file mode 100644
index 0000000000..240f407340
--- /dev/null
+++ b/fastdeploy/backends/backend.h
@@ -0,0 +1,48 @@
+// 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.
+
+#pragma once
+
+#include
+#include
+#include
+#include
+
+#include "fastdeploy/core/fd_tensor.h"
+
+namespace fastdeploy {
+
+struct TensorInfo {
+ std::string name;
+ std::vector shape;
+ FDDataType dtype;
+};
+
+class BaseBackend {
+ public:
+ bool initialized_ = false;
+
+ BaseBackend() {}
+
+ virtual bool Initialized() const { return initialized_; }
+
+ virtual int NumInputs() const = 0;
+ virtual int NumOutputs() const = 0;
+ virtual TensorInfo GetInputInfo(int index) = 0;
+ virtual TensorInfo GetOutputInfo(int index) = 0;
+ virtual bool Infer(std::vector& inputs,
+ std::vector* outputs) = 0;
+};
+
+} // namespace fastdeploy
diff --git a/fastdeploy/backends/ort/ort_backend.cc b/fastdeploy/backends/ort/ort_backend.cc
new file mode 100644
index 0000000000..7060b758c1
--- /dev/null
+++ b/fastdeploy/backends/ort/ort_backend.cc
@@ -0,0 +1,278 @@
+// 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/backends/ort/ort_backend.h"
+#include "fastdeploy/backends/ort/utils.h"
+#include "fastdeploy/utils/utils.h"
+#include
+#ifdef ENABLE_PADDLE_FRONTEND
+#include "paddle2onnx/converter.h"
+#endif
+
+namespace fastdeploy {
+
+ONNXTensorElementDataType GetOrtDtype(FDDataType fd_dtype) {
+ if (fd_dtype == FDDataType::FP32) {
+ return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT;
+ } else if (fd_dtype == FDDataType::FP64) {
+ return ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE;
+ } else if (fd_dtype == FDDataType::INT32) {
+ return ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32;
+ } else if (fd_dtype == FDDataType::INT64) {
+ return ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64;
+ }
+ FDERROR << "Unrecognized fastdeply data type:" << FDDataTypeStr(fd_dtype)
+ << "." << std::endl;
+ return ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED;
+}
+
+FDDataType GetFdDtype(ONNXTensorElementDataType ort_dtype) {
+ if (ort_dtype == ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT) {
+ return FDDataType::FP32;
+ } else if (ort_dtype == ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE) {
+ return FDDataType::FP64;
+ } else if (ort_dtype == ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32) {
+ return FDDataType::INT32;
+ } else if (ort_dtype == ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64) {
+ return FDDataType::INT64;
+ }
+ FDERROR << "Unrecognized ort data type:" << ort_dtype << "." << std::endl;
+ return FDDataType::FP32;
+}
+
+void OrtBackend::BuildOption(const OrtBackendOption& option) {
+ option_ = option;
+ if (option.graph_optimization_level >= 0) {
+ session_options_.SetGraphOptimizationLevel(
+ GraphOptimizationLevel(option.graph_optimization_level));
+ }
+ if (option.intra_op_num_threads >= 0) {
+ session_options_.SetIntraOpNumThreads(option.intra_op_num_threads);
+ }
+ if (option.inter_op_num_threads >= 0) {
+ session_options_.SetInterOpNumThreads(option.inter_op_num_threads);
+ }
+ if (option.execution_mode >= 0) {
+ session_options_.SetExecutionMode(ExecutionMode(option.execution_mode));
+ }
+ if (option.use_gpu) {
+ auto all_providers = Ort::GetAvailableProviders();
+ bool support_cuda = false;
+ std::string providers_msg = "";
+ for (size_t i = 0; i < all_providers.size(); ++i) {
+ providers_msg = providers_msg + all_providers[i] + ", ";
+ if (all_providers[i] == "CUDAExecutionProvider") {
+ support_cuda = true;
+ }
+ }
+ if (!support_cuda) {
+ FDLogger() << "[WARN] Compiled fastdeploy with onnxruntime doesn't "
+ "support GPU, the available providers are "
+ << providers_msg << "will fallback to CPUExecutionProvider."
+ << std::endl;
+ option_.use_gpu = false;
+ } else {
+ FDASSERT(option.gpu_id == 0, "Requires gpu_id == 0, but now gpu_id = " +
+ std::to_string(option.gpu_id) + ".");
+ OrtCUDAProviderOptions cuda_options;
+ cuda_options.device_id = option.gpu_id;
+ session_options_.AppendExecutionProvider_CUDA(cuda_options);
+ }
+ }
+}
+
+bool OrtBackend::InitFromPaddle(const std::string& model_file,
+ const std::string& params_file,
+ const OrtBackendOption& option, bool verbose) {
+ if (initialized_) {
+ FDERROR << "OrtBackend is already initlized, cannot initialize again."
+ << std::endl;
+ return false;
+ }
+#ifdef ENABLE_PADDLE_FRONTEND
+ char* model_content_ptr;
+ int model_content_size = 0;
+ if (!paddle2onnx::Export(model_file.c_str(), params_file.c_str(),
+ &model_content_ptr, &model_content_size, 11, true,
+ verbose, true, true, true)) {
+ FDERROR << "Error occured while export PaddlePaddle to ONNX format."
+ << std::endl;
+ return false;
+ }
+ std::string onnx_model_proto(model_content_ptr,
+ model_content_ptr + model_content_size);
+ delete model_content_ptr;
+ model_content_ptr = nullptr;
+ return InitFromOnnx(onnx_model_proto, option, true);
+#else
+ FDERROR << "Didn't compile with PaddlePaddle frontend, you can try to "
+ "call `InitFromOnnx` instead."
+ << std::endl;
+#endif
+ return false;
+}
+
+bool OrtBackend::InitFromOnnx(const std::string& model_file,
+ const OrtBackendOption& option,
+ bool from_memory_buffer) {
+ if (initialized_) {
+ FDERROR << "OrtBackend is already initlized, cannot initialize again."
+ << std::endl;
+ return false;
+ }
+ BuildOption(option);
+ if (from_memory_buffer) {
+ session_ = {env_, model_file.data(), model_file.size(), session_options_};
+ } else {
+#ifdef _WIN32
+ session_ = {env_,
+ std::wstring(model_file.begin(), model_file.end()).c_str(),
+ session_options_};
+#else
+ session_ = {env_, model_file.c_str(), session_options_};
+#endif
+ }
+ binding_ = std::make_shared(session_);
+
+ Ort::MemoryInfo memory_info("Cpu", OrtDeviceAllocator, 0, OrtMemTypeDefault);
+ Ort::Allocator allocator(session_, memory_info);
+ size_t n_inputs = session_.GetInputCount();
+ for (size_t i = 0; i < n_inputs; ++i) {
+ auto input_name = session_.GetInputName(i, allocator);
+ auto type_info = session_.GetInputTypeInfo(i);
+ std::vector shape =
+ type_info.GetTensorTypeAndShapeInfo().GetShape();
+ ONNXTensorElementDataType data_type =
+ type_info.GetTensorTypeAndShapeInfo().GetElementType();
+ inputs_desc_.emplace_back(OrtValueInfo{input_name, shape, data_type});
+ allocator.Free(input_name);
+ }
+
+ size_t n_outputs = session_.GetOutputCount();
+ for (size_t i = 0; i < n_outputs; ++i) {
+ auto output_name = session_.GetOutputName(i, allocator);
+ auto type_info = session_.GetOutputTypeInfo(i);
+ std::vector shape =
+ type_info.GetTensorTypeAndShapeInfo().GetShape();
+ ONNXTensorElementDataType data_type =
+ type_info.GetTensorTypeAndShapeInfo().GetElementType();
+ outputs_desc_.emplace_back(OrtValueInfo{output_name, shape, data_type});
+
+ Ort::MemoryInfo out_memory_info("Cpu", OrtDeviceAllocator, 0,
+ OrtMemTypeDefault);
+ binding_->BindOutput(output_name, out_memory_info);
+
+ allocator.Free(output_name);
+ }
+ initialized_ = true;
+ return true;
+}
+
+void OrtBackend::CopyToCpu(const Ort::Value& value, FDTensor* tensor) {
+ const auto info = value.GetTensorTypeAndShapeInfo();
+ const auto data_type = info.GetElementType();
+ size_t numel = info.GetElementCount();
+ tensor->shape = info.GetShape();
+
+ if (data_type == ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT) {
+ tensor->data.resize(numel * sizeof(float));
+ memcpy(static_cast(tensor->Data()), value.GetTensorData(),
+ numel * sizeof(float));
+ tensor->dtype = FDDataType::FP32;
+ } else if (data_type == ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32) {
+ tensor->data.resize(numel * sizeof(int32_t));
+ memcpy(static_cast(tensor->Data()), value.GetTensorData(),
+ numel * sizeof(int32_t));
+ tensor->dtype = FDDataType::INT32;
+ } else if (data_type == ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64) {
+ tensor->data.resize(numel * sizeof(int64_t));
+ memcpy(static_cast(tensor->Data()), value.GetTensorData(),
+ numel * sizeof(int64_t));
+ tensor->dtype = FDDataType::INT64;
+ } else if (data_type == ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE) {
+ tensor->data.resize(numel * sizeof(double));
+ memcpy(static_cast(tensor->Data()), value.GetTensorData(),
+ numel * sizeof(double));
+ tensor->dtype = FDDataType::FP64;
+ } else {
+ FDASSERT(false, "Unrecognized data type of " + std::to_string(data_type) +
+ " while calling OrtBackend::CopyToCpu().");
+ }
+}
+
+bool OrtBackend::Infer(std::vector& inputs,
+ std::vector* outputs) {
+ if (inputs.size() != inputs_desc_.size()) {
+ FDERROR << "[OrtBackend] Size of the inputs(" << inputs.size()
+ << ") should keep same with the inputs of this model("
+ << inputs_desc_.size() << ")." << std::endl;
+ return false;
+ }
+
+ // from FDTensor to Ort Inputs
+ for (size_t i = 0; i < inputs.size(); ++i) {
+ auto ort_value = CreateOrtValue(inputs[i], option_.use_gpu);
+ binding_->BindInput(inputs[i].name.c_str(), ort_value);
+ }
+
+ for (size_t i = 0; i < outputs_desc_.size(); ++i) {
+ Ort::MemoryInfo memory_info("Cpu", OrtDeviceAllocator, 0,
+ OrtMemTypeDefault);
+ binding_->BindOutput(outputs_desc_[i].name.c_str(), memory_info);
+ }
+
+ // Inference with inputs
+ try {
+ session_.Run({}, *(binding_.get()));
+ } catch (const std::exception& e) {
+ FDERROR << "Failed to Infer: " << e.what() << std::endl;
+ return false;
+ }
+
+ // Copy result after inference
+ std::vector ort_outputs = binding_->GetOutputValues();
+ outputs->resize(ort_outputs.size());
+ for (size_t i = 0; i < ort_outputs.size(); ++i) {
+ (*outputs)[i].name = outputs_desc_[i].name;
+ CopyToCpu(ort_outputs[i], &((*outputs)[i]));
+ }
+ return true;
+}
+
+TensorInfo OrtBackend::GetInputInfo(int index) {
+ FDASSERT(index < NumInputs(), "The index:" + std::to_string(index) +
+ " should less than the number of inputs:" +
+ std::to_string(NumInputs()) + ".");
+ TensorInfo info;
+ info.name = inputs_desc_[index].name;
+ info.shape.assign(inputs_desc_[index].shape.begin(),
+ inputs_desc_[index].shape.end());
+ info.dtype = GetFdDtype(inputs_desc_[index].dtype);
+ return info;
+}
+
+TensorInfo OrtBackend::GetOutputInfo(int index) {
+ FDASSERT(index < NumOutputs(),
+ "The index:" + std::to_string(index) +
+ " should less than the number of outputs:" +
+ std::to_string(NumOutputs()) + ".");
+ TensorInfo info;
+ info.name = outputs_desc_[index].name;
+ info.shape.assign(outputs_desc_[index].shape.begin(),
+ outputs_desc_[index].shape.end());
+ info.dtype = GetFdDtype(outputs_desc_[index].dtype);
+ return info;
+}
+
+} // namespace fastdeploy
diff --git a/fastdeploy/backends/ort/ort_backend.h b/fastdeploy/backends/ort/ort_backend.h
new file mode 100644
index 0000000000..3200c29352
--- /dev/null
+++ b/fastdeploy/backends/ort/ort_backend.h
@@ -0,0 +1,84 @@
+// 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.
+
+#pragma once
+
+#include
+#include
+#include
+#include
+
+#include "fastdeploy/backends/backend.h"
+#include "onnxruntime_cxx_api.h" // NOLINT
+
+namespace fastdeploy {
+
+struct OrtValueInfo {
+ std::string name;
+ std::vector shape;
+ ONNXTensorElementDataType dtype;
+};
+
+struct OrtBackendOption {
+ // -1 means default
+ // 0: ORT_DISABLE_ALL
+ // 1: ORT_ENABLE_BASIC
+ // 2: ORT_ENABLE_EXTENDED
+ // 99: ORT_ENABLE_ALL (enable some custom optimizations e.g bert)
+ int graph_optimization_level = -1;
+ int intra_op_num_threads = -1;
+ int inter_op_num_threads = -1;
+ // 0: ORT_SEQUENTIAL
+ // 1: ORT_PARALLEL
+ int execution_mode = -1;
+ bool use_gpu = false;
+ int gpu_id = 0;
+};
+
+class OrtBackend : public BaseBackend {
+ public:
+ OrtBackend() {}
+ void BuildOption(const OrtBackendOption& option);
+
+ bool InitFromPaddle(const std::string& model_file,
+ const std::string& params_file,
+ const OrtBackendOption& option = OrtBackendOption(),
+ bool verbose = false);
+
+ bool InitFromOnnx(const std::string& model_file,
+ const OrtBackendOption& option = OrtBackendOption(),
+ bool from_memory_buffer = false);
+
+ bool Infer(std::vector& inputs, std::vector* outputs);
+
+ int NumInputs() const { return inputs_desc_.size(); }
+
+ int NumOutputs() const { return outputs_desc_.size(); }
+
+ TensorInfo GetInputInfo(int index);
+ TensorInfo GetOutputInfo(int index);
+
+ private:
+ Ort::Env env_;
+ Ort::Session session_{nullptr};
+ Ort::SessionOptions session_options_;
+ std::shared_ptr binding_;
+ std::vector inputs_desc_;
+ std::vector outputs_desc_;
+
+ OrtBackendOption option_;
+
+ void CopyToCpu(const Ort::Value& value, FDTensor* tensor);
+};
+} // namespace fastdeploy
diff --git a/fastdeploy/backends/ort/utils.cc b/fastdeploy/backends/ort/utils.cc
new file mode 100644
index 0000000000..bbef1f3786
--- /dev/null
+++ b/fastdeploy/backends/ort/utils.cc
@@ -0,0 +1,67 @@
+// 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/backends/ort/utils.h"
+#include "fastdeploy/utils/utils.h"
+
+namespace fastdeploy {
+
+ONNXTensorElementDataType GetOrtDtype(const FDDataType& fd_dtype) {
+ if (fd_dtype == FDDataType::FP32) {
+ return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT;
+ } else if (fd_dtype == FDDataType::FP64) {
+ return ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE;
+ } else if (fd_dtype == FDDataType::INT32) {
+ return ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32;
+ } else if (fd_dtype == FDDataType::INT64) {
+ return ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64;
+ }
+ FDERROR << "Unrecognized fastdeply data type:" << FDDataTypeStr(fd_dtype)
+ << "." << std::endl;
+ return ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED;
+}
+
+FDDataType GetFdDtype(const ONNXTensorElementDataType& ort_dtype) {
+ if (ort_dtype == ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT) {
+ return FDDataType::FP32;
+ } else if (ort_dtype == ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE) {
+ return FDDataType::FP64;
+ } else if (ort_dtype == ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32) {
+ return FDDataType::INT32;
+ } else if (ort_dtype == ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64) {
+ return FDDataType::INT64;
+ }
+ FDERROR << "Unrecognized ort data type:" << ort_dtype << "." << std::endl;
+ return FDDataType::FP32;
+}
+
+Ort::Value CreateOrtValue(FDTensor& tensor, bool is_backend_cuda) {
+ FDASSERT(tensor.device == Device::GPU || tensor.device == Device::CPU,
+ "Only support tensor which device is CPU or GPU for OrtBackend.");
+ if (tensor.device == Device::GPU && is_backend_cuda) {
+ Ort::MemoryInfo memory_info("Cuda", OrtDeviceAllocator, 0,
+ OrtMemTypeDefault);
+ auto ort_value = Ort::Value::CreateTensor(
+ memory_info, tensor.MutableData(), tensor.Nbytes(), tensor.shape.data(),
+ tensor.shape.size(), GetOrtDtype(tensor.dtype));
+ return ort_value;
+ }
+ Ort::MemoryInfo memory_info("Cpu", OrtDeviceAllocator, 0, OrtMemTypeDefault);
+ auto ort_value = Ort::Value::CreateTensor(
+ memory_info, tensor.Data(), tensor.Nbytes(), tensor.shape.data(),
+ tensor.shape.size(), GetOrtDtype(tensor.dtype));
+ return ort_value;
+}
+
+} // namespace fastdeploy
diff --git a/fastdeploy/backends/ort/utils.h b/fastdeploy/backends/ort/utils.h
new file mode 100644
index 0000000000..b1b29e5ab1
--- /dev/null
+++ b/fastdeploy/backends/ort/utils.h
@@ -0,0 +1,39 @@
+// 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.
+
+#pragma once
+
+#include
+#include
+#include
+#include
+
+#include "fastdeploy/backends/backend.h"
+#include "onnxruntime_cxx_api.h" // NOLINT
+
+namespace fastdeploy {
+
+// Convert FDDataType to OrtDataType
+ONNXTensorElementDataType GetOrtDtype(const FDDataType& fd_dtype);
+
+// Convert OrtDataType to FDDataType
+FDDataType GetFdDtype(const ONNXTensorElementDataType* ort_dtype);
+
+// Create Ort::Value
+// is_backend_cuda specify if the onnxruntime use CUDAExectionProvider
+// While is_backend_cuda = true, and tensor.device = Device::GPU
+// Will directly share the cuda data in tensor to OrtValue
+Ort::Value CreateOrtValue(FDTensor& tensor, bool is_backend_cuda = false);
+
+} // namespace fastdeploy
diff --git a/fastdeploy/backends/tensorrt/common/BatchStream.h b/fastdeploy/backends/tensorrt/common/BatchStream.h
new file mode 100644
index 0000000000..2484ccc689
--- /dev/null
+++ b/fastdeploy/backends/tensorrt/common/BatchStream.h
@@ -0,0 +1,342 @@
+/*
+ * Copyright (c) 1993-2022, NVIDIA CORPORATION. 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.
+ */
+#ifndef BATCH_STREAM_H
+#define BATCH_STREAM_H
+
+#include "NvInfer.h"
+#include "common.h"
+#include
+#include
+#include
+
+class IBatchStream {
+ public:
+ virtual void reset(int firstBatch) = 0;
+ virtual bool next() = 0;
+ virtual void skip(int skipCount) = 0;
+ virtual float* getBatch() = 0;
+ virtual float* getLabels() = 0;
+ virtual int getBatchesRead() const = 0;
+ virtual int getBatchSize() const = 0;
+ virtual nvinfer1::Dims getDims() const = 0;
+};
+
+class MNISTBatchStream : public IBatchStream {
+ public:
+ MNISTBatchStream(int batchSize, int maxBatches, const std::string& dataFile,
+ const std::string& labelsFile,
+ const std::vector& directories)
+ : mBatchSize{batchSize}, mMaxBatches{maxBatches}, mDims{3, {1, 28, 28}}
+ //!< We already know the dimensions of MNIST images.
+ {
+ readDataFile(locateFile(dataFile, directories));
+ readLabelsFile(locateFile(labelsFile, directories));
+ }
+
+ void reset(int firstBatch) override { mBatchCount = firstBatch; }
+
+ bool next() override {
+ if (mBatchCount >= mMaxBatches) {
+ return false;
+ }
+ ++mBatchCount;
+ return true;
+ }
+
+ void skip(int skipCount) override { mBatchCount += skipCount; }
+
+ float* getBatch() override {
+ return mData.data() +
+ (mBatchCount * mBatchSize * samplesCommon::volume(mDims));
+ }
+
+ float* getLabels() override {
+ return mLabels.data() + (mBatchCount * mBatchSize);
+ }
+
+ int getBatchesRead() const override { return mBatchCount; }
+
+ int getBatchSize() const override { return mBatchSize; }
+
+ nvinfer1::Dims getDims() const override {
+ return Dims{4, {mBatchSize, mDims.d[0], mDims.d[1], mDims.d[2]}};
+ }
+
+ private:
+ void readDataFile(const std::string& dataFilePath) {
+ std::ifstream file{dataFilePath.c_str(), std::ios::binary};
+
+ int magicNumber, numImages, imageH, imageW;
+ file.read(reinterpret_cast(&magicNumber), sizeof(magicNumber));
+ // All values in the MNIST files are big endian.
+ magicNumber = samplesCommon::swapEndianness(magicNumber);
+ ASSERT(magicNumber == 2051 &&
+ "Magic Number does not match the expected value for an MNIST image "
+ "set");
+
+ // Read number of images and dimensions
+ file.read(reinterpret_cast(&numImages), sizeof(numImages));
+ file.read(reinterpret_cast(&imageH), sizeof(imageH));
+ file.read(reinterpret_cast(&imageW), sizeof(imageW));
+
+ numImages = samplesCommon::swapEndianness(numImages);
+ imageH = samplesCommon::swapEndianness(imageH);
+ imageW = samplesCommon::swapEndianness(imageW);
+
+ // The MNIST data is made up of unsigned bytes, so we need to cast to float
+ // and normalize.
+ int numElements = numImages * imageH * imageW;
+ std::vector rawData(numElements);
+ file.read(reinterpret_cast(rawData.data()),
+ numElements * sizeof(uint8_t));
+ mData.resize(numElements);
+ std::transform(rawData.begin(), rawData.end(), mData.begin(),
+ [](uint8_t val) { return static_cast(val) / 255.f; });
+ }
+
+ void readLabelsFile(const std::string& labelsFilePath) {
+ std::ifstream file{labelsFilePath.c_str(), std::ios::binary};
+ int magicNumber, numImages;
+ file.read(reinterpret_cast(&magicNumber), sizeof(magicNumber));
+ // All values in the MNIST files are big endian.
+ magicNumber = samplesCommon::swapEndianness(magicNumber);
+ ASSERT(magicNumber == 2049 &&
+ "Magic Number does not match the expected value for an MNIST labels "
+ "file");
+
+ file.read(reinterpret_cast(&numImages), sizeof(numImages));
+ numImages = samplesCommon::swapEndianness(numImages);
+
+ std::vector rawLabels(numImages);
+ file.read(reinterpret_cast(rawLabels.data()),
+ numImages * sizeof(uint8_t));
+ mLabels.resize(numImages);
+ std::transform(rawLabels.begin(), rawLabels.end(), mLabels.begin(),
+ [](uint8_t val) { return static_cast(val); });
+ }
+
+ int mBatchSize{0};
+ int mBatchCount{
+ 0}; //!< The batch that will be read on the next invocation of next()
+ int mMaxBatches{0};
+ Dims mDims{};
+ std::vector mData{};
+ std::vector mLabels{};
+};
+
+class BatchStream : public IBatchStream {
+ public:
+ BatchStream(int batchSize, int maxBatches, std::string prefix,
+ std::string suffix, std::vector directories)
+ : mBatchSize(batchSize), mMaxBatches(maxBatches), mPrefix(prefix),
+ mSuffix(suffix), mDataDir(directories) {
+ FILE* file = fopen(
+ locateFile(mPrefix + std::string("0") + mSuffix, mDataDir).c_str(),
+ "rb");
+ ASSERT(file != nullptr);
+ int d[4];
+ size_t readSize = fread(d, sizeof(int), 4, file);
+ ASSERT(readSize == 4);
+ mDims.nbDims = 4; // The number of dimensions.
+ mDims.d[0] = d[0]; // Batch Size
+ mDims.d[1] = d[1]; // Channels
+ mDims.d[2] = d[2]; // Height
+ mDims.d[3] = d[3]; // Width
+ ASSERT(mDims.d[0] > 0 && mDims.d[1] > 0 && mDims.d[2] > 0 &&
+ mDims.d[3] > 0);
+ fclose(file);
+
+ mImageSize = mDims.d[1] * mDims.d[2] * mDims.d[3];
+ mBatch.resize(mBatchSize * mImageSize, 0);
+ mLabels.resize(mBatchSize, 0);
+ mFileBatch.resize(mDims.d[0] * mImageSize, 0);
+ mFileLabels.resize(mDims.d[0], 0);
+ reset(0);
+ }
+
+ BatchStream(int batchSize, int maxBatches, std::string prefix,
+ std::vector directories)
+ : BatchStream(batchSize, maxBatches, prefix, ".batch", directories) {}
+
+ BatchStream(int batchSize, int maxBatches, nvinfer1::Dims dims,
+ std::string listFile, std::vector directories)
+ : mBatchSize(batchSize), mMaxBatches(maxBatches), mDims(dims),
+ mListFile(listFile), mDataDir(directories) {
+ mImageSize = mDims.d[1] * mDims.d[2] * mDims.d[3];
+ mBatch.resize(mBatchSize * mImageSize, 0);
+ mLabels.resize(mBatchSize, 0);
+ mFileBatch.resize(mDims.d[0] * mImageSize, 0);
+ mFileLabels.resize(mDims.d[0], 0);
+ reset(0);
+ }
+
+ // Resets data members
+ void reset(int firstBatch) override {
+ mBatchCount = 0;
+ mFileCount = 0;
+ mFileBatchPos = mDims.d[0];
+ skip(firstBatch);
+ }
+
+ // Advance to next batch and return true, or return false if there is no batch
+ // left.
+ bool next() override {
+ if (mBatchCount == mMaxBatches) {
+ return false;
+ }
+
+ for (int csize = 1, batchPos = 0; batchPos < mBatchSize;
+ batchPos += csize, mFileBatchPos += csize) {
+ ASSERT(mFileBatchPos > 0 && mFileBatchPos <= mDims.d[0]);
+ if (mFileBatchPos == mDims.d[0] && !update()) {
+ return false;
+ }
+
+ // copy the smaller of: elements left to fulfill the request, or elements
+ // left in the file buffer.
+ csize = std::min(mBatchSize - batchPos, mDims.d[0] - mFileBatchPos);
+ std::copy_n(getFileBatch() + mFileBatchPos * mImageSize,
+ csize * mImageSize, getBatch() + batchPos * mImageSize);
+ std::copy_n(getFileLabels() + mFileBatchPos, csize,
+ getLabels() + batchPos);
+ }
+ mBatchCount++;
+ return true;
+ }
+
+ // Skips the batches
+ void skip(int skipCount) override {
+ if (mBatchSize >= mDims.d[0] && mBatchSize % mDims.d[0] == 0 &&
+ mFileBatchPos == mDims.d[0]) {
+ mFileCount += skipCount * mBatchSize / mDims.d[0];
+ return;
+ }
+
+ int x = mBatchCount;
+ for (int i = 0; i < skipCount; i++) {
+ next();
+ }
+ mBatchCount = x;
+ }
+
+ float* getBatch() override { return mBatch.data(); }
+
+ float* getLabels() override { return mLabels.data(); }
+
+ int getBatchesRead() const override { return mBatchCount; }
+
+ int getBatchSize() const override { return mBatchSize; }
+
+ nvinfer1::Dims getDims() const override { return mDims; }
+
+ private:
+ float* getFileBatch() { return mFileBatch.data(); }
+
+ float* getFileLabels() { return mFileLabels.data(); }
+
+ bool update() {
+ if (mListFile.empty()) {
+ std::string inputFileName = locateFile(
+ mPrefix + std::to_string(mFileCount++) + mSuffix, mDataDir);
+ FILE* file = fopen(inputFileName.c_str(), "rb");
+ if (!file) {
+ return false;
+ }
+
+ int d[4];
+ size_t readSize = fread(d, sizeof(int), 4, file);
+ ASSERT(readSize == 4);
+ ASSERT(mDims.d[0] == d[0] && mDims.d[1] == d[1] && mDims.d[2] == d[2] &&
+ mDims.d[3] == d[3]);
+ size_t readInputCount =
+ fread(getFileBatch(), sizeof(float), mDims.d[0] * mImageSize, file);
+ ASSERT(readInputCount == size_t(mDims.d[0] * mImageSize));
+ size_t readLabelCount =
+ fread(getFileLabels(), sizeof(float), mDims.d[0], file);
+ ASSERT(readLabelCount == 0 || readLabelCount == size_t(mDims.d[0]));
+
+ fclose(file);
+ } else {
+ std::vector fNames;
+ std::ifstream file(locateFile(mListFile, mDataDir), std::ios::binary);
+ if (!file) {
+ return false;
+ }
+
+ sample::gLogInfo << "Batch #" << mFileCount << std::endl;
+ file.seekg(((mBatchCount * mBatchSize)) * 7);
+
+ for (int i = 1; i <= mBatchSize; i++) {
+ std::string sName;
+ std::getline(file, sName);
+ sName = sName + ".ppm";
+ sample::gLogInfo << "Calibrating with file " << sName << std::endl;
+ fNames.emplace_back(sName);
+ }
+
+ mFileCount++;
+
+ const int imageC = 3;
+ const int imageH = 300;
+ const int imageW = 300;
+ std::vector> ppms(
+ fNames.size());
+ for (uint32_t i = 0; i < fNames.size(); ++i) {
+ readPPMFile(locateFile(fNames[i], mDataDir), ppms[i]);
+ }
+
+ std::vector data(samplesCommon::volume(mDims));
+ const float scale = 2.0 / 255.0;
+ const float bias = 1.0;
+ long int volChl = mDims.d[2] * mDims.d[3];
+
+ // Normalize input data
+ for (int i = 0, volImg = mDims.d[1] * mDims.d[2] * mDims.d[3];
+ i < mBatchSize; ++i) {
+ for (int c = 0; c < mDims.d[1]; ++c) {
+ for (int j = 0; j < volChl; ++j) {
+ data[i * volImg + c * volChl + j] =
+ scale * float(ppms[i].buffer[j * mDims.d[1] + c]) - bias;
+ }
+ }
+ }
+
+ std::copy_n(data.data(), mDims.d[0] * mImageSize, getFileBatch());
+ }
+
+ mFileBatchPos = 0;
+ return true;
+ }
+
+ int mBatchSize{0};
+ int mMaxBatches{0};
+ int mBatchCount{0};
+ int mFileCount{0};
+ int mFileBatchPos{0};
+ int mImageSize{0};
+ std::vector mBatch; //!< Data for the batch
+ std::vector mLabels; //!< Labels for the batch
+ std::vector mFileBatch; //!< List of image files
+ std::vector mFileLabels; //!< List of label files
+ std::string mPrefix; //!< Batch file name prefix
+ std::string mSuffix; //!< Batch file name suffix
+ nvinfer1::Dims mDims; //!< Input dimensions
+ std::string mListFile; //!< File name of the list of image names
+ std::vector
+ mDataDir; //!< Directories where the files can be found
+};
+
+#endif
diff --git a/fastdeploy/backends/tensorrt/common/CPPLINT.cfg b/fastdeploy/backends/tensorrt/common/CPPLINT.cfg
new file mode 100644
index 0000000000..51ff339c18
--- /dev/null
+++ b/fastdeploy/backends/tensorrt/common/CPPLINT.cfg
@@ -0,0 +1 @@
+exclude_files=.*
diff --git a/fastdeploy/backends/tensorrt/common/EntropyCalibrator.h b/fastdeploy/backends/tensorrt/common/EntropyCalibrator.h
new file mode 100644
index 0000000000..40eb8f13e6
--- /dev/null
+++ b/fastdeploy/backends/tensorrt/common/EntropyCalibrator.h
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 1993-2022, NVIDIA CORPORATION. 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.
+ */
+
+#ifndef ENTROPY_CALIBRATOR_H
+#define ENTROPY_CALIBRATOR_H
+
+#include "BatchStream.h"
+#include "NvInfer.h"
+
+//! \class EntropyCalibratorImpl
+//!
+//! \brief Implements common functionality for Entropy calibrators.
+//!
+template class EntropyCalibratorImpl {
+ public:
+ EntropyCalibratorImpl(TBatchStream stream, int firstBatch,
+ std::string networkName, const char* inputBlobName,
+ bool readCache = true)
+ : mStream{stream},
+ mCalibrationTableName("CalibrationTable" + networkName),
+ mInputBlobName(inputBlobName), mReadCache(readCache) {
+ nvinfer1::Dims dims = mStream.getDims();
+ mInputCount = samplesCommon::volume(dims);
+ CHECK(cudaMalloc(&mDeviceInput, mInputCount * sizeof(float)));
+ mStream.reset(firstBatch);
+ }
+
+ virtual ~EntropyCalibratorImpl() { CHECK(cudaFree(mDeviceInput)); }
+
+ int getBatchSize() const noexcept { return mStream.getBatchSize(); }
+
+ bool getBatch(void* bindings[], const char* names[],
+ int nbBindings) noexcept {
+ if (!mStream.next()) {
+ return false;
+ }
+ CHECK(cudaMemcpy(mDeviceInput, mStream.getBatch(),
+ mInputCount * sizeof(float), cudaMemcpyHostToDevice));
+ ASSERT(!strcmp(names[0], mInputBlobName));
+ bindings[0] = mDeviceInput;
+ return true;
+ }
+
+ const void* readCalibrationCache(size_t& length) noexcept {
+ mCalibrationCache.clear();
+ std::ifstream input(mCalibrationTableName, std::ios::binary);
+ input >> std::noskipws;
+ if (mReadCache && input.good()) {
+ std::copy(std::istream_iterator(input),
+ std::istream_iterator(),
+ std::back_inserter(mCalibrationCache));
+ }
+ length = mCalibrationCache.size();
+ return length ? mCalibrationCache.data() : nullptr;
+ }
+
+ void writeCalibrationCache(const void* cache, size_t length) noexcept {
+ std::ofstream output(mCalibrationTableName, std::ios::binary);
+ output.write(reinterpret_cast(cache), length);
+ }
+
+ private:
+ TBatchStream mStream;
+ size_t mInputCount;
+ std::string mCalibrationTableName;
+ const char* mInputBlobName;
+ bool mReadCache{true};
+ void* mDeviceInput{nullptr};
+ std::vector mCalibrationCache;
+};
+
+//! \class Int8EntropyCalibrator2
+//!
+//! \brief Implements Entropy calibrator 2.
+//! CalibrationAlgoType is kENTROPY_CALIBRATION_2.
+//!
+template
+class Int8EntropyCalibrator2 : public IInt8EntropyCalibrator2 {
+ public:
+ Int8EntropyCalibrator2(TBatchStream stream, int firstBatch,
+ const char* networkName, const char* inputBlobName,
+ bool readCache = true)
+ : mImpl(stream, firstBatch, networkName, inputBlobName, readCache) {}
+
+ int getBatchSize() const noexcept override { return mImpl.getBatchSize(); }
+
+ bool getBatch(void* bindings[], const char* names[],
+ int nbBindings) noexcept override {
+ return mImpl.getBatch(bindings, names, nbBindings);
+ }
+
+ const void* readCalibrationCache(size_t& length) noexcept override {
+ return mImpl.readCalibrationCache(length);
+ }
+
+ void writeCalibrationCache(const void* cache,
+ size_t length) noexcept override {
+ mImpl.writeCalibrationCache(cache, length);
+ }
+
+ private:
+ EntropyCalibratorImpl mImpl;
+};
+
+#endif // ENTROPY_CALIBRATOR_H
diff --git a/fastdeploy/backends/tensorrt/common/ErrorRecorder.h b/fastdeploy/backends/tensorrt/common/ErrorRecorder.h
new file mode 100644
index 0000000000..e13b55bd93
--- /dev/null
+++ b/fastdeploy/backends/tensorrt/common/ErrorRecorder.h
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 1993-2022, NVIDIA CORPORATION. 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.
+ */
+
+#ifndef ERROR_RECORDER_H
+#define ERROR_RECORDER_H
+#include "NvInferRuntimeCommon.h"
+#include "logger.h"
+#include
+#include
+#include
+#include
+#include
+
+using nvinfer1::ErrorCode;
+using nvinfer1::IErrorRecorder;
+
+//!
+//! A simple implementation of the IErrorRecorder interface for
+//! use by samples. This interface also can be used as a reference
+//! implementation.
+//! The sample Error recorder is based on a vector that pairs the error
+//! code and the error string into a single element. It also uses
+//! standard mutex's and atomics in order to make sure that the code
+//! works in a multi-threaded environment.
+//!
+class SampleErrorRecorder : public IErrorRecorder {
+ using errorPair = std::pair;
+ using errorStack = std::vector;
+
+ public:
+ SampleErrorRecorder() = default;
+
+ virtual ~SampleErrorRecorder() noexcept {}
+ int32_t getNbErrors() const noexcept final { return mErrorStack.size(); }
+ ErrorCode getErrorCode(int32_t errorIdx) const noexcept final {
+ return invalidIndexCheck(errorIdx) ? ErrorCode::kINVALID_ARGUMENT
+ : (*this)[errorIdx].first;
+ };
+ IErrorRecorder::ErrorDesc
+ getErrorDesc(int32_t errorIdx) const noexcept final {
+ return invalidIndexCheck(errorIdx) ? "errorIdx out of range."
+ : (*this)[errorIdx].second.c_str();
+ }
+ // This class can never overflow since we have dynamic resize via std::vector
+ // usage.
+ bool hasOverflowed() const noexcept final { return false; }
+
+ // Empty the errorStack.
+ void clear() noexcept final {
+ try {
+ // grab a lock so that there is no addition while clearing.
+ std::lock_guard guard(mStackLock);
+ mErrorStack.clear();
+ } catch (const std::exception& e) {
+ sample::gLogFatal << "Internal Error: " << e.what() << std::endl;
+ }
+ };
+
+ //! Simple helper function that
+ bool empty() const noexcept { return mErrorStack.empty(); }
+
+ bool reportError(ErrorCode val,
+ IErrorRecorder::ErrorDesc desc) noexcept final {
+ try {
+ std::lock_guard guard(mStackLock);
+ sample::gLogError << "Error[" << static_cast(val)
+ << "]: " << desc << std::endl;
+ mErrorStack.push_back(errorPair(val, desc));
+ } catch (const std::exception& e) {
+ sample::gLogFatal << "Internal Error: " << e.what() << std::endl;
+ }
+ // All errors are considered fatal.
+ return true;
+ }
+
+ // Atomically increment or decrement the ref counter.
+ IErrorRecorder::RefCount incRefCount() noexcept final { return ++mRefCount; }
+ IErrorRecorder::RefCount decRefCount() noexcept final { return --mRefCount; }
+
+ private:
+ // Simple helper functions.
+ const errorPair& operator[](size_t index) const noexcept {
+ return mErrorStack[index];
+ }
+
+ bool invalidIndexCheck(int32_t index) const noexcept {
+ // By converting signed to unsigned, we only need a single check since
+ // negative numbers turn into large positive greater than the size.
+ size_t sIndex = index;
+ return sIndex >= mErrorStack.size();
+ }
+ // Mutex to hold when locking mErrorStack.
+ std::mutex mStackLock;
+
+ // Reference count of the class. Destruction of the class when mRefCount
+ // is not zero causes undefined behavior.
+ std::atomic mRefCount{0};
+
+ // The error stack that holds the errors recorded by TensorRT.
+ errorStack mErrorStack;
+}; // class SampleErrorRecorder
+#endif // ERROR_RECORDER_H
diff --git a/fastdeploy/backends/tensorrt/common/README.md b/fastdeploy/backends/tensorrt/common/README.md
new file mode 100644
index 0000000000..0ed86b17a5
--- /dev/null
+++ b/fastdeploy/backends/tensorrt/common/README.md
@@ -0,0 +1 @@
+目录代码来源自 https://github.com/NVIDIA/TensorRT
diff --git a/fastdeploy/backends/tensorrt/common/argsParser.h b/fastdeploy/backends/tensorrt/common/argsParser.h
new file mode 100644
index 0000000000..e2e1b1e95f
--- /dev/null
+++ b/fastdeploy/backends/tensorrt/common/argsParser.h
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 1993-2022, NVIDIA CORPORATION. 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.
+ */
+#ifndef TENSORRT_ARGS_PARSER_H
+#define TENSORRT_ARGS_PARSER_H
+
+#include
+#include
+#ifdef _MSC_VER
+#include ".\windows\getopt.h"
+#else
+#include
+#endif
+#include
+
+namespace samplesCommon {
+
+//!
+//! \brief The SampleParams structure groups the basic parameters required by
+//! all sample networks.
+//!
+struct SampleParams {
+ int32_t batchSize{1}; //!< Number of inputs in a batch
+ int32_t dlaCore{-1}; //!< Specify the DLA core to run network on.
+ bool int8{false}; //!< Allow runnning the network in Int8 mode.
+ bool fp16{false}; //!< Allow running the network in FP16 mode.
+ std::vector
+ dataDirs; //!< Directory paths where sample data files are stored
+ std::vector inputTensorNames;
+ std::vector outputTensorNames;
+};
+
+//!
+//! \brief The CaffeSampleParams structure groups the additional parameters
+//! required by
+//! networks that use caffe
+//!
+struct CaffeSampleParams : public SampleParams {
+ std::string
+ prototxtFileName; //!< Filename of prototxt design file of a network
+ std::string
+ weightsFileName; //!< Filename of trained weights file of a network
+ std::string meanFileName; //!< Filename of mean file of a network
+};
+
+//!
+//! \brief The OnnxSampleParams structure groups the additional parameters
+//! required by
+//! networks that use ONNX
+//!
+struct OnnxSampleParams : public SampleParams {
+ std::string onnxFileName; //!< Filename of ONNX file of a network
+};
+
+//!
+//! \brief The UffSampleParams structure groups the additional parameters
+//! required by
+//! networks that use Uff
+//!
+struct UffSampleParams : public SampleParams {
+ std::string uffFileName; //!< Filename of uff file of a network
+};
+
+//!
+//! /brief Struct to maintain command-line arguments.
+//!
+struct Args {
+ bool runInInt8{false};
+ bool runInFp16{false};
+ bool help{false};
+ int32_t useDLACore{-1};
+ int32_t batch{1};
+ std::vector dataDirs;
+ std::string saveEngine;
+ std::string loadEngine;
+ bool useILoop{false};
+};
+
+//!
+//! \brief Populates the Args struct with the provided command-line parameters.
+//!
+//! \throw invalid_argument if any of the arguments are not valid
+//!
+//! \return boolean If return value is true, execution can continue, otherwise
+//! program should exit
+//!
+inline bool parseArgs(Args& args, int32_t argc, char* argv[]) {
+ while (1) {
+ int32_t arg;
+ static struct option long_options[] = {
+ {"help", no_argument, 0, 'h'},
+ {"datadir", required_argument, 0, 'd'},
+ {"int8", no_argument, 0, 'i'},
+ {"fp16", no_argument, 0, 'f'},
+ {"useILoop", no_argument, 0, 'l'},
+ {"saveEngine", required_argument, 0, 's'},
+ {"loadEngine", no_argument, 0, 'o'},
+ {"useDLACore", required_argument, 0, 'u'},
+ {"batch", required_argument, 0, 'b'},
+ {nullptr, 0, nullptr, 0}};
+ int32_t option_index = 0;
+ arg = getopt_long(argc, argv, "hd:iu", long_options, &option_index);
+ if (arg == -1) {
+ break;
+ }
+
+ switch (arg) {
+ case 'h':
+ args.help = true;
+ return true;
+ case 'd':
+ if (optarg) {
+ args.dataDirs.push_back(optarg);
+ } else {
+ std::cerr << "ERROR: --datadir requires option argument" << std::endl;
+ return false;
+ }
+ break;
+ case 's':
+ if (optarg) {
+ args.saveEngine = optarg;
+ }
+ break;
+ case 'o':
+ if (optarg) {
+ args.loadEngine = optarg;
+ }
+ break;
+ case 'i':
+ args.runInInt8 = true;
+ break;
+ case 'f':
+ args.runInFp16 = true;
+ break;
+ case 'l':
+ args.useILoop = true;
+ break;
+ case 'u':
+ if (optarg) {
+ args.useDLACore = std::stoi(optarg);
+ }
+ break;
+ case 'b':
+ if (optarg) {
+ args.batch = std::stoi(optarg);
+ }
+ break;
+ default:
+ return false;
+ }
+ }
+ return true;
+}
+
+} // namespace samplesCommon
+
+#endif // TENSORRT_ARGS_PARSER_H
diff --git a/fastdeploy/backends/tensorrt/common/buffers.h b/fastdeploy/backends/tensorrt/common/buffers.h
new file mode 100644
index 0000000000..8061ee33d1
--- /dev/null
+++ b/fastdeploy/backends/tensorrt/common/buffers.h
@@ -0,0 +1,426 @@
+/*
+ * Copyright (c) 1993-2022, NVIDIA CORPORATION. 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.
+ */
+#ifndef TENSORRT_BUFFERS_H
+#define TENSORRT_BUFFERS_H
+
+#include "NvInfer.h"
+#include "common.h"
+#include "half.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace samplesCommon {
+
+//!
+//! \brief The GenericBuffer class is a templated class for buffers.
+//!
+//! \details This templated RAII (Resource Acquisition Is Initialization) class
+//! handles the allocation,
+//! deallocation, querying of buffers on both the device and the host.
+//! It can handle data of arbitrary types because it stores byte
+//! buffers.
+//! The template parameters AllocFunc and FreeFunc are used for the
+//! allocation and deallocation of the buffer.
+//! AllocFunc must be a functor that takes in (void** ptr, size_t size)
+//! and returns bool. ptr is a pointer to where the allocated buffer
+//! address should be stored.
+//! size is the amount of memory in bytes to allocate.
+//! The boolean indicates whether or not the memory allocation was
+//! successful.
+//! FreeFunc must be a functor that takes in (void* ptr) and returns
+//! void.
+//! ptr is the allocated buffer address. It must work with nullptr
+//! input.
+//!
+template class GenericBuffer {
+ public:
+ //!
+ //! \brief Construct an empty buffer.
+ //!
+ GenericBuffer(nvinfer1::DataType type = nvinfer1::DataType::kFLOAT)
+ : mSize(0), mCapacity(0), mType(type), mBuffer(nullptr) {}
+
+ //!
+ //! \brief Construct a buffer with the specified allocation size in bytes.
+ //!
+ GenericBuffer(size_t size, nvinfer1::DataType type)
+ : mSize(size), mCapacity(size), mType(type) {
+ if (!allocFn(&mBuffer, this->nbBytes())) {
+ throw std::bad_alloc();
+ }
+ }
+
+ GenericBuffer(GenericBuffer&& buf)
+ : mSize(buf.mSize), mCapacity(buf.mCapacity), mType(buf.mType),
+ mBuffer(buf.mBuffer) {
+ buf.mSize = 0;
+ buf.mCapacity = 0;
+ buf.mType = nvinfer1::DataType::kFLOAT;
+ buf.mBuffer = nullptr;
+ }
+
+ GenericBuffer& operator=(GenericBuffer&& buf) {
+ if (this != &buf) {
+ freeFn(mBuffer);
+ mSize = buf.mSize;
+ mCapacity = buf.mCapacity;
+ mType = buf.mType;
+ mBuffer = buf.mBuffer;
+ // Reset buf.
+ buf.mSize = 0;
+ buf.mCapacity = 0;
+ buf.mBuffer = nullptr;
+ }
+ return *this;
+ }
+
+ //!
+ //! \brief Returns pointer to underlying array.
+ //!
+ void* data() { return mBuffer; }
+
+ //!
+ //! \brief Returns pointer to underlying array.
+ //!
+ const void* data() const { return mBuffer; }
+
+ //!
+ //! \brief Returns the size (in number of elements) of the buffer.
+ //!
+ size_t size() const { return mSize; }
+
+ //!
+ //! \brief Returns the size (in bytes) of the buffer.
+ //!
+ size_t nbBytes() const {
+ return this->size() * samplesCommon::getElementSize(mType);
+ }
+
+ //!
+ //! \brief Resizes the buffer. This is a no-op if the new size is smaller than
+ //! or equal to the current capacity.
+ //!
+ void resize(size_t newSize) {
+ mSize = newSize;
+ if (mCapacity < newSize) {
+ freeFn(mBuffer);
+ if (!allocFn(&mBuffer, this->nbBytes())) {
+ throw std::bad_alloc{};
+ }
+ mCapacity = newSize;
+ }
+ }
+
+ //!
+ //! \brief Overload of resize that accepts Dims
+ //!
+ void resize(const nvinfer1::Dims& dims) {
+ return this->resize(samplesCommon::volume(dims));
+ }
+
+ ~GenericBuffer() { freeFn(mBuffer); }
+
+ private:
+ size_t mSize{0}, mCapacity{0};
+ nvinfer1::DataType mType;
+ void* mBuffer;
+ AllocFunc allocFn;
+ FreeFunc freeFn;
+};
+
+class DeviceAllocator {
+ public:
+ bool operator()(void** ptr, size_t size) const {
+ return cudaMalloc(ptr, size) == cudaSuccess;
+ }
+};
+
+class DeviceFree {
+ public:
+ void operator()(void* ptr) const { cudaFree(ptr); }
+};
+
+class HostAllocator {
+ public:
+ bool operator()(void** ptr, size_t size) const {
+ *ptr = malloc(size);
+ return *ptr != nullptr;
+ }
+};
+
+class HostFree {
+ public:
+ void operator()(void* ptr) const { free(ptr); }
+};
+
+using DeviceBuffer = GenericBuffer;
+using HostBuffer = GenericBuffer;
+
+//!
+//! \brief The ManagedBuffer class groups together a pair of corresponding
+//! device and host buffers.
+//!
+class ManagedBuffer {
+ public:
+ DeviceBuffer deviceBuffer;
+ HostBuffer hostBuffer;
+};
+
+//!
+//! \brief The BufferManager class handles host and device buffer allocation
+//! and deallocation.
+//!
+//! \details This RAII class handles host and device buffer allocation and
+//! deallocation,
+//! memcpy between host and device buffers to aid with inference,
+//! and debugging dumps to validate inference. The BufferManager class
+//! is meant to be
+//! used to simplify buffer management and any interactions between
+//! buffers and the engine.
+//!
+class BufferManager {
+ public:
+ static const size_t kINVALID_SIZE_VALUE = ~size_t(0);
+
+ //!
+ //! \brief Create a BufferManager for handling buffer interactions with
+ //! engine.
+ //!
+ BufferManager(std::shared_ptr engine,
+ const int batchSize = 0,
+ const nvinfer1::IExecutionContext* context = nullptr)
+ : mEngine(engine), mBatchSize(batchSize) {
+ // Full Dims implies no batch size.
+ assert(engine->hasImplicitBatchDimension() || mBatchSize == 0);
+ // Create host and device buffers
+ for (int i = 0; i < mEngine->getNbBindings(); i++) {
+ auto dims = context ? context->getBindingDimensions(i)
+ : mEngine->getBindingDimensions(i);
+ size_t vol = context || !mBatchSize ? 1 : static_cast(mBatchSize);
+ nvinfer1::DataType type = mEngine->getBindingDataType(i);
+ int vecDim = mEngine->getBindingVectorizedDim(i);
+ if (-1 != vecDim) // i.e., 0 != lgScalarsPerVector
+ {
+ int scalarsPerVec = mEngine->getBindingComponentsPerElement(i);
+ dims.d[vecDim] = divUp(dims.d[vecDim], scalarsPerVec);
+ vol *= scalarsPerVec;
+ }
+ vol *= samplesCommon::volume(dims);
+ std::unique_ptr manBuf{new ManagedBuffer()};
+ manBuf->deviceBuffer = DeviceBuffer(vol, type);
+ manBuf->hostBuffer = HostBuffer(vol, type);
+ mDeviceBindings.emplace_back(manBuf->deviceBuffer.data());
+ mManagedBuffers.emplace_back(std::move(manBuf));
+ }
+ }
+
+ //!
+ //! \brief Returns a vector of device buffers that you can use directly as
+ //! bindings for the execute and enqueue methods of IExecutionContext.
+ //!
+ std::vector& getDeviceBindings() { return mDeviceBindings; }
+
+ //!
+ //! \brief Returns a vector of device buffers.
+ //!
+ const std::vector& getDeviceBindings() const {
+ return mDeviceBindings;
+ }
+
+ //!
+ //! \brief Returns the device buffer corresponding to tensorName.
+ //! Returns nullptr if no such tensor can be found.
+ //!
+ void* getDeviceBuffer(const std::string& tensorName) const {
+ return getBuffer(false, tensorName);
+ }
+
+ //!
+ //! \brief Returns the host buffer corresponding to tensorName.
+ //! Returns nullptr if no such tensor can be found.
+ //!
+ void* getHostBuffer(const std::string& tensorName) const {
+ return getBuffer(true, tensorName);
+ }
+
+ //!
+ //! \brief Returns the size of the host and device buffers that correspond to
+ //! tensorName.
+ //! Returns kINVALID_SIZE_VALUE if no such tensor can be found.
+ //!
+ size_t size(const std::string& tensorName) const {
+ int index = mEngine->getBindingIndex(tensorName.c_str());
+ if (index == -1)
+ return kINVALID_SIZE_VALUE;
+ return mManagedBuffers[index]->hostBuffer.nbBytes();
+ }
+
+ //!
+ //! \brief Dump host buffer with specified tensorName to ostream.
+ //! Prints error message to std::ostream if no such tensor can be
+ //! found.
+ //!
+ void dumpBuffer(std::ostream& os, const std::string& tensorName) {
+ int index = mEngine->getBindingIndex(tensorName.c_str());
+ if (index == -1) {
+ os << "Invalid tensor name" << std::endl;
+ return;
+ }
+ void* buf = mManagedBuffers[index]->hostBuffer.data();
+ size_t bufSize = mManagedBuffers[index]->hostBuffer.nbBytes();
+ nvinfer1::Dims bufDims = mEngine->getBindingDimensions(index);
+ size_t rowCount = static_cast(
+ bufDims.nbDims > 0 ? bufDims.d[bufDims.nbDims - 1] : mBatchSize);
+ int leadDim = mBatchSize;
+ int* trailDims = bufDims.d;
+ int nbDims = bufDims.nbDims;
+
+ // Fix explicit Dimension networks
+ if (!leadDim && nbDims > 0) {
+ leadDim = bufDims.d[0];
+ ++trailDims;
+ --nbDims;
+ }
+
+ os << "[" << leadDim;
+ for (int i = 0; i < nbDims; i++)
+ os << ", " << trailDims[i];
+ os << "]" << std::endl;
+ switch (mEngine->getBindingDataType(index)) {
+ case nvinfer1::DataType::kINT32:
+ print(os, buf, bufSize, rowCount);
+ break;
+ case nvinfer1::DataType::kFLOAT:
+ print(os, buf, bufSize, rowCount);
+ break;
+ case nvinfer1::DataType::kHALF:
+ print(os, buf, bufSize, rowCount);
+ break;
+ case nvinfer1::DataType::kINT8:
+ assert(0 && "Int8 network-level input and output is not supported");
+ break;
+ case nvinfer1::DataType::kBOOL:
+ assert(0 && "Bool network-level input and output are not supported");
+ break;
+ }
+ }
+
+ //!
+ //! \brief Templated print function that dumps buffers of arbitrary type to
+ //! std::ostream.
+ //! rowCount parameter controls how many elements are on each line.
+ //! A rowCount of 1 means that there is only 1 element on each line.
+ //!
+ template
+ void print(std::ostream& os, void* buf, size_t bufSize, size_t rowCount) {
+ assert(rowCount != 0);
+ assert(bufSize % sizeof(T) == 0);
+ T* typedBuf = static_cast(buf);
+ size_t numItems = bufSize / sizeof(T);
+ for (int i = 0; i < static_cast(numItems); i++) {
+ // Handle rowCount == 1 case
+ if (rowCount == 1 && i != static_cast(numItems) - 1)
+ os << typedBuf[i] << std::endl;
+ else if (rowCount == 1)
+ os << typedBuf[i];
+ // Handle rowCount > 1 case
+ else if (i % rowCount == 0)
+ os << typedBuf[i];
+ else if (i % rowCount == rowCount - 1)
+ os << " " << typedBuf[i] << std::endl;
+ else
+ os << " " << typedBuf[i];
+ }
+ }
+
+ //!
+ //! \brief Copy the contents of input host buffers to input device buffers
+ //! synchronously.
+ //!
+ void copyInputToDevice() { memcpyBuffers(true, false, false); }
+
+ //!
+ //! \brief Copy the contents of output device buffers to output host buffers
+ //! synchronously.
+ //!
+ void copyOutputToHost() { memcpyBuffers(false, true, false); }
+
+ //!
+ //! \brief Copy the contents of input host buffers to input device buffers
+ //! asynchronously.
+ //!
+ void copyInputToDeviceAsync(const cudaStream_t& stream = 0) {
+ memcpyBuffers(true, false, true, stream);
+ }
+
+ //!
+ //! \brief Copy the contents of output device buffers to output host buffers
+ //! asynchronously.
+ //!
+ void copyOutputToHostAsync(const cudaStream_t& stream = 0) {
+ memcpyBuffers(false, true, true, stream);
+ }
+
+ ~BufferManager() = default;
+
+ private:
+ void* getBuffer(const bool isHost, const std::string& tensorName) const {
+ int index = mEngine->getBindingIndex(tensorName.c_str());
+ if (index == -1)
+ return nullptr;
+ return (isHost ? mManagedBuffers[index]->hostBuffer.data()
+ : mManagedBuffers[index]->deviceBuffer.data());
+ }
+
+ void memcpyBuffers(const bool copyInput, const bool deviceToHost,
+ const bool async, const cudaStream_t& stream = 0) {
+ for (int i = 0; i < mEngine->getNbBindings(); i++) {
+ void* dstPtr = deviceToHost ? mManagedBuffers[i]->hostBuffer.data()
+ : mManagedBuffers[i]->deviceBuffer.data();
+ const void* srcPtr = deviceToHost
+ ? mManagedBuffers[i]->deviceBuffer.data()
+ : mManagedBuffers[i]->hostBuffer.data();
+ const size_t byteSize = mManagedBuffers[i]->hostBuffer.nbBytes();
+ const cudaMemcpyKind memcpyType =
+ deviceToHost ? cudaMemcpyDeviceToHost : cudaMemcpyHostToDevice;
+ if ((copyInput && mEngine->bindingIsInput(i)) ||
+ (!copyInput && !mEngine->bindingIsInput(i))) {
+ if (async)
+ CHECK(cudaMemcpyAsync(dstPtr, srcPtr, byteSize, memcpyType, stream));
+ else
+ CHECK(cudaMemcpy(dstPtr, srcPtr, byteSize, memcpyType));
+ }
+ }
+ }
+
+ std::shared_ptr mEngine; //!< The pointer to the engine
+ int mBatchSize; //!< The batch size for legacy networks, 0 otherwise.
+ std::vector>
+ mManagedBuffers; //!< The vector of pointers to managed buffers
+ std::vector mDeviceBindings; //!< The vector of device buffers needed
+ //! for engine execution
+};
+
+} // namespace samplesCommon
+
+#endif // TENSORRT_BUFFERS_H
diff --git a/fastdeploy/backends/tensorrt/common/common.h b/fastdeploy/backends/tensorrt/common/common.h
new file mode 100644
index 0000000000..ad3af72a2b
--- /dev/null
+++ b/fastdeploy/backends/tensorrt/common/common.h
@@ -0,0 +1,844 @@
+/*
+ * Copyright (c) 1993-2022, NVIDIA CORPORATION. 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.
+ */
+
+#ifndef TENSORRT_COMMON_H
+#define TENSORRT_COMMON_H
+
+// For loadLibrary
+#ifdef _MSC_VER
+// Needed so that the max/min definitions in windows.h do not conflict with
+// std::max/min.
+#define NOMINMAX
+#include
+#undef NOMINMAX
+#else
+#include
+#endif
+
+#include "NvInfer.h"
+#include "NvInferPlugin.h"
+#include "logger.h"
+#include
+#include
+#include
+#include
+#include
+#include