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
780e0178
Commit
780e0178
authored
6 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Roughed in more bounding box generator
parent
97d6b156
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
model_server/base/roiset.py
+14
-5
14 additions, 5 deletions
model_server/base/roiset.py
tests/base/test_roiset.py
+8
-0
8 additions, 0 deletions
tests/base/test_roiset.py
with
22 additions
and
5 deletions
model_server/base/roiset.py
+
14
−
5
View file @
780e0178
import
itertools
from
math
import
sqrt
,
floor
from
pathlib
import
Path
from
typing
import
List
,
Union
from
typing
import
Dict
,
List
,
Union
from
typing_extensions
import
Self
from
uuid
import
uuid4
...
...
@@ -386,12 +386,17 @@ class RoiSet(object):
@staticmethod
def
from_bounding_boxes
(
acc_raw
:
GenericImageDataAccessor
,
bbox_df
:
pd
.
DataFrame
,
bbox_yxhw
:
List
[
Dict
],
bbox_zi
:
Union
[
List
[
int
],
int
]
=
None
,
params
:
RoiSetMetaParams
=
RoiSetMetaParams
()
):
bbox_df
=
pd
.
DataFrame
(
bbox_yxhw
)
if
list
(
bbox_df
.
columns
.
str
.
upper
().
sort_values
())
!=
[
'
H
'
,
'
W
'
,
'
X
'
,
'
Y
'
]:
raise
BoundingBoxError
(
f
'
Expecting bounding box coordinates Y, X, H, and W, not
{
list
(
bbox_df
.
columns
)
}
'
)
# deproject if zi is not provided
if
'
zi
'
not
in
bbox_df
.
columns
:
# deproject if zi is not specified
if
bbox_zi
is
None
:
def
_slice_zmax
(
r
):
acc_raw
.
crop_hw
(
r
.
y0
,
...
...
@@ -400,7 +405,8 @@ class RoiSet(object):
r
.
x1
-
r
.
x0
)
zmax
=
acc_raw
.
data
.
argmax
(
axis
=
3
,
keepdims
=
True
)[:,
:,
0
,
0
].
astype
(
'
uint16
'
)
bbox_df
[
'
zi
'
]
=
0
else
:
bbox_df
[
'
zi
'
]
=
bbox_zi
df
=
df_insert_slices
(
bbox_df
,
...
...
@@ -1010,6 +1016,9 @@ class RoiSet(object):
class
Error
(
Exception
):
pass
class
BoundingBoxError
(
Error
):
pass
class
DeserializeRoiSet
(
Error
):
pass
...
...
This diff is collapsed.
Click to expand it.
tests/base/test_roiset.py
+
8
−
0
View file @
780e0178
...
...
@@ -626,6 +626,14 @@ class TestRoiSetSerialization(unittest.TestCase):
self
.
assertTrue
(
ref_roiset
.
contains_segmentation
)
self
.
assertTrue
(
ref_roiset
.
contains_segmentation
)
class
TestRoiSetObjectDetection
(
unittest
.
TestCase
):
def
setUp
(
self
)
->
None
:
# set up test raw data and segmentation from file
self
.
stack
=
generate_file_accessor
(
data
[
'
multichannel_zstack_raw
'
][
'
path
'
])
self
.
stack_ch_pa
=
self
.
stack
.
get_mono
(
params
[
'
segmentation_channel
'
])
self
.
seg_mask_3d
=
generate_file_accessor
(
data
[
'
multichannel_zstack_mask3d
'
][
'
path
'
])
def
test_create_roiset_from_bounding_boxes
(
self
):
from
skimage.measure
import
label
,
regionprops
,
regionprops_table
...
...
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