Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleX
提交
cc6405b9
P
PaddleX
项目概览
PaddlePaddle
/
PaddleX
通知
136
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
43
列表
看板
标记
里程碑
合并请求
5
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleX
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
43
Issue
43
列表
看板
标记
里程碑
合并请求
5
合并请求
5
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cc6405b9
编写于
5月 11, 2020
作者:
C
Channingss
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify segment
上级
ec3f1065
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
12 deletion
+18
-12
deploy/cpp/scripts/build.sh
deploy/cpp/scripts/build.sh
+1
-1
paddlex/cv/transforms/det_transforms.py
paddlex/cv/transforms/det_transforms.py
+16
-10
paddlex/cv/transforms/seg_transforms.py
paddlex/cv/transforms/seg_transforms.py
+1
-1
未找到文件。
deploy/cpp/scripts/build.sh
浏览文件 @
cc6405b9
...
...
@@ -10,7 +10,7 @@ TENSORRT_DIR=/path/to/TensorRT/
PADDLE_DIR
=
/path/to/fluid_inference/
# Paddle 的预测库是否使用静态库来编译
# 使用TensorRT时,Paddle的预测库通常为动态库
WITH_STATIC_LIB
=
O
N
WITH_STATIC_LIB
=
O
FF
# CUDA 的 lib 路径
CUDA_LIB
=
/path/to/cuda/lib/
# CUDNN 的 lib 路径
...
...
paddlex/cv/transforms/det_transforms.py
浏览文件 @
cc6405b9
...
...
@@ -193,11 +193,16 @@ class ResizeByShort:
class
Padding
:
"""将图像的长和宽padding至coarsest_stride的倍数。如输入图像为[300, 640],
"""
1.
将图像的长和宽padding至coarsest_stride的倍数。如输入图像为[300, 640],
`coarest_stride`为32,则由于300不为32的倍数,因此在图像最右和最下使用0值
进行padding,最终输出图像为[320, 640]。
2.或者,将图像的长和宽padding到target_size指定的shape,如输入的图像为[300,640],
a. `target_size` = 960,在图像最右和最下使用0值进行padding,最终输出
图像为[960, 960]。
b. `target_size` = [640, 960],在图像最右和最下使用0值进行padding,最终
输出图像为[640, 960]。
1. 如果coarsest_stride为1则直接返回。
1. 如果coarsest_stride为1
,target_size为None
则直接返回。
2. 获取图像的高H、宽W。
3. 计算填充后图像的高H_new、宽W_new。
4. 构建大小为(H_new, W_new, 3)像素值为0的np.ndarray,
...
...
@@ -205,7 +210,7 @@ class Padding:
Args:
coarsest_stride (int): 填充后的图像长、宽为该参数的倍数,默认为1。
target_size (int|list): 填充后的图像长、宽,默认为None。
target_size (int|list): 填充后的图像长、宽,默认为None
,coarset_stride优先级更高
。
"""
def
__init__
(
self
,
coarsest_stride
=
1
,
target_size
=
None
):
...
...
@@ -227,7 +232,7 @@ class Padding:
Raises:
TypeError: 形参数据类型不满足需求。
ValueError: 数据长度不匹配。
ValueError: coarsest_stride,target_size需有且只有一个被指定
,coarset_stride优先级更高
。
ValueError: coarsest_stride,target_size需有且只有一个被指定。
ValueError: target_size小于原图的大小。
"""
...
...
@@ -243,17 +248,18 @@ class Padding:
if
len
(
im
.
shape
)
!=
3
:
raise
ValueError
(
'Padding: image is not 3-dimensional.'
)
im_h
,
im_w
,
im_c
=
im
.
shape
[:]
if
self
.
coarsest_stride
>
1
:
padding_im_h
=
int
(
np
.
ceil
(
im_h
/
self
.
coarsest_stride
)
*
self
.
coarsest_stride
)
padding_im_w
=
int
(
np
.
ceil
(
im_w
/
self
.
coarsest_stride
)
*
self
.
coarsest_stride
)
elif
isinstance
(
self
.
target_size
,
int
):
if
isinstance
(
self
.
target_size
,
int
):
padding_im_h
=
self
.
target_size
padding_im_w
=
self
.
target_size
elif
isinstance
(
self
.
target_size
,
list
):
padding_im_w
=
self
.
target_size
[
0
]
padding_im_h
=
self
.
target_size
[
1
]
elif
self
.
coarsest_stride
>
1
:
padding_im_h
=
int
(
np
.
ceil
(
im_h
/
self
.
coarsest_stride
)
*
self
.
coarsest_stride
)
padding_im_w
=
int
(
np
.
ceil
(
im_w
/
self
.
coarsest_stride
)
*
self
.
coarsest_stride
)
else
:
raise
ValueError
(
"coarsest_stridei(>1) or target_size(list|int) need setting in Padding transform"
...
...
paddlex/cv/transforms/seg_transforms.py
浏览文件 @
cc6405b9
...
...
@@ -353,7 +353,7 @@ class ResizeByShort:
raise
TypeError
(
"ResizeByShort: image type is not numpy."
)
if
len
(
im
.
shape
)
!=
3
:
raise
ValueError
(
'ResizeByShort: image is not 3-dimensional.'
)
im_info
[
'shape_before_resize'
]
=
im
.
shape
[:
2
]
im_info
.
append
((
'resize'
,
im
.
shape
[:
2
]))
im_short_size
=
min
(
im
.
shape
[
0
],
im
.
shape
[
1
])
im_long_size
=
max
(
im
.
shape
[
0
],
im
.
shape
[
1
])
scale
=
float
(
self
.
short_size
)
/
im_short_size
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录