Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
24c266cc
S
Serving
项目概览
PaddlePaddle
/
Serving
1 年多 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
24c266cc
编写于
9月 30, 2020
作者:
B
BohaoWu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Zelda!
Provide preprocess operatore for images.
上级
50f1bbfd
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
33 addition
and
47 deletion
+33
-47
core/CMakeLists.txt
core/CMakeLists.txt
+1
-0
core/preprocess/hwvideoframe/CMakeLists.txt
core/preprocess/hwvideoframe/CMakeLists.txt
+16
-21
core/preprocess/hwvideoframe/cuda/CMakeLists.txt
core/preprocess/hwvideoframe/cuda/CMakeLists.txt
+1
-5
core/preprocess/hwvideoframe/cuda/resize.cu
core/preprocess/hwvideoframe/cuda/resize.cu
+4
-4
core/preprocess/hwvideoframe/include/sub.h
core/preprocess/hwvideoframe/include/sub.h
+2
-2
core/preprocess/hwvideoframe/lib/libpython2.7.so
core/preprocess/hwvideoframe/lib/libpython2.7.so
+0
-0
core/preprocess/hwvideoframe/src/image_io.cpp
core/preprocess/hwvideoframe/src/image_io.cpp
+1
-1
core/preprocess/hwvideoframe/src/resize.cpp
core/preprocess/hwvideoframe/src/resize.cpp
+2
-3
core/preprocess/hwvideoframe/src/resize_by_factor.cpp
core/preprocess/hwvideoframe/src/resize_by_factor.cpp
+2
-2
core/preprocess/hwvideoframe/src/rgb_swap.cpp
core/preprocess/hwvideoframe/src/rgb_swap.cpp
+1
-1
core/preprocess/hwvideoframe/src/utlis.cpp
core/preprocess/hwvideoframe/src/utlis.cpp
+1
-1
python/paddle_serving_app/reader/__init__.py
python/paddle_serving_app/reader/__init__.py
+0
-1
python/setup.py.app.in
python/setup.py.app.in
+2
-6
未找到文件。
core/CMakeLists.txt
浏览文件 @
24c266cc
...
...
@@ -25,6 +25,7 @@ endif()
if
(
APP
)
add_subdirectory
(
configure
)
add_subdirectory
(
preprocess
)
endif
()
...
...
core/preprocess/hwvideoframe/CMakeLists.txt
浏览文件 @
24c266cc
cmake_minimum_required
(
VERSION 3.2
)
project
(
hw-frame-extract
)
# SET(CUDA_VERSION 10.1)
project
(
gpupreprocess
)
include
(
cuda
)
include
(
configure
)
#gcc version
#GCC('gcc482')
#CUDA("10.1")
set
(
global_cflags_str
"-g -pipe -W -Wall -fPIC"
)
set
(
CMAKE_C_FLAGS
${
global_cflags_str
}
)
#C flags
set
(
CMAKE_C_FLAGS
" -g -pipe -W -Wall -fPIC"
)
#C++ flags.
set
(
global_cxxflags_str
"-g -pipe -W -Wall -fPIC -std=c++11"
)
set
(
CMAKE_CXX_FLAGS
${
global_cxxflags_str
}
)
set
(
CMAKE_CXX_FLAGS
" -g -pipe -W -Wall -fPIC -std=c++11"
)
add_subdirectory
(
cuda
)
add_subdirectory
(
pybind11
)
set
(
EXTRA_LIBS
${
EXTRA_LIBS
}
gpu
)
set
(
PYTHON_SO
"
${
CMAKE_SOURCE_DIR
}
/core/preprocess/hwvideoframe/lib/libpython2.7.so"
)
set
(
EXTRA_LIBS
${
EXTRA_LIBS
}
gpu
)
file
(
GLOB SOURCE_FILES pybind/*.cpp src/*.cpp
)
message
(
${
CMAKE_CURRENT_SOURCE_DIR
}
)
include_directories
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include"
)
include_directories
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/pybind11/include"
)
include_directories
(
"/opt/compiler/cuda-10.1/include"
)
include_directories
(
"/home/work/wubohao/baidu/third-party/python/include/python2.7"
)
include_directories
(
"./include"
)
include_directories
(
${
CUDA_INCLUDE_DIRS
}
)
include_directories
(
${
PYTHON_INCLUDE_DIR
}
)
file
(
GLOB SOURCE_FILES src/*.cpp pybind11/*.cpp
)
link_directories
(
"-L/opt/compiler/cuda-10.1/lib64 -lcudart -lnppidei_static -lnppial_static -lnpps_static -lnppc_static -lculibos"
)
# link_directories("/home/work/wubohao/baidu/third-party/python/lib")
link_directories
(
"-L
${
CUDA_TOOLKIT_ROOT_DIR
}
/lib64 -lcudart -lnppidei_static -lnppial_static -lnpps_static -lnppc_static -lculibos"
)
link_directories
(
${
PYTHON_SO
}
)
#.so
add_library
(
gpupreprocess SHARED
${
SOURCE_FILES
}
)
target_link_libraries
(
gpupreprocess
${
EXTRA_LIBS
}
)
target_link_libraries
(
gpupreprocess
${
EXTRA_LIBS
}
)
target_link_libraries
(
gpupreprocess
${
CUDA_LIBRARIES
}
)
core/preprocess/hwvideoframe/cuda/CMakeLists.txt
浏览文件 @
24c266cc
...
...
@@ -5,7 +5,6 @@ SET(CUDA_TARGET_INCLUDE ${CUDA_TOOLKIT_ROOT_DIR}-${CUDA_VERSION}/targets/${CMAKE
file
(
GLOB_RECURSE CURRENT_HEADERS *.h *.hpp *.cuh
)
file
(
GLOB CURRENT_SOURCES *.cpp *.cu
)
file
(
GLOB CUDA_LIBS /opt/compiler/cuda-10.1/lib64/*.so
)
source_group
(
"Include"
FILES
${
CURRENT_HEADERS
}
)
source_group
(
"Source"
FILES
${
CURRENT_SOURCES
}
)
...
...
@@ -13,10 +12,7 @@ source_group("Source" FILES ${CURRENT_SOURCES})
set
(
CMAKE_CUDA_FLAGS
"-ccbin /opt/compiler/gcc-4.8.2/bin -Xcompiler -fPIC --std=c++11"
)
set
(
CUDA_NVCC_FLAGS
"-L/opt/compiler/gcc-4.8.2/bin -Xcompiler -fPIC --std=c++11"
)
include_directories
(
"/opt/compiler/cuda-10.1/include"
)
include_directories
(
${
CUDA_INCLUDE_DIRS
}
)
#cuda_add_library(gpu SHARED ${CURRENT_HEADERS} ${CURRENT_SOURCES})
cuda_add_library
(
gpu SHARED
${
CURRENT_HEADERS
}
${
CURRENT_SOURCES
}
)
target_link_libraries
(
gpu
${
CUDA_LIBS
}
)
# import libgpupreprocess as pp
core/preprocess/hwvideoframe/cuda/resize.cu
浏览文件 @
24c266cc
...
...
@@ -34,8 +34,8 @@ __global__ void resizeCudaKernel(const float* input,
if
(
inputChannels
==
1
)
{
// grayscale image
// TODO(Zelda): support grayscale
}
else
if
(
inputChannels
==
3
)
{
// RGB image
double
scale_x
=
static_cast
<
double
>
inputWidth
/
outputWidth
;
double
scale_y
=
static_cast
<
double
>
inputHeight
/
outputHeight
;
double
scale_x
=
static_cast
<
double
>
(
inputWidth
/
outputWidth
)
;
double
scale_y
=
static_cast
<
double
>
(
inputHeight
/
outputHeight
)
;
int
xmax
=
outputWidth
;
...
...
@@ -144,8 +144,8 @@ __global__ void resizeCudaKernel_fixpt(const float* input,
if
(
inputChannels
==
1
)
{
// grayscale image
// TODO(Zelda): support grayscale
}
else
if
(
inputChannels
==
3
)
{
// RGB image
double
scale_x
=
static_cast
<
double
>
inputWidth
/
outputWidth
;
double
scale_y
=
static_cast
<
double
>
inputHeight
/
outputHeight
;
double
scale_x
=
static_cast
<
double
>
(
inputWidth
/
outputWidth
)
;
double
scale_y
=
static_cast
<
double
>
(
inputHeight
/
outputHeight
)
;
int
xmax
=
outputWidth
;
...
...
core/preprocess/hwvideoframe/include/sub.h
浏览文件 @
24c266cc
...
...
@@ -23,8 +23,8 @@
// subtract by some float numbers
class
Sub
{
public:
explicit
Sub
(
float
subtractor
)
{}
explicit
Sub
(
const
std
::
vector
<
float
>
&
subtractors
)
{}
explicit
Sub
(
float
subtractor
)
;
explicit
Sub
(
const
std
::
vector
<
float
>
&
subtractors
)
;
std
::
shared_ptr
<
OpContext
>
operator
()(
std
::
shared_ptr
<
OpContext
>
input
);
private:
...
...
core/preprocess/hwvideoframe/lib/libpython2.7.so
0 → 100644
浏览文件 @
24c266cc
core/preprocess/hwvideoframe/src/image_io.cpp
浏览文件 @
24c266cc
...
...
@@ -45,7 +45,7 @@ pybind11::array_t<float> Gpubuffer2Image::operator()(
std
::
shared_ptr
<
OpContext
>
input
)
{
auto
result
=
pybind11
::
array_t
<
float
>
({
input
->
nppi_size
().
height
,
input
->
nppi_size
().
width
,
static_cast
<
int
>
CHANNEL_SIZE
});
static_cast
<
int
>
(
CHANNEL_SIZE
)
});
pybind11
::
buffer_info
buf
=
result
.
request
();
auto
ret
=
cudaMemcpy
(
static_cast
<
float
*>
(
buf
.
ptr
),
input
->
p_frame
(),
...
...
core/preprocess/hwvideoframe/src/resize.cpp
浏览文件 @
24c266cc
...
...
@@ -34,9 +34,8 @@ std::shared_ptr<OpContext> Resize::operator()(
if
(
round
(
percent
*
im_max_size
)
>
_max_size
)
{
percent
=
static_cast
<
float
>
(
_max_size
)
/
static_cast
<
float
>
(
im_max_size
);
}
resized_width
=
tatic_cast
<
int
>
(
round
(
input
->
nppi_size
().
width
*
percent
));
resized_height
=
tatic_cast
<
int
>
(
round
(
input
->
nppi_size
().
height
*
percent
));
resized_width
=
static_cast
<
int
>
(
round
(
input
->
nppi_size
().
width
*
percent
));
resized_height
=
static_cast
<
int
>
(
round
(
input
->
nppi_size
().
height
*
percent
));
}
auto
output
=
std
::
make_shared
<
OpContext
>
(
resized_height
,
resized_width
);
auto
ret
=
resize_linear
(
input
->
p_frame
(),
...
...
core/preprocess/hwvideoframe/src/resize_by_factor.cpp
浏览文件 @
24c266cc
...
...
@@ -49,8 +49,8 @@ std::shared_ptr<OpContext> ResizeByFactor::operator()(
}
else
{
resized_width
=
(
floor
(
resized_width
/
32
)
-
1
)
*
_factor
;
}
if
(
tatic_cast
<
int
>
(
resized_width
)
<=
0
||
tatic_cast
<
int
>
(
resized_height
)
<=
0
)
{
if
(
s
tatic_cast
<
int
>
(
resized_width
)
<=
0
||
s
tatic_cast
<
int
>
(
resized_height
)
<=
0
)
{
return
NULL
;
}
auto
output
=
std
::
make_shared
<
OpContext
>
(
resized_height
,
resized_width
);
...
...
core/preprocess/hwvideoframe/src/rgb_swap.cpp
浏览文件 @
24c266cc
...
...
@@ -15,7 +15,7 @@
#include <npp.h>
#include "core/preprocess/hwvideoframe/include/utils.h"
#include "core/preprocess/hwvideoframe/
src
/rgb_swap.h"
#include "core/preprocess/hwvideoframe/
include
/rgb_swap.h"
const
int
SwapChannel
::
_ORDER
[
CHANNEL_SIZE
]
=
{
2
,
1
,
0
};
...
...
core/preprocess/hwvideoframe/src/utlis.cpp
浏览文件 @
24c266cc
...
...
@@ -16,7 +16,7 @@
#include <sstream>
#include <stdexcept>
#include "core/preprocess/hwvideoframe/
src
/utils.h"
#include "core/preprocess/hwvideoframe/
include
/utils.h"
void
verify_npp_ret
(
const
std
::
string
&
function_name
,
NppStatus
ret
)
{
if
(
ret
!=
NPP_SUCCESS
)
{
...
...
python/paddle_serving_app/reader/__init__.py
浏览文件 @
24c266cc
...
...
@@ -11,7 +11,6 @@
# 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
.audio_reader
import
AudioFeatureOp
from
.chinese_bert_reader
import
ChineseBertReader
from
.image_reader
import
ImageReader
,
File2Image
,
URL2Image
,
Sequential
,
Normalize
,
Base64ToImage
from
.image_reader
import
CenterCrop
,
Resize
,
Transpose
,
Div
,
RGB2BGR
,
BGR2RGB
,
ResizeByFactor
...
...
python/setup.py.app.in
浏览文件 @
24c266cc
...
...
@@ -40,11 +40,8 @@ max_version, mid_version, min_version = python_version()
if '${PACK}' == 'ON':
copy_lib()
os.system('cp ../core/preprocess/nvdec-extractframe/libhwextract.so ./')
os.system('mv ./libhwextract.so ./paddle_serving_app/reader/hwextract.so')
os.system('cp ../core/preprocess/hwvideoframe/libgpupreprocess.so ./paddle_serving_app/reader')
os.system('mkdir ./paddle_serving_app/reader/lib')
os.system('cp ../core/preprocess/nvdec-extractframe/cuda/libhwgpu.so ./paddle_serving_app/reader/lib')
os.system('cp ../core/preprocess/hwvideoframe/cuda/libgpu.so ./paddle_serving_app/reader/lib')
os.system('export LD_LIBRARY_PATH="./paddle_serving_app/reader/lib"')
...
...
@@ -61,8 +58,7 @@ packages=['paddle_serving_app',
'paddle_serving_app.reader.pddet',
'paddle_serving_app.reader.lib']
package_data={'paddle_serving_app': ['reader/*.so']}
# 'paddle_serving_app.reader': ['lib/*.so']}
package_data={}
package_dir={'paddle_serving_app':
'${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_app',
'paddle_serving_app.proto':
...
...
@@ -110,4 +106,4 @@ setup(
'Topic :: Software Development :: Libraries :: Python Modules',
],
license='Apache 2.0',
keywords=('paddle-serving serving-client deployment industrial easy-to-use'))
\ No newline at end of file
keywords=('paddle-serving serving-client deployment industrial easy-to-use'))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录