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
83259e77
Commit
83259e77
authored
8 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Implemented logic to find overlapping bounding boxes
parent
dc1b5e08
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
+33
-1
33 additions, 1 deletion
model_server/base/roiset.py
tests/base/test_roiset.py
+19
-1
19 additions, 1 deletion
tests/base/test_roiset.py
with
52 additions
and
2 deletions
model_server/base/roiset.py
+
33
−
1
View file @
83259e77
from
itertools
import
combinations
from
math
import
sqrt
,
floor
from
pathlib
import
Path
import
re
from
typing
import
List
,
Union
from
uuid
import
uuid4
...
...
@@ -108,6 +108,26 @@ def _focus_metrics():
'
moment
'
:
lambda
x
:
moment
(
x
.
flatten
(),
moment
=
2
),
}
# TODO: get overlapping bounding boxes
def
_filter_overlap_bbox
(
df
:
pd
.
DataFrame
)
->
pd
.
DataFrame
:
def
_compare
(
r0
,
r1
):
olx
=
(
r0
.
x0
<
r1
.
x1
)
and
(
r0
.
x1
>
r1
.
x0
)
oly
=
(
r0
.
y0
<
r1
.
y1
)
and
(
r0
.
y1
>
r1
.
y0
)
olz
=
(
r0
.
zi
==
r1
.
zi
)
return
olx
and
oly
and
olz
first
=
[]
second
=
[]
for
pair
in
combinations
(
df
.
index
,
2
):
if
_compare
(
df
.
iloc
[
pair
[
0
]],
df
.
iloc
[
pair
[
1
]]):
first
.
append
(
pair
[
0
])
second
.
append
(
pair
[
1
])
sdf
=
df
.
iloc
[
first
]
sdf
[
'
overlaps_with
'
]
=
second
return
sdf
def
_safe_add
(
a
,
g
,
b
):
assert
a
.
dtype
==
b
.
dtype
...
...
@@ -178,6 +198,10 @@ class RoiSet(object):
"""
return
RoiSet
(
acc_raw
,
_get_label_ids
(
acc_seg
,
allow_3d
=
allow_3d
,
connect_3d
=
connect_3d
),
params
)
# TODO: generate overlapping RoiSet from multiple masks
# call e.g. static adder
@staticmethod
def
make_df
(
acc_raw
,
acc_obj_ids
,
expand_box_by
)
->
pd
.
DataFrame
:
"""
...
...
@@ -258,6 +282,14 @@ class RoiSet(object):
)
return
df
# TODO: get overlapping segments
def
get_overlap_seg
(
self
)
->
pd
.
DataFrame
:
df_overlap_bbox
=
self
.
get_overlap_bbox
()
# TODO: test if overlaps exist
@staticmethod
def
filter_df
(
df
:
pd
.
DataFrame
,
filters
:
RoiFilter
=
None
)
->
pd
.
DataFrame
:
query_str
=
'
label > 0
'
# always true
...
...
This diff is collapsed.
Click to expand it.
tests/base/test_roiset.py
+
19
−
1
View file @
83259e77
...
...
@@ -7,7 +7,7 @@ from pathlib import Path
import
pandas
as
pd
from
model_server.base.roiset
import
RoiSetExportParams
,
RoiSetMetaParams
from
model_server.base.roiset
import
_filter_overlap_bbox
,
RoiSetExportParams
,
RoiSetMetaParams
from
model_server.base.roiset
import
RoiSet
from
model_server.base.accessors
import
generate_file_accessor
,
InMemoryDataAccessor
,
write_accessor_data_to_file
,
PatchStack
from
model_server.base.models
import
DummyInstanceSegmentationModel
...
...
@@ -17,6 +17,24 @@ data = conf.meta['image_files']
output_path
=
conf
.
meta
[
'
output_path
'
]
params
=
conf
.
meta
[
'
roiset
'
]
class
TestOverlapLogic
(
unittest
.
TestCase
):
def
test_overlap_bbox
(
self
):
df
=
pd
.
DataFrame
({
'
x0
'
:
[
0
,
1
,
3
,
1
,
1
],
'
x1
'
:
[
2
,
3
,
4
,
3
,
3
],
'
y0
'
:
[
0
,
0
,
0
,
1
,
0
],
'
y1
'
:
[
1
,
1
,
1
,
2
,
1
],
'
zi
'
:
[
0
,
0
,
0
,
0
,
1
],
})
res
=
_filter_overlap_bbox
(
df
)
print
(
res
)
self
.
assertEqual
(
len
(
res
),
1
)
self
.
assertTrue
((
res
.
loc
[
0
,
'
overlaps_with
'
]
==
1
).
all
())
class
BaseTestRoiSetMonoProducts
(
object
):
def
setUp
(
self
)
->
None
:
...
...
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