Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
b0683058
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b0683058
编写于
7月 25, 2019
作者:
W
walloollaw
提交者:
qingqing01
7月 25, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bug in unittests of ppdet.data.tests (#2894)
上级
cc2c52ed
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
32 addition
and
27 deletion
+32
-27
ppdet/data/source/coco_loader.py
ppdet/data/source/coco_loader.py
+3
-0
ppdet/data/tests/coco.yml
ppdet/data/tests/coco.yml
+1
-1
ppdet/data/tests/rcnn_dataset.yml
ppdet/data/tests/rcnn_dataset.yml
+1
-1
ppdet/data/tests/set_env.py
ppdet/data/tests/set_env.py
+0
-4
ppdet/data/tests/test_loader.py
ppdet/data/tests/test_loader.py
+4
-4
ppdet/data/tests/test_operator.py
ppdet/data/tests/test_operator.py
+8
-8
ppdet/data/tests/test_reader.py
ppdet/data/tests/test_reader.py
+1
-1
ppdet/data/tests/test_roidb_source.py
ppdet/data/tests/test_roidb_source.py
+1
-1
ppdet/data/tests/test_transformer.py
ppdet/data/tests/test_transformer.py
+5
-5
ppdet/data/transform/__init__.py
ppdet/data/transform/__init__.py
+5
-1
ppdet/data/transform/operators.py
ppdet/data/transform/operators.py
+3
-1
未找到文件。
ppdet/data/source/coco_loader.py
浏览文件 @
b0683058
...
...
@@ -13,6 +13,9 @@
# limitations under the License.
import
numpy
as
np
import
matplotlib
matplotlib
.
use
(
'Agg'
)
from
pycocotools.coco
import
COCO
import
logging
...
...
ppdet/data/tests/coco.yml
浏览文件 @
b0683058
...
...
@@ -23,7 +23,7 @@ TRANSFORM:
-
OP
:
ResizeImage
TARGET_SIZE
:
800
MAX_SIZE
:
1333
-
OP
:
Rgb2Bgr
-
OP
:
Permute
TO_BGR
:
False
-
OP
:
ArrangeRCNN
BATCH_SIZE
:
1
...
...
ppdet/data/tests/rcnn_dataset.yml
浏览文件 @
b0683058
...
...
@@ -19,7 +19,7 @@ TRANSFORM:
-
OP
:
ResizeImage
TARGET_SIZE
:
800
MAX_SIZE
:
1333
-
OP
:
Rgb2Bgr
-
OP
:
Permute
TO_BGR
:
False
-
OP
:
ArrangeRCNN
BATCH_SIZE
:
1
...
...
ppdet/data/tests/set_env.py
浏览文件 @
b0683058
...
...
@@ -3,10 +3,6 @@ import os
import
six
import
logging
path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'../../'
)
if
path
not
in
sys
.
path
:
sys
.
path
.
insert
(
0
,
path
)
prefix
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
#coco data for testing
...
...
ppdet/data/tests/test_loader.py
浏览文件 @
b0683058
...
...
@@ -51,7 +51,7 @@ class TestLoader(unittest.TestCase):
def
test_load_coco_in_json
(
self
):
""" test loading COCO data in json file
"""
from
data.source.coco_loader
import
load
from
ppdet.
data.source.coco_loader
import
load
if
not
os
.
path
.
exists
(
self
.
anno_path
):
logging
.
warn
(
'not found %s, so skip this test'
%
(
self
.
anno_path
))
return
...
...
@@ -71,7 +71,7 @@ class TestLoader(unittest.TestCase):
return
samples
=
10
from
data.source.loader
import
load_roidb
from
ppdet.
data.source.loader
import
load_roidb
records
,
cname2cid
=
load_roidb
(
anno_path
,
samples
)
self
.
assertEqual
(
len
(
records
),
samples
)
self
.
assertGreater
(
len
(
cname2cid
),
0
)
...
...
@@ -79,7 +79,7 @@ class TestLoader(unittest.TestCase):
def
test_load_voc_in_xml
(
self
):
""" test loading VOC data in xml files
"""
from
data.source.voc_loader
import
load
from
ppdet.
data.source.voc_loader
import
load
if
not
os
.
path
.
exists
(
self
.
anno_path1
):
logging
.
warn
(
'not found %s, so skip this test'
%
(
self
.
anno_path1
))
return
...
...
@@ -98,7 +98,7 @@ class TestLoader(unittest.TestCase):
return
samples
=
3
from
loader
import
load_roidb
from
ppdet.data.source.
loader
import
load_roidb
records
,
cname2cid
=
load_roidb
(
anno_path
,
samples
)
self
.
assertEqual
(
len
(
records
),
samples
)
self
.
assertGreater
(
len
(
cname2cid
),
0
)
...
...
ppdet/data/tests/test_operator.py
浏览文件 @
b0683058
...
...
@@ -3,7 +3,7 @@ import unittest
import
logging
import
numpy
as
np
import
set_env
from
data
import
transform
as
tf
import
ppdet.data.
transform
as
tf
logging
.
basicConfig
(
level
=
logging
.
INFO
)
...
...
@@ -47,7 +47,7 @@ class TestBase(unittest.TestCase):
'target_size'
:
300
,
'max_size'
:
1333
}]
mapper
=
tf
.
build
(
ops_conf
)
mapper
=
tf
.
build
_mapper
(
ops_conf
)
self
.
assertTrue
(
mapper
is
not
None
)
data
=
self
.
sample
.
copy
()
result0
=
mapper
(
data
)
...
...
@@ -55,14 +55,14 @@ class TestBase(unittest.TestCase):
self
.
assertEqual
(
len
(
result0
[
'image'
].
shape
),
3
)
# RandFlipImage
ops_conf
=
[{
'op'
:
'RandomFlipImage'
}]
mapper
=
tf
.
build
(
ops_conf
)
mapper
=
tf
.
build
_mapper
(
ops_conf
)
self
.
assertTrue
(
mapper
is
not
None
)
result1
=
mapper
(
result0
)
self
.
assertEqual
(
result1
[
'image'
].
shape
,
result0
[
'image'
].
shape
)
self
.
assertEqual
(
result1
[
'gt_bbox'
].
shape
,
result0
[
'gt_bbox'
].
shape
)
# NormalizeImage
ops_conf
=
[{
'op'
:
'NormalizeImage'
,
'is_channel_first'
:
False
}]
mapper
=
tf
.
build
(
ops_conf
)
mapper
=
tf
.
build
_mapper
(
ops_conf
)
self
.
assertTrue
(
mapper
is
not
None
)
result2
=
mapper
(
result1
)
im1
=
result1
[
'image'
]
...
...
@@ -71,7 +71,7 @@ class TestBase(unittest.TestCase):
self
.
assertEqual
(
count
,
im1
.
shape
[
0
]
*
im1
.
shape
[
1
],
im1
.
shape
[
2
])
# ArrangeSample
ops_conf
=
[{
'op'
:
'ArrangeRCNN'
}]
mapper
=
tf
.
build
(
ops_conf
)
mapper
=
tf
.
build
_mapper
(
ops_conf
)
self
.
assertTrue
(
mapper
is
not
None
)
result3
=
mapper
(
result2
)
self
.
assertEqual
(
type
(
result3
),
tuple
)
...
...
@@ -93,7 +93,7 @@ class TestBase(unittest.TestCase):
[
1
,
50
,
0.3
,
1.0
,
0.5
,
2.0
,
0.9
,
0.0
],
[
1
,
50
,
0.3
,
1.0
,
0.5
,
2.0
,
0.0
,
1.0
]]
}]
mapper
=
tf
.
build
(
ops_conf
)
mapper
=
tf
.
build
_mapper
(
ops_conf
)
self
.
assertTrue
(
mapper
is
not
None
)
data
=
self
.
sample
.
copy
()
result
=
mapper
(
data
)
...
...
@@ -111,7 +111,7 @@ class TestBase(unittest.TestCase):
'max_ratio'
:
1.5
,
'prob'
:
1
}]
mapper
=
tf
.
build
(
ops_conf
)
mapper
=
tf
.
build
_mapper
(
ops_conf
)
self
.
assertTrue
(
mapper
is
not
None
)
data
=
self
.
sample
.
copy
()
result
=
mapper
(
data
)
...
...
@@ -130,7 +130,7 @@ class TestBase(unittest.TestCase):
'op'
:
'RandomInterpImage'
,
'target_size'
:
608
}]
mapper
=
tf
.
build
(
ops_conf
)
mapper
=
tf
.
build
_mapper
(
ops_conf
)
self
.
assertTrue
(
mapper
is
not
None
)
data
=
self
.
sample
.
copy
()
result
=
mapper
(
data
)
...
...
ppdet/data/tests/test_reader.py
浏览文件 @
b0683058
...
...
@@ -7,7 +7,7 @@ import numpy as np
import
yaml
import
set_env
from
data
import
Reader
from
ppdet.data.reader
import
Reader
class
TestReader
(
unittest
.
TestCase
):
...
...
ppdet/data/tests/test_roidb_source.py
浏览文件 @
b0683058
...
...
@@ -5,7 +5,7 @@ import sys
import
logging
import
set_env
from
data
import
build_source
from
ppdet.data.source
import
build_source
class
TestRoiDbSource
(
unittest
.
TestCase
):
...
...
ppdet/data/tests/test_transformer.py
浏览文件 @
b0683058
...
...
@@ -6,8 +6,8 @@ import logging
import
numpy
as
np
import
set_env
from
data
import
build_source
from
data
import
transform
as
tf
import
ppdet.data.transform
as
tf
from
ppdet.data.source
import
build_source
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -53,7 +53,7 @@ class TestTransformer(unittest.TestCase):
def
test_map
(
self
):
""" test transformer.map
"""
mapper
=
tf
.
build
(
self
.
ops
)
mapper
=
tf
.
build
_mapper
(
self
.
ops
)
ds
=
build_source
(
self
.
sc_config
)
mapped_ds
=
tf
.
map
(
ds
,
mapper
)
ct
=
0
...
...
@@ -66,7 +66,7 @@ class TestTransformer(unittest.TestCase):
def
test_parallel_map
(
self
):
""" test transformer.map with concurrent workers
"""
mapper
=
tf
.
build
(
self
.
ops
)
mapper
=
tf
.
build
_mapper
(
self
.
ops
)
ds
=
build_source
(
self
.
sc_config
)
worker_conf
=
{
'WORKER_NUM'
:
2
,
'use_process'
:
True
}
mapped_ds
=
tf
.
map
(
ds
,
mapper
,
worker_conf
)
...
...
@@ -91,7 +91,7 @@ class TestTransformer(unittest.TestCase):
""" test batched dataset
"""
batchsize
=
2
mapper
=
tf
.
build
(
self
.
ops
)
mapper
=
tf
.
build
_mapper
(
self
.
ops
)
ds
=
build_source
(
self
.
sc_config
)
mapped_ds
=
tf
.
map
(
ds
,
mapper
)
batched_ds
=
tf
.
batch
(
mapped_ds
,
batchsize
,
True
)
...
...
ppdet/data/transform/__init__.py
浏览文件 @
b0683058
...
...
@@ -17,6 +17,7 @@ from __future__ import print_function
import
copy
import
logging
import
traceback
from
.transformer
import
MappedDataset
,
BatchedDataset
from
.post_map
import
build_post_map
...
...
@@ -76,7 +77,10 @@ def build_mapper(ops, context=None):
out
=
f
(
sample
,
ctx
)
sample
=
out
except
Exception
as
e
:
logger
.
warn
(
"fail to map op [{}] with error: {}"
.
format
(
f
,
e
))
stack_info
=
traceback
.
format_exc
()
logger
.
warn
(
"fail to map op [{}] with error: {} and stack:
\n
{}"
.
format
(
f
,
e
,
str
(
stack_info
)))
raise
e
return
out
_mapper
.
ops
=
op_repr
...
...
ppdet/data/transform/operators.py
浏览文件 @
b0683058
...
...
@@ -540,6 +540,8 @@ class CropImage(BaseOperator):
gt_class
=
sample
[
'gt_class'
]
im_width
=
sample
[
'w'
]
im_height
=
sample
[
'h'
]
gt_score
=
None
if
'gt_score'
in
sample
:
gt_score
=
sample
[
'gt_score'
]
sampled_bbox
=
[]
gt_bbox
=
gt_bbox
.
tolist
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录