Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Swin-Transformer-Object-Detection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wanggh
Swin-Transformer-Object-Detection
Commits
3cb1a70d
Unverified
Commit
3cb1a70d
authored
4 years ago
by
Haian Huang(深度眸)
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[Feature]: Support automaticaly gathering metrics to execl and fix total_epochs (#4693)
parent
1085e3c3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.dev_scripts/gather_benchmark_metric.py
+62
-1
62 additions, 1 deletion
.dev_scripts/gather_benchmark_metric.py
with
62 additions
and
1 deletion
.dev_scripts/gather_benchmark_metric.py
+
62
−
1
View file @
3cb1a70d
...
...
@@ -5,6 +5,16 @@ import os.path as osp
import
mmcv
from
gather_models
import
get_final_results
try
:
import
xlrd
except
ImportError
:
xlrd
=
None
try
:
import
xlutils
from
xlutils.copy
import
copy
except
ImportError
:
xlutils
=
None
def
parse_args
():
parser
=
argparse
.
ArgumentParser
(
...
...
@@ -19,6 +29,10 @@ def parse_args():
'
--out
'
,
type
=
str
,
help
=
'
output path of gathered metrics to be stored
'
)
parser
.
add_argument
(
'
--not-show
'
,
action
=
'
store_true
'
,
help
=
'
not show metrics
'
)
parser
.
add_argument
(
'
--excel
'
,
type
=
str
,
help
=
'
input path of excel to be recorded
'
)
parser
.
add_argument
(
'
--ncol
'
,
type
=
int
,
help
=
'
Number of column to be modified or appended
'
)
args
=
parser
.
parse_args
()
return
args
...
...
@@ -27,6 +41,26 @@ def parse_args():
if
__name__
==
'
__main__
'
:
args
=
parse_args
()
if
args
.
excel
:
assert
args
.
ncol
,
'
Please specify
"
--excel
"
and
"
--ncol
"
'
\
'
at the same time
'
if
xlrd
is
None
:
raise
RuntimeError
(
'
xlrd is not installed,
'
'
Please use “pip install xlrd==1.2.0” to install
'
)
if
xlutils
is
None
:
raise
RuntimeError
(
'
xlutils is not installed,
'
'
Please use “pip install xlutils==2.0.0” to install
'
)
readbook
=
xlrd
.
open_workbook
(
args
.
excel
)
sheet
=
readbook
.
sheet_by_name
(
'
Sheet1
'
)
sheet_info
=
{}
total_nrows
=
sheet
.
nrows
for
i
in
range
(
3
,
sheet
.
nrows
):
sheet_info
[
sheet
.
row_values
(
i
)[
0
]]
=
i
xlrw
=
copy
(
readbook
)
table
=
xlrw
.
get_sheet
(
0
)
root_path
=
args
.
root
metrics_out
=
args
.
out
benchmark_json_path
=
args
.
benchmark_json
...
...
@@ -40,7 +74,7 @@ if __name__ == '__main__':
if
osp
.
exists
(
result_path
):
# 1 read config
cfg
=
mmcv
.
Config
.
fromfile
(
config
)
total_epochs
=
cfg
.
total
_epochs
total_epochs
=
cfg
.
runner
.
max
_epochs
final_results
=
cfg
.
evaluation
.
metric
if
not
isinstance
(
final_results
,
list
):
final_results
=
[
final_results
]
...
...
@@ -64,7 +98,30 @@ if __name__ == '__main__':
if
model_performance
is
None
:
print
(
f
'
log file error:
{
log_json_path
}
'
)
continue
for
performance
in
model_performance
:
if
performance
in
[
'
AR@1000
'
,
'
bbox_mAP
'
,
'
segm_mAP
'
]:
metric
=
round
(
model_performance
[
performance
]
*
100
,
1
)
model_performance
[
performance
]
=
metric
result_dict
[
config
]
=
model_performance
# update and append excel content
if
args
.
excel
:
if
'
AR@1000
'
in
model_performance
:
metrics
=
f
'
{
model_performance
[
"
AR@1000
"
]
}
(AR@1000)
'
elif
'
segm_mAP
'
in
model_performance
:
metrics
=
f
'
{
model_performance
[
"
bbox_mAP
"
]
}
/
'
\
f
'
{
model_performance
[
"
segm_mAP
"
]
}
'
else
:
metrics
=
f
'
{
model_performance
[
"
bbox_mAP
"
]
}
'
row_num
=
sheet_info
.
get
(
config
,
None
)
if
row_num
:
table
.
write
(
row_num
,
args
.
ncol
,
metrics
)
else
:
table
.
write
(
total_nrows
,
0
,
config
)
table
.
write
(
total_nrows
,
args
.
ncol
,
metrics
)
total_nrows
+=
1
else
:
print
(
f
'
{
config
}
not exist:
{
ckpt_path
}
'
)
else
:
...
...
@@ -79,3 +136,7 @@ if __name__ == '__main__':
for
config_name
,
metrics
in
result_dict
.
items
():
print
(
config_name
,
metrics
)
print
(
'
===================================
'
)
if
args
.
excel
:
filename
,
sufflx
=
osp
.
splitext
(
args
.
excel
)
xlrw
.
save
(
f
'
{
filename
}
_o
{
sufflx
}
'
)
print
(
f
'
>>> Output
{
filename
}
_o
{
sufflx
}
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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