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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
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 @@
...
@@ -13,6 +13,9 @@
# limitations under the License.
# limitations under the License.
import
numpy
as
np
import
numpy
as
np
import
matplotlib
matplotlib
.
use
(
'Agg'
)
from
pycocotools.coco
import
COCO
from
pycocotools.coco
import
COCO
import
logging
import
logging
...
...
ppdet/data/tests/coco.yml
浏览文件 @
b0683058
...
@@ -23,7 +23,7 @@ TRANSFORM:
...
@@ -23,7 +23,7 @@ TRANSFORM:
-
OP
:
ResizeImage
-
OP
:
ResizeImage
TARGET_SIZE
:
800
TARGET_SIZE
:
800
MAX_SIZE
:
1333
MAX_SIZE
:
1333
-
OP
:
Rgb2Bgr
-
OP
:
Permute
TO_BGR
:
False
TO_BGR
:
False
-
OP
:
ArrangeRCNN
-
OP
:
ArrangeRCNN
BATCH_SIZE
:
1
BATCH_SIZE
:
1
...
...
ppdet/data/tests/rcnn_dataset.yml
浏览文件 @
b0683058
...
@@ -19,7 +19,7 @@ TRANSFORM:
...
@@ -19,7 +19,7 @@ TRANSFORM:
-
OP
:
ResizeImage
-
OP
:
ResizeImage
TARGET_SIZE
:
800
TARGET_SIZE
:
800
MAX_SIZE
:
1333
MAX_SIZE
:
1333
-
OP
:
Rgb2Bgr
-
OP
:
Permute
TO_BGR
:
False
TO_BGR
:
False
-
OP
:
ArrangeRCNN
-
OP
:
ArrangeRCNN
BATCH_SIZE
:
1
BATCH_SIZE
:
1
...
...
ppdet/data/tests/set_env.py
浏览文件 @
b0683058
...
@@ -3,10 +3,6 @@ import os
...
@@ -3,10 +3,6 @@ import os
import
six
import
six
import
logging
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__
))
prefix
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
#coco data for testing
#coco data for testing
...
...
ppdet/data/tests/test_loader.py
浏览文件 @
b0683058
...
@@ -51,7 +51,7 @@ class TestLoader(unittest.TestCase):
...
@@ -51,7 +51,7 @@ class TestLoader(unittest.TestCase):
def
test_load_coco_in_json
(
self
):
def
test_load_coco_in_json
(
self
):
""" test loading COCO data in json file
""" 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
):
if
not
os
.
path
.
exists
(
self
.
anno_path
):
logging
.
warn
(
'not found %s, so skip this test'
%
(
self
.
anno_path
))
logging
.
warn
(
'not found %s, so skip this test'
%
(
self
.
anno_path
))
return
return
...
@@ -71,7 +71,7 @@ class TestLoader(unittest.TestCase):
...
@@ -71,7 +71,7 @@ class TestLoader(unittest.TestCase):
return
return
samples
=
10
samples
=
10
from
data.source.loader
import
load_roidb
from
ppdet.
data.source.loader
import
load_roidb
records
,
cname2cid
=
load_roidb
(
anno_path
,
samples
)
records
,
cname2cid
=
load_roidb
(
anno_path
,
samples
)
self
.
assertEqual
(
len
(
records
),
samples
)
self
.
assertEqual
(
len
(
records
),
samples
)
self
.
assertGreater
(
len
(
cname2cid
),
0
)
self
.
assertGreater
(
len
(
cname2cid
),
0
)
...
@@ -79,7 +79,7 @@ class TestLoader(unittest.TestCase):
...
@@ -79,7 +79,7 @@ class TestLoader(unittest.TestCase):
def
test_load_voc_in_xml
(
self
):
def
test_load_voc_in_xml
(
self
):
""" test loading VOC data in xml files
""" 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
):
if
not
os
.
path
.
exists
(
self
.
anno_path1
):
logging
.
warn
(
'not found %s, so skip this test'
%
(
self
.
anno_path1
))
logging
.
warn
(
'not found %s, so skip this test'
%
(
self
.
anno_path1
))
return
return
...
@@ -98,7 +98,7 @@ class TestLoader(unittest.TestCase):
...
@@ -98,7 +98,7 @@ class TestLoader(unittest.TestCase):
return
return
samples
=
3
samples
=
3
from
loader
import
load_roidb
from
ppdet.data.source.
loader
import
load_roidb
records
,
cname2cid
=
load_roidb
(
anno_path
,
samples
)
records
,
cname2cid
=
load_roidb
(
anno_path
,
samples
)
self
.
assertEqual
(
len
(
records
),
samples
)
self
.
assertEqual
(
len
(
records
),
samples
)
self
.
assertGreater
(
len
(
cname2cid
),
0
)
self
.
assertGreater
(
len
(
cname2cid
),
0
)
...
...
ppdet/data/tests/test_operator.py
浏览文件 @
b0683058
...
@@ -3,7 +3,7 @@ import unittest
...
@@ -3,7 +3,7 @@ import unittest
import
logging
import
logging
import
numpy
as
np
import
numpy
as
np
import
set_env
import
set_env
from
data
import
transform
as
tf
import
ppdet.data.
transform
as
tf
logging
.
basicConfig
(
level
=
logging
.
INFO
)
logging
.
basicConfig
(
level
=
logging
.
INFO
)
...
@@ -47,7 +47,7 @@ class TestBase(unittest.TestCase):
...
@@ -47,7 +47,7 @@ class TestBase(unittest.TestCase):
'target_size'
:
300
,
'target_size'
:
300
,
'max_size'
:
1333
'max_size'
:
1333
}]
}]
mapper
=
tf
.
build
(
ops_conf
)
mapper
=
tf
.
build
_mapper
(
ops_conf
)
self
.
assertTrue
(
mapper
is
not
None
)
self
.
assertTrue
(
mapper
is
not
None
)
data
=
self
.
sample
.
copy
()
data
=
self
.
sample
.
copy
()
result0
=
mapper
(
data
)
result0
=
mapper
(
data
)
...
@@ -55,14 +55,14 @@ class TestBase(unittest.TestCase):
...
@@ -55,14 +55,14 @@ class TestBase(unittest.TestCase):
self
.
assertEqual
(
len
(
result0
[
'image'
].
shape
),
3
)
self
.
assertEqual
(
len
(
result0
[
'image'
].
shape
),
3
)
# RandFlipImage
# RandFlipImage
ops_conf
=
[{
'op'
:
'RandomFlipImage'
}]
ops_conf
=
[{
'op'
:
'RandomFlipImage'
}]
mapper
=
tf
.
build
(
ops_conf
)
mapper
=
tf
.
build
_mapper
(
ops_conf
)
self
.
assertTrue
(
mapper
is
not
None
)
self
.
assertTrue
(
mapper
is
not
None
)
result1
=
mapper
(
result0
)
result1
=
mapper
(
result0
)
self
.
assertEqual
(
result1
[
'image'
].
shape
,
result0
[
'image'
].
shape
)
self
.
assertEqual
(
result1
[
'image'
].
shape
,
result0
[
'image'
].
shape
)
self
.
assertEqual
(
result1
[
'gt_bbox'
].
shape
,
result0
[
'gt_bbox'
].
shape
)
self
.
assertEqual
(
result1
[
'gt_bbox'
].
shape
,
result0
[
'gt_bbox'
].
shape
)
# NormalizeImage
# NormalizeImage
ops_conf
=
[{
'op'
:
'NormalizeImage'
,
'is_channel_first'
:
False
}]
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
)
self
.
assertTrue
(
mapper
is
not
None
)
result2
=
mapper
(
result1
)
result2
=
mapper
(
result1
)
im1
=
result1
[
'image'
]
im1
=
result1
[
'image'
]
...
@@ -71,7 +71,7 @@ class TestBase(unittest.TestCase):
...
@@ -71,7 +71,7 @@ class TestBase(unittest.TestCase):
self
.
assertEqual
(
count
,
im1
.
shape
[
0
]
*
im1
.
shape
[
1
],
im1
.
shape
[
2
])
self
.
assertEqual
(
count
,
im1
.
shape
[
0
]
*
im1
.
shape
[
1
],
im1
.
shape
[
2
])
# ArrangeSample
# ArrangeSample
ops_conf
=
[{
'op'
:
'ArrangeRCNN'
}]
ops_conf
=
[{
'op'
:
'ArrangeRCNN'
}]
mapper
=
tf
.
build
(
ops_conf
)
mapper
=
tf
.
build
_mapper
(
ops_conf
)
self
.
assertTrue
(
mapper
is
not
None
)
self
.
assertTrue
(
mapper
is
not
None
)
result3
=
mapper
(
result2
)
result3
=
mapper
(
result2
)
self
.
assertEqual
(
type
(
result3
),
tuple
)
self
.
assertEqual
(
type
(
result3
),
tuple
)
...
@@ -93,7 +93,7 @@ class TestBase(unittest.TestCase):
...
@@ -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.9
,
0.0
],
[
1
,
50
,
0.3
,
1.0
,
0.5
,
2.0
,
0.0
,
1.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
)
self
.
assertTrue
(
mapper
is
not
None
)
data
=
self
.
sample
.
copy
()
data
=
self
.
sample
.
copy
()
result
=
mapper
(
data
)
result
=
mapper
(
data
)
...
@@ -111,7 +111,7 @@ class TestBase(unittest.TestCase):
...
@@ -111,7 +111,7 @@ class TestBase(unittest.TestCase):
'max_ratio'
:
1.5
,
'max_ratio'
:
1.5
,
'prob'
:
1
'prob'
:
1
}]
}]
mapper
=
tf
.
build
(
ops_conf
)
mapper
=
tf
.
build
_mapper
(
ops_conf
)
self
.
assertTrue
(
mapper
is
not
None
)
self
.
assertTrue
(
mapper
is
not
None
)
data
=
self
.
sample
.
copy
()
data
=
self
.
sample
.
copy
()
result
=
mapper
(
data
)
result
=
mapper
(
data
)
...
@@ -130,7 +130,7 @@ class TestBase(unittest.TestCase):
...
@@ -130,7 +130,7 @@ class TestBase(unittest.TestCase):
'op'
:
'RandomInterpImage'
,
'op'
:
'RandomInterpImage'
,
'target_size'
:
608
'target_size'
:
608
}]
}]
mapper
=
tf
.
build
(
ops_conf
)
mapper
=
tf
.
build
_mapper
(
ops_conf
)
self
.
assertTrue
(
mapper
is
not
None
)
self
.
assertTrue
(
mapper
is
not
None
)
data
=
self
.
sample
.
copy
()
data
=
self
.
sample
.
copy
()
result
=
mapper
(
data
)
result
=
mapper
(
data
)
...
...
ppdet/data/tests/test_reader.py
浏览文件 @
b0683058
...
@@ -7,7 +7,7 @@ import numpy as np
...
@@ -7,7 +7,7 @@ import numpy as np
import
yaml
import
yaml
import
set_env
import
set_env
from
data
import
Reader
from
ppdet.data.reader
import
Reader
class
TestReader
(
unittest
.
TestCase
):
class
TestReader
(
unittest
.
TestCase
):
...
...
ppdet/data/tests/test_roidb_source.py
浏览文件 @
b0683058
...
@@ -5,7 +5,7 @@ import sys
...
@@ -5,7 +5,7 @@ import sys
import
logging
import
logging
import
set_env
import
set_env
from
data
import
build_source
from
ppdet.data.source
import
build_source
class
TestRoiDbSource
(
unittest
.
TestCase
):
class
TestRoiDbSource
(
unittest
.
TestCase
):
...
...
ppdet/data/tests/test_transformer.py
浏览文件 @
b0683058
...
@@ -6,8 +6,8 @@ import logging
...
@@ -6,8 +6,8 @@ import logging
import
numpy
as
np
import
numpy
as
np
import
set_env
import
set_env
from
data
import
build_source
import
ppdet.data.transform
as
tf
from
data
import
transform
as
tf
from
ppdet.data.source
import
build_source
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -53,7 +53,7 @@ class TestTransformer(unittest.TestCase):
...
@@ -53,7 +53,7 @@ class TestTransformer(unittest.TestCase):
def
test_map
(
self
):
def
test_map
(
self
):
""" test transformer.map
""" test transformer.map
"""
"""
mapper
=
tf
.
build
(
self
.
ops
)
mapper
=
tf
.
build
_mapper
(
self
.
ops
)
ds
=
build_source
(
self
.
sc_config
)
ds
=
build_source
(
self
.
sc_config
)
mapped_ds
=
tf
.
map
(
ds
,
mapper
)
mapped_ds
=
tf
.
map
(
ds
,
mapper
)
ct
=
0
ct
=
0
...
@@ -66,7 +66,7 @@ class TestTransformer(unittest.TestCase):
...
@@ -66,7 +66,7 @@ class TestTransformer(unittest.TestCase):
def
test_parallel_map
(
self
):
def
test_parallel_map
(
self
):
""" test transformer.map with concurrent workers
""" test transformer.map with concurrent workers
"""
"""
mapper
=
tf
.
build
(
self
.
ops
)
mapper
=
tf
.
build
_mapper
(
self
.
ops
)
ds
=
build_source
(
self
.
sc_config
)
ds
=
build_source
(
self
.
sc_config
)
worker_conf
=
{
'WORKER_NUM'
:
2
,
'use_process'
:
True
}
worker_conf
=
{
'WORKER_NUM'
:
2
,
'use_process'
:
True
}
mapped_ds
=
tf
.
map
(
ds
,
mapper
,
worker_conf
)
mapped_ds
=
tf
.
map
(
ds
,
mapper
,
worker_conf
)
...
@@ -91,7 +91,7 @@ class TestTransformer(unittest.TestCase):
...
@@ -91,7 +91,7 @@ class TestTransformer(unittest.TestCase):
""" test batched dataset
""" test batched dataset
"""
"""
batchsize
=
2
batchsize
=
2
mapper
=
tf
.
build
(
self
.
ops
)
mapper
=
tf
.
build
_mapper
(
self
.
ops
)
ds
=
build_source
(
self
.
sc_config
)
ds
=
build_source
(
self
.
sc_config
)
mapped_ds
=
tf
.
map
(
ds
,
mapper
)
mapped_ds
=
tf
.
map
(
ds
,
mapper
)
batched_ds
=
tf
.
batch
(
mapped_ds
,
batchsize
,
True
)
batched_ds
=
tf
.
batch
(
mapped_ds
,
batchsize
,
True
)
...
...
ppdet/data/transform/__init__.py
浏览文件 @
b0683058
...
@@ -17,6 +17,7 @@ from __future__ import print_function
...
@@ -17,6 +17,7 @@ from __future__ import print_function
import
copy
import
copy
import
logging
import
logging
import
traceback
from
.transformer
import
MappedDataset
,
BatchedDataset
from
.transformer
import
MappedDataset
,
BatchedDataset
from
.post_map
import
build_post_map
from
.post_map
import
build_post_map
...
@@ -76,7 +77,10 @@ def build_mapper(ops, context=None):
...
@@ -76,7 +77,10 @@ def build_mapper(ops, context=None):
out
=
f
(
sample
,
ctx
)
out
=
f
(
sample
,
ctx
)
sample
=
out
sample
=
out
except
Exception
as
e
:
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
return
out
_mapper
.
ops
=
op_repr
_mapper
.
ops
=
op_repr
...
...
ppdet/data/transform/operators.py
浏览文件 @
b0683058
...
@@ -540,7 +540,9 @@ class CropImage(BaseOperator):
...
@@ -540,7 +540,9 @@ class CropImage(BaseOperator):
gt_class
=
sample
[
'gt_class'
]
gt_class
=
sample
[
'gt_class'
]
im_width
=
sample
[
'w'
]
im_width
=
sample
[
'w'
]
im_height
=
sample
[
'h'
]
im_height
=
sample
[
'h'
]
gt_score
=
sample
[
'gt_score'
]
gt_score
=
None
if
'gt_score'
in
sample
:
gt_score
=
sample
[
'gt_score'
]
sampled_bbox
=
[]
sampled_bbox
=
[]
gt_bbox
=
gt_bbox
.
tolist
()
gt_bbox
=
gt_bbox
.
tolist
()
for
sampler
in
self
.
batch_sampler
:
for
sampler
in
self
.
batch_sampler
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录