Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
RODNet
Commits
0505a4d8
Commit
0505a4d8
authored
Nov 10, 2020
by
Yizhou Wang
Browse files
Create read_rod_results.py
parent
1bbd4784
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
0 deletions
+93
-0
rodnet/datasets/loaders/read_rod_results.py
rodnet/datasets/loaders/read_rod_results.py
+93
-0
No files found.
rodnet/datasets/loaders/read_rod_results.py
0 → 100644
View file @
0505a4d8
import
math
from
rodnet.core.object_class
import
get_class_id
def
load_rodnet_res
(
filename
,
config_dict
):
n_class
=
config_dict
[
'class_cfg'
][
'n_class'
]
classes
=
config_dict
[
'class_cfg'
][
'classes'
]
model_configs
=
config_dict
[
'model_cfg'
]
rng_grid
=
config_dict
[
'mappings'
][
'range_grid'
]
agl_grid
=
config_dict
[
'mappings'
][
'angle_grid'
]
test_configs
=
config_dict
[
'test_cfg'
]
with
open
(
filename
,
'r'
)
as
df
:
data
=
df
.
readlines
()
if
len
(
data
)
==
0
:
return
None
,
0
n_frame
=
int
(
float
(
data
[
-
1
].
rstrip
().
split
()[
0
]))
+
1
dts
=
{(
i
,
j
):
[]
for
i
in
range
(
n_frame
)
for
j
in
range
(
n_class
)}
for
id
,
line
in
enumerate
(
data
):
if
line
is
not
None
:
line
=
line
.
rstrip
().
split
()
frameid
,
class_str
,
ridx
,
aidx
,
conf
=
line
frameid
=
int
(
frameid
)
classid
=
get_class_id
(
class_str
,
classes
)
ridx
=
int
(
ridx
)
aidx
=
int
(
aidx
)
conf
=
float
(
conf
)
if
conf
>
1
:
conf
=
1
if
conf
<
model_configs
[
'ols_thres'
]:
continue
rng
=
rng_grid
[
ridx
]
agl
=
agl_grid
[
aidx
]
if
rng
>
test_configs
[
'rr_max'
]
or
rng
<
test_configs
[
'rr_min'
]:
continue
if
agl
>
math
.
radians
(
test_configs
[
'ra_max'
])
or
agl
<
math
.
radians
(
test_configs
[
'ra_min'
]):
continue
obj_dict
=
dict
(
id
=
id
+
1
,
frame_id
=
frameid
,
range
=
rng
,
angle
=
agl
,
range_id
=
ridx
,
angle_id
=
aidx
,
class_id
=
classid
,
score
=
conf
)
dts
[
frameid
,
classid
].
append
(
obj_dict
)
return
dts
,
n_frame
def
load_vgg_res
(
filename
,
config_dict
):
n_class
=
config_dict
[
'class_cfg'
][
'n_class'
]
classes
=
config_dict
[
'class_cfg'
][
'classes'
]
model_configs
=
config_dict
[
'model_cfg'
]
rng_grid
=
config_dict
[
'mappings'
][
'range_grid'
]
agl_grid
=
config_dict
[
'mappings'
][
'angle_grid'
]
test_configs
=
config_dict
[
'test_cfg'
]
with
open
(
filename
,
'r'
)
as
df
:
data
=
df
.
readlines
()
n_frame
=
int
(
float
(
data
[
-
1
].
rstrip
().
split
()[
0
]))
+
1
dts
=
{(
i
,
j
):
[]
for
i
in
range
(
n_frame
)
for
j
in
range
(
n_class
)}
for
id
,
line
in
enumerate
(
data
):
if
line
is
not
None
:
line
=
line
.
rstrip
().
split
()
frameid
,
ridx
,
aidx
,
classid
,
conf
=
line
frameid
=
int
(
frameid
)
classid
=
int
(
classid
)
ridx
=
int
(
ridx
)
aidx
=
int
(
aidx
)
conf
=
float
(
conf
)
if
conf
>
1
:
conf
=
1
# if conf < 0.5:
# continue
rng
=
rng_grid
[
ridx
]
agl
=
agl_grid
[
aidx
]
if
rng
>
test_configs
[
'rr_max'
]
or
rng
<
test_configs
[
'rr_min'
]:
continue
if
agl
>
math
.
radians
(
test_configs
[
'ra_max'
])
or
agl
<
math
.
radians
(
test_configs
[
'ra_min'
]):
continue
obj_dict
=
{
'id'
:
id
+
1
,
'frameid'
:
frameid
,
'range'
:
rng
,
'angle'
:
agl
,
'ridx'
:
ridx
,
'aidx'
:
aidx
,
'classid'
:
classid
,
'score'
:
conf
}
dts
[
frameid
,
classid
].
append
(
obj_dict
)
return
dts
,
n_frame
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment