[C API] Refactor code structure (#1449)

* refactor code

* move files

* fix doc

* fix
This commit is contained in:
chenjian
2023-02-27 20:19:13 +08:00
committed by GitHub
parent 48f776b9db
commit 266ae046f2
34 changed files with 158 additions and 132 deletions

View File

@@ -19,7 +19,7 @@ if(NOT WITH_CAPI)
return()
endif()
configure_file(${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/c_api/fastdeploy_capi/config.h.in ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/c_api/fastdeploy_capi/config.h)
configure_file(${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/c_api/fastdeploy_capi/core/config.h.in ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/c_api/fastdeploy_capi/core/config.h)
file(GLOB_RECURSE DEPLOY_CAPI_SRCS ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/c_api/fastdeploy_capi/*.cc)
if(NOT ENABLE_VISION)
file(GLOB_RECURSE DEPLOY_VISION_CAPI_SRCS ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/c_api/fastdeploy_capi/vision/*.cc)

View File

@@ -0,0 +1,22 @@
// Copyright (c) 2023 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
#ifndef ENABLE_VISION
#define ENABLE_VISION
#endif
#ifndef ENABLE_TEXT
#define ENABLE_TEXT
#endif

View File

@@ -12,11 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/core/fd_type.h"
#include <opencv2/imgcodecs.hpp>
#include "fastdeploy_capi/fd_common.h"
#include "fastdeploy_capi/core/fd_common.h"
#ifdef __cplusplus
extern "C" {

View File

@@ -17,8 +17,8 @@
#include <stdint.h>
#include <stdio.h>
#include "fastdeploy_capi/enum_variables.h"
#include "fastdeploy_capi/fd_common.h"
#include "fastdeploy_capi/runtime/enum_variables.h"
#include "fastdeploy_capi/core/fd_common.h"
typedef struct FD_C_OneDimArrayUint8 {
size_t size;

View File

@@ -1,71 +0,0 @@
// Copyright (c) 2023 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
#define FD_ENUM(type) \
typedef int32_t type; \
enum
FD_ENUM(FD_C_ModelFormat){
AUTOREC, ///< Auto recognize the model format by model file name
PADDLE, ///< Model with paddlepaddle format
ONNX, ///< Model with ONNX format
RKNN, ///< Model with RKNN format
TORCHSCRIPT, ///< Model with TorchScript format
SOPHGO, ///< Model with SOPHGO format
};
FD_ENUM(FD_C_rknpu2_CpuName){
RK356X = 0, /* run on RK356X. */
RK3588 = 1, /* default,run on RK3588. */
UNDEFINED,
};
FD_ENUM(FD_C_rknpu2_CoreMask){
RKNN_NPU_CORE_AUTO = 0, //< default, run on NPU core randomly.
RKNN_NPU_CORE_0 = 1, //< run on NPU core 0.
RKNN_NPU_CORE_1 = 2, //< run on NPU core 1.
RKNN_NPU_CORE_2 = 4, //< run on NPU core 2.
RKNN_NPU_CORE_0_1 = RKNN_NPU_CORE_0 |
RKNN_NPU_CORE_1, //< run on NPU core 1 and core 2.
RKNN_NPU_CORE_0_1_2 = RKNN_NPU_CORE_0_1 |
RKNN_NPU_CORE_2, //< run on NPU core 1 and core 2.
RKNN_NPU_CORE_UNDEFINED,
};
FD_ENUM(FD_C_LitePowerMode){
LITE_POWER_HIGH = 0, ///< Use Lite Backend with high power mode
LITE_POWER_LOW = 1, ///< Use Lite Backend with low power mode
LITE_POWER_FULL = 2, ///< Use Lite Backend with full power mode
LITE_POWER_NO_BIND = 3, ///< Use Lite Backend with no bind power mode
LITE_POWER_RAND_HIGH = 4, ///< Use Lite Backend with rand high mode
LITE_POWER_RAND_LOW = 5 ///< Use Lite Backend with rand low power mode
};
FD_ENUM(FD_C_ResultType){
UNKNOWN_RESULT,
CLASSIFY,
DETECTION,
SEGMENTATION,
OCR,
MOT,
FACE_DETECTION,
FACE_ALIGNMENT,
FACE_RECOGNITION,
MATTING,
MASK,
KEYPOINT_DETECTION,
HEADPOSE,
};

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "fastdeploy_capi/types_internal.h"
#include "fastdeploy_capi/internal/types_internal.h"
namespace fastdeploy {

View File

@@ -15,7 +15,7 @@
#pragma once
#include "fastdeploy/runtime/runtime_option.h"
#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/core/fd_type.h"
#include <memory>
#ifdef ENABLE_VISION

View File

@@ -0,0 +1,71 @@
// Copyright (c) 2023 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
#define FD_ENUM(type) \
typedef int32_t type; \
enum
FD_ENUM(FD_C_ModelFormat){
FD_C_ModelFormat_AUTOREC, ///< Auto recognize the model format by model file name
FD_C_ModelFormat_PADDLE, ///< Model with paddlepaddle format
FD_C_ModelFormat_ONNX, ///< Model with ONNX format
FD_C_ModelFormat_RKNN, ///< Model with RKNN format
FD_C_ModelFormat_TORCHSCRIPT, ///< Model with TorchScript format
FD_C_ModelFormat_SOPHGO, ///< Model with SOPHGO format
};
FD_ENUM(FD_C_rknpu2_CpuName){
FD_C_ModelFormat_RK356X = 0, /* run on RK356X. */
FD_C_ModelFormat_RK3588 = 1, /* default,run on RK3588. */
FD_C_ModelFormat_UNDEFINED,
};
FD_ENUM(FD_C_rknpu2_CoreMask){
FD_C_ModelFormat_RKNN_NPU_CORE_AUTO = 0, //< default, run on NPU core randomly.
FD_C_ModelFormat_RKNN_NPU_CORE_0 = 1, //< run on NPU core 0.
FD_C_ModelFormat_RKNN_NPU_CORE_1 = 2, //< run on NPU core 1.
FD_C_ModelFormat_RKNN_NPU_CORE_2 = 4, //< run on NPU core 2.
FD_C_ModelFormat_RKNN_NPU_CORE_0_1 = FD_C_ModelFormat_RKNN_NPU_CORE_0 |
FD_C_ModelFormat_RKNN_NPU_CORE_1, //< run on NPU core 1 and core 2.
FD_C_ModelFormat_RKNN_NPU_CORE_0_1_2 = FD_C_ModelFormat_RKNN_NPU_CORE_0_1 |
FD_C_ModelFormat_RKNN_NPU_CORE_2, //< run on NPU core 1 and core 2.
FD_C_ModelFormat_RKNN_NPU_CORE_UNDEFINED,
};
FD_ENUM(FD_C_LitePowerMode){
FD_C_ModelFormat_LITE_POWER_HIGH = 0, ///< Use Lite Backend with high power mode
FD_C_ModelFormat_LITE_POWER_LOW = 1, ///< Use Lite Backend with low power mode
FD_C_ModelFormat_LITE_POWER_FULL = 2, ///< Use Lite Backend with full power mode
FD_C_ModelFormat_LITE_POWER_NO_BIND = 3, ///< Use Lite Backend with no bind power mode
FD_C_ModelFormat_LITE_POWER_RAND_HIGH = 4, ///< Use Lite Backend with rand high mode
FD_C_ModelFormat_LITE_POWER_RAND_LOW = 5 ///< Use Lite Backend with rand low power mode
};
FD_ENUM(FD_C_ResultType){
FD_C_ModelFormat_UNKNOWN_RESULT,
FD_C_ModelFormat_CLASSIFY,
FD_C_ModelFormat_DETECTION,
FD_C_ModelFormat_SEGMENTATION,
FD_C_ModelFormat_OCR,
FD_C_ModelFormat_MOT,
FD_C_ModelFormat_FACE_DETECTION,
FD_C_ModelFormat_FACE_ALIGNMENT,
FD_C_ModelFormat_FACE_RECOGNITION,
FD_C_ModelFormat_MATTING,
FD_C_ModelFormat_MASK,
FD_C_ModelFormat_KEYPOINT_DETECTION,
FD_C_ModelFormat_HEADPOSE,
};

View File

@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "fastdeploy_capi/runtime_option.h"
#include "fastdeploy_capi/runtime/runtime_option.h"
#include "fastdeploy/utils/utils.h"
#include "fastdeploy_capi/types_internal.h"
#include "fastdeploy_capi/internal/types_internal.h"
#ifdef __cplusplus
extern "C" {

View File

@@ -14,7 +14,7 @@
#pragma once
#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/core/fd_type.h"
typedef struct FD_C_RuntimeOptionWrapper FD_C_RuntimeOptionWrapper;

View File

@@ -13,7 +13,7 @@
// limitations under the License.
#pragma once
#include "fastdeploy_capi/config.h"
#include "fastdeploy_capi/core/config.h"
#ifdef ENABLE_VISION
#include "fastdeploy_capi/vision/classification/ppcls/model.h"
@@ -24,5 +24,5 @@
#include "fastdeploy_capi/vision/visualize.h"
#endif
#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/runtime_option.h"
#include "fastdeploy_capi/core/fd_type.h"
#include "fastdeploy_capi/runtime/runtime_option.h"

View File

@@ -14,7 +14,7 @@
#include "fastdeploy_capi/vision/classification/ppcls/model.h"
#include "fastdeploy_capi/types_internal.h"
#include "fastdeploy_capi/internal/types_internal.h"
#ifdef __cplusplus
extern "C" {

View File

@@ -14,9 +14,9 @@
#pragma once
#include "fastdeploy_capi/fd_common.h"
#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/runtime_option.h"
#include "fastdeploy_capi/core/fd_common.h"
#include "fastdeploy_capi/core/fd_type.h"
#include "fastdeploy_capi/runtime/runtime_option.h"
#include "fastdeploy_capi/vision/result.h"
typedef struct FD_C_PaddleClasModelWrapper FD_C_PaddleClasModelWrapper;

View File

@@ -14,7 +14,7 @@
#include "fastdeploy_capi/vision/detection/ppdet/model.h"
#include "fastdeploy_capi/types_internal.h"
#include "fastdeploy_capi/internal/types_internal.h"
#include "fastdeploy_capi/vision/visualize.h"
#ifdef __cplusplus

View File

@@ -14,9 +14,9 @@
#pragma once
#include "fastdeploy_capi/fd_common.h"
#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/runtime_option.h"
#include "fastdeploy_capi/core/fd_common.h"
#include "fastdeploy_capi/core/fd_type.h"
#include "fastdeploy_capi/runtime/runtime_option.h"
#include "fastdeploy_capi/vision/result.h"
#include "fastdeploy_capi/vision/detection/ppdet/base_define.h"

View File

@@ -28,7 +28,7 @@
#include "fastdeploy_capi/vision/ocr/ppocr/model.h"
#include "fastdeploy_capi/types_internal.h"
#include "fastdeploy_capi/internal/types_internal.h"
#include "fastdeploy_capi/vision/visualize.h"
#ifdef __cplusplus

View File

@@ -14,9 +14,9 @@
#pragma once
#include "fastdeploy_capi/fd_common.h"
#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/runtime_option.h"
#include "fastdeploy_capi/core/fd_common.h"
#include "fastdeploy_capi/core/fd_type.h"
#include "fastdeploy_capi/runtime/runtime_option.h"
#include "fastdeploy_capi/vision/result.h"
#include "fastdeploy_capi/vision/ocr/ppocr/base_define.h"

View File

@@ -15,7 +15,7 @@
#include "fastdeploy_capi/vision/result.h"
#include "fastdeploy/utils/utils.h"
#include "fastdeploy_capi/types_internal.h"
#include "fastdeploy_capi/internal/types_internal.h"
#ifdef __cplusplus
extern "C" {

View File

@@ -14,8 +14,8 @@
#pragma once
#include "fastdeploy_capi/fd_common.h"
#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/core/fd_common.h"
#include "fastdeploy_capi/core/fd_type.h"
typedef struct FD_C_ClassifyResultWrapper FD_C_ClassifyResultWrapper;
typedef struct FD_C_DetectionResultWrapper FD_C_DetectionResultWrapper;

View File

@@ -14,7 +14,7 @@
#include "fastdeploy_capi/vision/segmentation/ppseg/model.h"
#include "fastdeploy_capi/types_internal.h"
#include "fastdeploy_capi/internal/types_internal.h"
#ifdef __cplusplus
extern "C" {

View File

@@ -14,9 +14,9 @@
#pragma once
#include "fastdeploy_capi/fd_common.h"
#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/runtime_option.h"
#include "fastdeploy_capi/core/fd_common.h"
#include "fastdeploy_capi/core/fd_type.h"
#include "fastdeploy_capi/runtime/runtime_option.h"
#include "fastdeploy_capi/vision/result.h"
typedef struct FD_C_PaddleSegModelWrapper FD_C_PaddleSegModelWrapper;

View File

@@ -15,7 +15,7 @@
#include "fastdeploy_capi/vision/visualize.h"
#include "fastdeploy/vision/visualize/visualize.h"
#include "fastdeploy_capi/types_internal.h"
#include "fastdeploy_capi/internal/types_internal.h"
#ifdef __cplusplus
extern "C" {

View File

@@ -14,8 +14,8 @@
#pragma once
#include "fastdeploy_capi/fd_common.h"
#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/core/fd_common.h"
#include "fastdeploy_capi/core/fd_type.h"
#include "fastdeploy_capi/vision/result.h"
#ifdef __cplusplus

View File

@@ -66,7 +66,7 @@ typedef struct FD_C_SegmentationResult {
FD_C_ResultType type;
} FD_C_SegmentationResult;
```
关于FD_C_OneDimArrayUint8之类的表示可以参考文件c_api/fastdeploy_capi/fd_type.h。
关于FD_C_OneDimArrayUint8之类的表示可以参考文件c_api/fastdeploy_capi/core/fd_type.h。
之后需要定义两个函数用来从fastdeploy::SegmentationResult和FD_C_SegmentationResult之间进行相互转化。由于对C++的结构使用了对应的Wrapper结构进行包裹所以实际定义的是FD_C_SegmentationResultWrapper和FD_C_SegmentationResult之间的转化对应下面两个函数。
```c
@@ -83,11 +83,11 @@ FD_C_SegmentationResultWrapperToCResult(
关于各种Result在C API中的实现位置为c_api/fastdeploy_capi/vision/result.cc。
关于声明各种Wrapper的结构可以参考文件c_api/fastdeploy_capi/types_internal.h 。
关于声明各种Wrapper的结构可以参考文件c_api/fastdeploy_capi/internal/types_internal.h 。
2. 提供模型接口的C API
打开文件fastdeploy/vision/segmentation/ppseg/model.h里面定义了分割模型的C++接口即fastdeploy::vision::segmentation::PaddleSegModel类。在C中创建一个Wrapper来表示这个类为了方便后续对同一类别的模型进行快速定义和实现c_api/fastdeploy_capi/types_internal.h中定义了宏来快速创建Wrapper以及从Wrapper中取出所包裹的类的对象。例如定义创建分割类模型的Wrapper的宏为
打开文件fastdeploy/vision/segmentation/ppseg/model.h里面定义了分割模型的C++接口即fastdeploy::vision::segmentation::PaddleSegModel类。在C中创建一个Wrapper来表示这个类为了方便后续对同一类别的模型进行快速定义和实现c_api/fastdeploy_capi/internal/types_internal.h中定义了宏来快速创建Wrapper以及从Wrapper中取出所包裹的类的对象。例如定义创建分割类模型的Wrapper的宏为
```c
#define DEFINE_SEGMENTATION_MODEL_WRAPPER_STRUCT(typename, varname) typedef struct FD_C_##typename##Wrapper { \
std::unique_ptr<fastdeploy::vision::segmentation::typename> varname; \

View File

@@ -71,7 +71,7 @@ typedef struct FD_C_SegmentationResult {
} FD_C_SegmentationResult;
```
For representations such as FD_C_OneDimArrayUint8, refer to file c_api/fastdeploy_capi/fd_type.h.
For representations such as FD_C_OneDimArrayUint8, refer to file c_api/fastdeploy_capi/core/fd_type.h.
Then you need to define two functions that convert between fastdeploy::SegmentationResult and FD_C_SegmentationResult. Since a corresponding Wrapper structure in C is used for wrapping C++ structures, what is actually defined is conversion between FD_C_SegmentationResultWrapper and FD_C_SegmentationResult, corresponding to the following two functions.
@@ -90,10 +90,10 @@ There are also other API functions for creating and destroying structures that c
The implementation of various Results in C API is located at c_api/fastdeploy_capi/vision/result.cc.
For declaring various Wrapper structures, refer to file c_api/fastdeploy_capi/types_internal.h .
For declaring various Wrapper structures, refer to file c_api/fastdeploy_capi/internal/types_internal.h .
2. Provide C API for model interface
Open file fastdeploy/vision/segmentation/ppseg/model.h, which defines the C++ interface for segmentation model, i.e. fastdeploy::vision::segmentation::PaddleSegModel class. Create a Wrapper in C to represent this class. For convenience of quick definition and implementation of models of the same category in the future, c_api/fastdeploy_capi/types_internal.h defines macros to quickly create Wrapper and extract the wrapped class object from Wrapper. For example, define a macro to create a Wrapper for segmentation model as
Open file fastdeploy/vision/segmentation/ppseg/model.h, which defines the C++ interface for segmentation model, i.e. fastdeploy::vision::segmentation::PaddleSegModel class. Create a Wrapper in C to represent this class. For convenience of quick definition and implementation of models of the same category in the future, c_api/fastdeploy_capi/internal/types_internal.h defines macros to quickly create Wrapper and extract the wrapped class object from Wrapper. For example, define a macro to create a Wrapper for segmentation model as
```c
#define DEFINE_SEGMENTATION_MODEL_WRAPPER_STRUCT(typename, varname) typedef struct FD_C_##typename##Wrapper { \

View File

@@ -92,7 +92,7 @@ FD_C_PaddleClasModelWrapper* FD_C_CreatePaddleClasModelWrapper(
> * **params_file**(const char*): Parameter file path
> * **config_file**(const char*): Configuration file path, which is the deployment yaml file exported by PaddleClas.
> * **runtime_option**(FD_C_RuntimeOptionWrapper*): Backend inference configuration. None by default, which is the default configuration
> * **model_format**(FD_C_ModelFormat): Model format. Paddle format by default
> * **model_format**(FD_C_ModelFormat): Model format. FD_C_ModelFormat_PADDLE format by default
>
> **Return**
> * **fd_c_ppclas_wrapper**(FD_C_PaddleClasModelWrapper*): Pointer to manipulate PaddleClas object.

View File

@@ -38,7 +38,7 @@ void CpuInfer(const char* model_dir, const char* image_file) {
FD_C_RuntimeOptionWrapperUseCpu(option);
FD_C_PaddleClasModelWrapper* model = FD_C_CreatePaddleClasModelWrapper(
model_file, params_file, config_file, option, PADDLE);
model_file, params_file, config_file, option, FD_C_ModelFormat_PADDLE);
if (!FD_C_PaddleClasModelWrapperInitialized(model)) {
printf("Failed to initialize.\n");
@@ -86,7 +86,7 @@ void GpuInfer(const char* model_dir, const char* image_file) {
FD_C_RuntimeOptionWrapperUseGpu(option, 0);
FD_C_PaddleClasModelWrapper* model = FD_C_CreatePaddleClasModelWrapper(
model_file, params_file, config_file, option, PADDLE);
model_file, params_file, config_file, option, FD_C_ModelFormat_PADDLE);
if (!FD_C_PaddleClasModelWrapperInitialized(model)) {
printf("Failed to initialize.\n");

View File

@@ -93,7 +93,7 @@ FD_C_PPYOLOEWrapper* FD_C_CreatePPYOLOEWrapper(
> * **params_file**(const char*): Parameter file path
> * **config_file**(const char*): Configuration file path, which is the deployment yaml file exported by PaddleDetection
> * **runtime_option**(FD_C_RuntimeOptionWrapper*): Backend inference configuration. None by default, which is the default configuration
> * **model_format**(FD_C_ModelFormat): Model format. Paddle format by default
> * **model_format**(FD_C_ModelFormat): Model format. FD_C_ModelFormat_PADDLE format by default
>
> **Return**
> * **fd_c_ppyoloe_wrapper**(FD_C_PPYOLOEWrapper*): Pointer to manipulate PPYOLOE object.

View File

@@ -36,7 +36,7 @@ void CpuInfer(const char* model_dir, const char* image_file) {
FD_C_RuntimeOptionWrapperUseCpu(option);
FD_C_PPYOLOEWrapper* model = FD_C_CreatePPYOLOEWrapper(
model_file, params_file, config_file, option, PADDLE);
model_file, params_file, config_file, option, FD_C_ModelFormat_PADDLE);
if (!FD_C_PPYOLOEWrapperInitialized(model)) {
printf("Failed to initialize.\n");
@@ -84,7 +84,7 @@ void GpuInfer(const char* model_dir, const char* image_file) {
FD_C_RuntimeOptionWrapperUseGpu(option, 0);
FD_C_PPYOLOEWrapper* model = FD_C_CreatePPYOLOEWrapper(
model_file, params_file, config_file, option, PADDLE);
model_file, params_file, config_file, option, FD_C_ModelFormat_PADDLE);
if (!FD_C_PPYOLOEWrapperInitialized(model)) {
printf("Failed to initialize.\n");

View File

@@ -73,11 +73,12 @@ void CpuInfer(const char* det_model_dir, const char* cls_model_dir,
FD_C_RuntimeOptionWrapperUseCpu(rec_option);
FD_C_DBDetectorWrapper* det_model = FD_C_CreateDBDetectorWrapper(
det_model_file, det_params_file, det_option, PADDLE);
det_model_file, det_params_file, det_option, FD_C_ModelFormat_PADDLE);
FD_C_ClassifierWrapper* cls_model = FD_C_CreateClassifierWrapper(
cls_model_file, cls_params_file, cls_option, PADDLE);
cls_model_file, cls_params_file, cls_option, FD_C_ModelFormat_PADDLE);
FD_C_RecognizerWrapper* rec_model = FD_C_CreateRecognizerWrapper(
rec_model_file, rec_params_file, rec_label_file, rec_option, PADDLE);
rec_model_file, rec_params_file, rec_label_file, rec_option,
FD_C_ModelFormat_PADDLE);
FD_C_PPOCRv2Wrapper* ppocr_v2 =
FD_C_CreatePPOCRv2Wrapper(det_model, cls_model, rec_model);
@@ -167,11 +168,12 @@ void GpuInfer(const char* det_model_dir, const char* cls_model_dir,
FD_C_RuntimeOptionWrapperUseGpu(rec_option, 0);
FD_C_DBDetectorWrapper* det_model = FD_C_CreateDBDetectorWrapper(
det_model_file, det_params_file, det_option, PADDLE);
det_model_file, det_params_file, det_option, FD_C_ModelFormat_PADDLE);
FD_C_ClassifierWrapper* cls_model = FD_C_CreateClassifierWrapper(
cls_model_file, cls_params_file, cls_option, PADDLE);
cls_model_file, cls_params_file, cls_option, FD_C_ModelFormat_PADDLE);
FD_C_RecognizerWrapper* rec_model = FD_C_CreateRecognizerWrapper(
rec_model_file, rec_params_file, rec_label_file, rec_option, PADDLE);
rec_model_file, rec_params_file, rec_label_file, rec_option,
FD_C_ModelFormat_PADDLE);
FD_C_PPOCRv2Wrapper* ppocr_v2 =
FD_C_CreatePPOCRv2Wrapper(det_model, cls_model, rec_model);

View File

@@ -73,11 +73,12 @@ void CpuInfer(const char* det_model_dir, const char* cls_model_dir,
FD_C_RuntimeOptionWrapperUseCpu(rec_option);
FD_C_DBDetectorWrapper* det_model = FD_C_CreateDBDetectorWrapper(
det_model_file, det_params_file, det_option, PADDLE);
det_model_file, det_params_file, det_option, FD_C_ModelFormat_PADDLE);
FD_C_ClassifierWrapper* cls_model = FD_C_CreateClassifierWrapper(
cls_model_file, cls_params_file, cls_option, PADDLE);
cls_model_file, cls_params_file, cls_option, FD_C_ModelFormat_PADDLE);
FD_C_RecognizerWrapper* rec_model = FD_C_CreateRecognizerWrapper(
rec_model_file, rec_params_file, rec_label_file, rec_option, PADDLE);
rec_model_file, rec_params_file, rec_label_file, rec_option,
FD_C_ModelFormat_PADDLE);
FD_C_PPOCRv3Wrapper* ppocr_v3 =
FD_C_CreatePPOCRv3Wrapper(det_model, cls_model, rec_model);
@@ -167,11 +168,12 @@ void GpuInfer(const char* det_model_dir, const char* cls_model_dir,
FD_C_RuntimeOptionWrapperUseGpu(rec_option, 0);
FD_C_DBDetectorWrapper* det_model = FD_C_CreateDBDetectorWrapper(
det_model_file, det_params_file, det_option, PADDLE);
det_model_file, det_params_file, det_option, FD_C_ModelFormat_PADDLE);
FD_C_ClassifierWrapper* cls_model = FD_C_CreateClassifierWrapper(
cls_model_file, cls_params_file, cls_option, PADDLE);
cls_model_file, cls_params_file, cls_option, FD_C_ModelFormat_PADDLE);
FD_C_RecognizerWrapper* rec_model = FD_C_CreateRecognizerWrapper(
rec_model_file, rec_params_file, rec_label_file, rec_option, PADDLE);
rec_model_file, rec_params_file, rec_label_file, rec_option,
FD_C_ModelFormat_PADDLE);
FD_C_PPOCRv3Wrapper* ppocr_v3 =
FD_C_CreatePPOCRv3Wrapper(det_model, cls_model, rec_model);

View File

@@ -36,7 +36,7 @@ void CpuInfer(const char* model_dir, const char* image_file) {
FD_C_RuntimeOptionWrapperUseCpu(option);
FD_C_PaddleSegModelWrapper* model = FD_C_CreatePaddleSegModelWrapper(
model_file, params_file, config_file, option, PADDLE);
model_file, params_file, config_file, option, FD_C_ModelFormat_PADDLE);
if (!FD_C_PaddleSegModelWrapperInitialized(model)) {
printf("Failed to initialize.\n");
@@ -88,7 +88,7 @@ void GpuInfer(const char* model_dir, const char* image_file) {
FD_C_RuntimeOptionWrapperUseGpu(option, 0);
FD_C_PaddleSegModelWrapper* model = FD_C_CreatePaddleSegModelWrapper(
model_file, params_file, config_file, option, PADDLE);
model_file, params_file, config_file, option, FD_C_ModelFormat_PADDLE);
if (!FD_C_PaddleSegModelWrapperInitialized(model)) {
printf("Failed to initialize.\n");