Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SVLT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ALMF
SVLT
Commits
88cd7cae
Commit
88cd7cae
authored
6 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Implemented bounding box intersection metric
parent
f7037423
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
model_server/base/roiset.py
+13
-0
13 additions, 0 deletions
model_server/base/roiset.py
tests/base/test_roiset.py
+2
-0
2 additions, 0 deletions
tests/base/test_roiset.py
with
15 additions
and
0 deletions
model_server/base/roiset.py
+
13
−
0
View file @
88cd7cae
...
...
@@ -128,6 +128,8 @@ def filter_df_overlap_bbox(df1: pd.DataFrame, df2: pd.DataFrame = None) -> pd.Da
:param df1: DataFrame with potentially overlapping bounding boxes
:param df2: (optional) second DataFrame
:return DataFrame describing subset of overlapping ROIs
bbox_overlaps_with: index of ROI that overlaps
bbox_intersec: pixel area of intersecting region
"""
def
_compare
(
r0
,
r1
):
...
...
@@ -136,14 +138,21 @@ def filter_df_overlap_bbox(df1: pd.DataFrame, df2: pd.DataFrame = None) -> pd.Da
olz
=
(
r0
.
zi
==
r1
.
zi
)
return
olx
and
oly
and
olz
def
_intersec
(
r0
,
r1
):
return
(
r0
.
x1
-
r1
.
x0
)
*
(
r0
.
y1
-
r1
.
y0
)
first
=
[]
second
=
[]
intersec
=
[]
if
df2
is
not
None
:
for
pair
in
itertools
.
product
(
df1
.
index
,
df2
.
index
):
if
_compare
(
df1
.
iloc
[
pair
[
0
]],
df2
.
iloc
[
pair
[
1
]]):
first
.
append
(
pair
[
0
])
second
.
append
(
pair
[
1
])
intersec
.
append
(
_intersec
(
df1
.
iloc
[
pair
[
0
]],
df2
.
iloc
[
pair
[
1
]])
)
else
:
for
pair
in
itertools
.
combinations
(
df1
.
index
,
2
):
if
_compare
(
df1
.
iloc
[
pair
[
0
]],
df1
.
iloc
[
pair
[
1
]]):
...
...
@@ -151,9 +160,13 @@ def filter_df_overlap_bbox(df1: pd.DataFrame, df2: pd.DataFrame = None) -> pd.Da
second
.
append
(
pair
[
1
])
first
.
append
(
pair
[
1
])
second
.
append
(
pair
[
0
])
isc
=
_intersec
(
df1
.
iloc
[
pair
[
0
]],
df1
.
iloc
[
pair
[
1
]])
intersec
.
append
(
isc
)
intersec
.
append
(
isc
)
sdf
=
df1
.
iloc
[
first
]
sdf
.
loc
[:,
'
bbox_overlaps_with
'
]
=
second
sdf
.
loc
[:,
'
bbox_intersec
'
]
=
intersec
return
sdf
# TODO: option to quantify overlap e.g. IOU
...
...
This diff is collapsed.
Click to expand it.
tests/base/test_roiset.py
+
2
−
0
View file @
88cd7cae
...
...
@@ -644,6 +644,7 @@ class TestRoiSetPolygons(BaseTestRoiSetMonoProducts, unittest.TestCase):
self
.
assertEqual
(
len
(
res
),
4
)
self
.
assertTrue
((
res
.
loc
[
0
,
'
bbox_overlaps_with
'
]
==
[
1
]).
all
())
self
.
assertTrue
((
res
.
loc
[
1
,
'
bbox_overlaps_with
'
]
==
[
0
,
2
]).
all
())
self
.
assertTrue
((
res
.
bbox_intersec
==
2
).
all
())
return
res
# TODO: test overloaded condition comparing two DFs
...
...
@@ -665,6 +666,7 @@ class TestRoiSetPolygons(BaseTestRoiSetMonoProducts, unittest.TestCase):
res
=
filter_df_overlap_bbox
(
df1
,
df2
)
self
.
assertTrue
((
res
.
loc
[
1
,
'
bbox_overlaps_with
'
]
==
[
0
]).
all
())
self
.
assertEqual
(
len
(
res
),
1
)
self
.
assertTrue
((
res
.
bbox_intersec
==
2
).
all
())
def
test_overlap_seg
(
self
):
df
=
pd
.
DataFrame
({
...
...
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