Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
7bae6d90
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7bae6d90
编写于
9月 02, 2019
作者:
G
Guanghua Yu
提交者:
qingqing01
9月 02, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix import cocoapi (#3226)
上级
5006775a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
8 addition
and
4 deletion
+8
-4
PaddleCV/PaddleDetection/ppdet/utils/coco_eval.py
PaddleCV/PaddleDetection/ppdet/utils/coco_eval.py
+8
-4
未找到文件。
PaddleCV/PaddleDetection/ppdet/utils/coco_eval.py
浏览文件 @
7bae6d90
...
@@ -24,9 +24,6 @@ import cv2
...
@@ -24,9 +24,6 @@ import cv2
import
numpy
as
np
import
numpy
as
np
import
matplotlib
import
matplotlib
matplotlib
.
use
(
'Agg'
)
matplotlib
.
use
(
'Agg'
)
from
pycocotools.coco
import
COCO
from
pycocotools.cocoeval
import
COCOeval
import
pycocotools.mask
as
mask_util
import
logging
import
logging
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -74,6 +71,7 @@ def bbox_eval(results,
...
@@ -74,6 +71,7 @@ def bbox_eval(results,
is_bbox_normalized
=
False
):
is_bbox_normalized
=
False
):
assert
'bbox'
in
results
[
0
]
assert
'bbox'
in
results
[
0
]
assert
outfile
.
endswith
(
'.json'
)
assert
outfile
.
endswith
(
'.json'
)
from
pycocotools.coco
import
COCO
coco_gt
=
COCO
(
anno_file
)
coco_gt
=
COCO
(
anno_file
)
cat_ids
=
coco_gt
.
getCatIds
()
cat_ids
=
coco_gt
.
getCatIds
()
...
@@ -104,6 +102,7 @@ def bbox_eval(results,
...
@@ -104,6 +102,7 @@ def bbox_eval(results,
def
mask_eval
(
results
,
anno_file
,
outfile
,
resolution
,
thresh_binarize
=
0.5
):
def
mask_eval
(
results
,
anno_file
,
outfile
,
resolution
,
thresh_binarize
=
0.5
):
assert
'mask'
in
results
[
0
]
assert
'mask'
in
results
[
0
]
assert
outfile
.
endswith
(
'.json'
)
assert
outfile
.
endswith
(
'.json'
)
from
pycocotools.coco
import
COCO
coco_gt
=
COCO
(
anno_file
)
coco_gt
=
COCO
(
anno_file
)
clsid2catid
=
{
i
+
1
:
v
for
i
,
v
in
enumerate
(
coco_gt
.
getCatIds
())}
clsid2catid
=
{
i
+
1
:
v
for
i
,
v
in
enumerate
(
coco_gt
.
getCatIds
())}
...
@@ -134,6 +133,9 @@ def cocoapi_eval(jsonfile,
...
@@ -134,6 +133,9 @@ def cocoapi_eval(jsonfile,
max_dets: COCO evaluation maxDets.
max_dets: COCO evaluation maxDets.
"""
"""
assert
coco_gt
!=
None
or
anno_file
!=
None
assert
coco_gt
!=
None
or
anno_file
!=
None
from
pycocotools.coco
import
COCO
from
pycocotools.cocoeval
import
COCOeval
if
coco_gt
==
None
:
if
coco_gt
==
None
:
coco_gt
=
COCO
(
anno_file
)
coco_gt
=
COCO
(
anno_file
)
logger
.
info
(
"Start evaluate..."
)
logger
.
info
(
"Start evaluate..."
)
...
@@ -240,6 +242,7 @@ def bbox2out(results, clsid2catid, is_bbox_normalized=False):
...
@@ -240,6 +242,7 @@ def bbox2out(results, clsid2catid, is_bbox_normalized=False):
def
mask2out
(
results
,
clsid2catid
,
resolution
,
thresh_binarize
=
0.5
):
def
mask2out
(
results
,
clsid2catid
,
resolution
,
thresh_binarize
=
0.5
):
import
pycocotools.mask
as
mask_util
scale
=
(
resolution
+
2.0
)
/
resolution
scale
=
(
resolution
+
2.0
)
/
resolution
segm_res
=
[]
segm_res
=
[]
...
@@ -362,6 +365,7 @@ def get_category_info_from_anno(anno_file, with_background=True):
...
@@ -362,6 +365,7 @@ def get_category_info_from_anno(anno_file, with_background=True):
with_background (bool, default True):
with_background (bool, default True):
whether load background as class 0.
whether load background as class 0.
"""
"""
from
pycocotools.coco
import
COCO
coco
=
COCO
(
anno_file
)
coco
=
COCO
(
anno_file
)
cats
=
coco
.
loadCats
(
coco
.
getCatIds
())
cats
=
coco
.
loadCats
(
coco
.
getCatIds
())
clsid2catid
=
{
clsid2catid
=
{
...
@@ -552,4 +556,4 @@ def coco17_category_info(with_background=True):
...
@@ -552,4 +556,4 @@ def coco17_category_info(with_background=True):
if
not
with_background
:
if
not
with_background
:
clsid2catid
=
{
k
-
1
:
v
for
k
,
v
in
clsid2catid
.
items
()}
clsid2catid
=
{
k
-
1
:
v
for
k
,
v
in
clsid2catid
.
items
()}
return
clsid2catid
,
catid2name
return
clsid2catid
,
catid2name
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录