Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
221cb0332
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
221cb0332
Commits
db09b899
Commit
db09b899
authored
3 years ago
by
maijianqiang
Browse files
Options
Downloads
Patches
Plain Diff
postprocess bug
parent
fafd17ed
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
official/cv/faster_rcnn/eval.py
+1
-1
1 addition, 1 deletion
official/cv/faster_rcnn/eval.py
official/cv/faster_rcnn/postprocess.py
+4
-1
4 additions, 1 deletion
official/cv/faster_rcnn/postprocess.py
official/cv/faster_rcnn/src/util.py
+14
-6
14 additions, 6 deletions
official/cv/faster_rcnn/src/util.py
with
19 additions
and
8 deletions
official/cv/faster_rcnn/eval.py
+
1
−
1
View file @
db09b899
...
...
@@ -110,7 +110,7 @@ def fasterrcnn_eval(dataset_path, ckpt_path, anno_path):
eval_types
=
[
"
bbox
"
]
result_files
=
results2json
(
dataset_coco
,
outputs
,
"
./results.pkl
"
)
coco_eval
(
config
,
result_files
,
eval_types
,
dataset_coco
,
single_result
=
Fals
e
)
coco_eval
(
config
,
result_files
,
eval_types
,
dataset_coco
,
single_result
=
True
,
plot_detect_result
=
Tru
e
)
def
modelarts_pre_process
():
...
...
This diff is collapsed.
Click to expand it.
official/cv/faster_rcnn/postprocess.py
+
4
−
1
View file @
db09b899
...
...
@@ -25,9 +25,11 @@ from src.model_utils.moxing_adapter import moxing_wrapper
dst_width
=
config
.
img_width
dst_height
=
config
.
img_height
def
modelarts_pre_process
():
pass
@moxing_wrapper
(
pre_process
=
modelarts_pre_process
)
def
get_eval_result
(
ann_file
,
result_path
):
"""
get evaluation result of faster rcnn
"""
...
...
@@ -68,7 +70,8 @@ def get_eval_result(ann_file, result_path):
eval_types
=
[
"
bbox
"
]
result_files
=
results2json
(
dataset_coco
,
outputs
,
"
./results.pkl
"
)
coco_eval
(
result_files
,
eval_types
,
dataset_coco
,
single_result
=
False
)
coco_eval
(
config
,
result_files
,
eval_types
,
dataset_coco
,
single_result
=
False
)
if
__name__
==
'
__main__
'
:
get_eval_result
(
config
.
ann_file
,
config
.
result_path
)
This diff is collapsed.
Click to expand it.
official/cv/faster_rcnn/src/util.py
+
14
−
6
View file @
db09b899
...
...
@@ -23,7 +23,6 @@ import mmcv
from
pycocotools.coco
import
COCO
from
src.detecteval
import
DetectEval
_init_value
=
np
.
array
(
0.0
)
summary_init
=
{
'
Precision/mAP
'
:
_init_value
,
...
...
@@ -52,7 +51,8 @@ def write_list_to_csv(file_path, data_to_write, append=False):
writer
.
writerow
(
data_to_write
)
def
coco_eval
(
config
,
result_files
,
result_types
,
coco
,
max_dets
=
(
100
,
300
,
1000
),
single_result
=
False
):
def
coco_eval
(
config
,
result_files
,
result_types
,
coco
,
max_dets
=
(
100
,
300
,
1000
),
single_result
=
False
,
plot_detect_result
=
False
):
"""
coco eval for fasterrcnn
"""
anns
=
json
.
load
(
open
(
result_files
[
'
bbox
'
]))
if
not
anns
:
...
...
@@ -119,9 +119,12 @@ def coco_eval(config, result_files, result_types, coco, max_dets=(100, 300, 1000
print
(
"
summary_metrics:
"
)
print
(
summary_metrics
)
res
=
calcuate_pr_rc_f1
(
config
,
coco
,
coco_dets
,
tgt_ids
,
iou_type
)
if
plot_detect_result
:
res
=
calcuate_pr_rc_f1
(
config
,
coco
,
coco_dets
,
tgt_ids
,
iou_type
)
return
res
if
plot_detect_result
:
return
res
return
summary_metrics
def
calcuate_pr_rc_f1
(
config
,
coco
,
coco_dets
,
tgt_ids
,
iou_type
):
...
...
@@ -193,7 +196,8 @@ def xyxy2xywh(bbox):
_bbox
[
1
],
_bbox
[
2
]
-
_bbox
[
0
]
+
1
,
_bbox
[
3
]
-
_bbox
[
1
]
+
1
,
]
]
def
bbox2result_1image
(
bboxes
,
labels
,
num_classes
):
"""
Convert detection results to a list of numpy arrays.
...
...
@@ -212,11 +216,12 @@ def bbox2result_1image(bboxes, labels, num_classes):
result
=
[
bboxes
[
labels
==
i
,
:]
for
i
in
range
(
num_classes
-
1
)]
return
result
def
proposal2json
(
dataset
,
results
):
"""
convert proposal to json mode
"""
img_ids
=
dataset
.
getImgIds
()
json_results
=
[]
dataset_len
=
dataset
.
get_dataset_size
()
*
2
dataset_len
=
dataset
.
get_dataset_size
()
*
2
for
idx
in
range
(
dataset_len
):
img_id
=
img_ids
[
idx
]
bboxes
=
results
[
idx
]
...
...
@@ -229,6 +234,7 @@ def proposal2json(dataset, results):
json_results
.
append
(
data
)
return
json_results
def
det2json
(
dataset
,
results
):
"""
convert det to json mode
"""
cat_ids
=
dataset
.
getCatIds
()
...
...
@@ -250,6 +256,7 @@ def det2json(dataset, results):
json_results
.
append
(
data
)
return
json_results
def
segm2json
(
dataset
,
results
):
"""
convert segm to json mode
"""
bbox_json_results
=
[]
...
...
@@ -284,6 +291,7 @@ def segm2json(dataset, results):
segm_json_results
.
append
(
data
)
return
bbox_json_results
,
segm_json_results
def
results2json
(
dataset
,
results
,
out_file
):
"""
convert result convert to json mode
"""
result_files
=
dict
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment