diff --git a/deploy/paddleocr-go/README.md b/deploy/paddleocr-go/README.md index 1332c3c0b31c7b6943dfe616deeffc447d6be218..a82aca574ee2fe2c17286cd92c9840ec5b1c9b6e 100644 --- a/deploy/paddleocr-go/README.md +++ b/deploy/paddleocr-go/README.md @@ -150,12 +150,13 @@ make install ```shell # 创建c++推理库文件夹 mkdir -p ~/paddle_inference -export PADDLE_ROOT=`$HOME/paddle_inference` +export PADDLE_INFER=`$HOME/paddle_inference` # 执行编译 +export PADDLE_ROOT=`pwd` mkdir build cd build -cmake -DFLUID_INFERENCE_INSTALL_DIR=$PADDLE_ROOT \ +cmake -DFLUID_INFERENCE_INSTALL_DIR=$PADDLE_INFER \ -DWITH_CONTRIB=OFF \ -DCMAKE_BUILD_TYPE=Release \ -DWITH_PYTHON=OFF \ @@ -178,17 +179,23 @@ build/fluid_inference_c_install_dir └── version.txt ``` -其中`paddle`就是Paddle库的C语言预测API,`version.txt`中包含当前预测库的版本信息。 +其中`paddle`就是Paddle库的C语言预测API,`version.txt`中包含当前预测库的版本信息。最后,将C推理库的动态库和静态库配置到环境变量。 +```shell +echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PADDLE_ROOT/build/fluid_inference_c_install_dir/paddle/lib" >> ~/.bashrc +echo "export LIBRARY_PATH=$LIBRARY_PATH:$PADDLE_ROOT/build/fluid_inference_c_install_dir/paddle/lib" >> ~/.bashrc + +souce ~/.bashrc +``` ## 2. paddleocr-go预测库 ### 2.1 安装paddleocr-go -直接执行安装命令 +确保C推理库已配置到环境变量,然后直接执行安装命令 ```shell -go get github.com/PaddlePaddle/PaddleOCR/deploy/paddleocr-go +go get -u github.com/PaddlePaddle/PaddleOCR/deploy/paddleocr-go ``` ### 2.2 相关使用API @@ -265,15 +272,10 @@ git clone https://github.com/PaddlePaddle/PaddleOCR cd PaddleOCR/deploy/paddleocr-go ``` -- 准备paddle_c环境 - -```shell -cp -r ~/paddle/build/fluid_inference_c_install_dir/* paddle_c/ -``` - - 编译demo ```shell +# 确保C动态库路径已在环境变量中 go build demo.go ``` diff --git a/deploy/paddleocr-go/paddle/common.go b/deploy/paddleocr-go/paddle/common.go index 4bcd443cf247f54943e53f7795aa649b1896242f..ffff739f3043319e245ed900b360dbcd3cb49ddc 100644 --- a/deploy/paddleocr-go/paddle/common.go +++ b/deploy/paddleocr-go/paddle/common.go @@ -1,9 +1,8 @@ package paddle // #cgo CFLAGS: -I../paddle_c/paddle/include -// #cgo LDFLAGS: -L${SRCDIR}/../paddle_c/paddle/lib -Wl,-rpath=\$ORIGIN/paddle_c/paddle/lib -lpaddle_fluid_c +// #cgo LDFLAGS: -lpaddle_fluid_c // #include -// #include "paddle_c_api.h" import "C" import "fmt" diff --git a/deploy/paddleocr-go/paddle/config.go b/deploy/paddleocr-go/paddle/config.go index 3201923936dca57aa809a058a76e34d00790057d..70f6d33b9092693ce9d8c087ff1f2467d5316be1 100644 --- a/deploy/paddleocr-go/paddle/config.go +++ b/deploy/paddleocr-go/paddle/config.go @@ -1,7 +1,5 @@ package paddle -// #cgo CFLAGS: -I../paddle_c/paddle/include -// #cgo LDFLAGS: -L${SRCDIR}/../paddle_c/paddle/lib -Wl,-rpath,$ORIGIN/paddle_c/paddle/lib -lpaddle_fluid_c // #include // #include // #include diff --git a/deploy/paddleocr-go/paddle/predictor.go b/deploy/paddleocr-go/paddle/predictor.go index f6cba7bc7756aab7f68cb5f84be1fae659c5f61c..9a69c9ee477ad09c202616cdf1f008df66568365 100644 --- a/deploy/paddleocr-go/paddle/predictor.go +++ b/deploy/paddleocr-go/paddle/predictor.go @@ -1,7 +1,5 @@ package paddle -// #cgo CFLAGS: -I../paddle_c/paddle/include -// #cgo LDFLAGS: -L${SRCDIR}/../paddle_c/paddle/lib -Wl,-rpath,$ORIGIN/paddle_c/paddle/lib -lpaddle_fluid_c // #include // #include "paddle_c_api.h" import "C" diff --git a/deploy/paddleocr-go/paddle/tensor.go b/deploy/paddleocr-go/paddle/tensor.go index cf462dcd886861f23ab504569662456d86db9107..5c889e5c1680e373b3c42baf724c20b3a81cfdac 100644 --- a/deploy/paddleocr-go/paddle/tensor.go +++ b/deploy/paddleocr-go/paddle/tensor.go @@ -1,7 +1,5 @@ package paddle -// #cgo CFLAGS: -I../paddle_c/paddle/include -// #cgo LDFLAGS: -L${SRCDIR}/../paddle_c/paddle/lib -Wl,-rpath,$ORIGIN/paddle_c/paddle/lib -lpaddle_fluid_c // #include // #include // #include diff --git a/deploy/paddleocr-go/paddle_c/README.md b/deploy/paddleocr-go/paddle_c/README.md deleted file mode 100644 index e3565d6fbd54d3d3f39f6b75eac100f666d42f00..0000000000000000000000000000000000000000 --- a/deploy/paddleocr-go/paddle_c/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Paddle C预测库目录 - -## 编译安装 -使用cmake编译paddle,并打开-DON_INFER=ON,在编译目录下得到paddle_inference_c_install_dir,将该目录下的所有文件复制到本目录下。 - -详细编译步骤请参见[README.md](../README.md) 或者官方文档指导 https://www.paddlepaddle.org.cn/documentation/docs/zh/advanced_guide/inference_deployment/inference/build_and_install_lib_cn.html#id12 \ No newline at end of file