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
f7a56191
Commit
f7a56191
authored
11 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Added height, width fields for convenience
parent
1c543e96
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
+3
-1
3 additions, 1 deletion
model_server/base/roiset.py
tests/test_roiset.py
+8
-13
8 additions, 13 deletions
tests/test_roiset.py
with
11 additions
and
14 deletions
model_server/base/roiset.py
+
3
−
1
View file @
f7a56191
...
...
@@ -178,6 +178,8 @@ class RoiSet(object):
# compute expanded bounding boxes
h
,
w
,
c
,
nz
=
acc_raw
.
shape
df
[
'
h
'
]
=
df
[
'
y1
'
]
-
df
[
'
y0
'
]
df
[
'
w
'
]
=
df
[
'
x1
'
]
-
df
[
'
x0
'
]
ebxy
,
ebz
=
expand_box_by
df
[
'
ebb_y0
'
]
=
(
df
.
y0
-
ebxy
).
apply
(
lambda
x
:
max
(
x
,
0
))
df
[
'
ebb_y1
'
]
=
(
df
.
y1
+
ebxy
).
apply
(
lambda
x
:
min
(
x
,
h
))
...
...
@@ -563,7 +565,7 @@ class RoiSet(object):
# export dataframe and patch masks
record
[
'
dataframe
'
]
=
self
.
export_dataframe
(
where
/
'
dataframe
'
/
(
prefix
+
'
.csv
'
))
self
.
export_patch_masks
(
where
/
'
patch_masks
'
,
prefix
=
prefix
,
pad_to
=
None
)
self
.
export_patch_masks
(
where
/
'
tight_
patch_masks
'
,
prefix
=
prefix
,
pad_to
=
None
,
expanded
=
False
)
for
k
in
params
.
dict
().
keys
():
subdir
=
where
/
k
...
...
This diff is collapsed.
Click to expand it.
tests/test_roiset.py
+
8
−
13
View file @
f7a56191
...
...
@@ -45,7 +45,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase):
for
roi
in
roiset
.
get_df
().
itertuples
():
self
.
assertEqual
(
roi
.
binary_mask
.
dtype
,
'
bool
'
)
sh
=
roi
.
binary_mask
.
shape
self
.
assertEqual
(
sh
,
(
roi
.
y1
-
roi
.
y0
,
roi
.
x1
-
roi
.
x0
))
self
.
assertEqual
(
sh
,
(
roi
.
h
,
roi
.
w
))
self
.
assertGreaterEqual
(
sh
[
0
]
*
sh
[
1
],
roi
.
area
)
def
test_roi_zmask
(
self
,
**
kwargs
):
...
...
@@ -87,7 +87,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase):
for
roi
in
roiset
:
ma
=
roi
.
binary_mask
self
.
assertEqual
(
ma
.
dtype
,
'
bool
'
)
self
.
assertEqual
(
ma
.
shape
,
(
roi
.
y1
-
roi
.
y0
,
roi
.
x1
-
roi
.
x0
))
self
.
assertEqual
(
ma
.
shape
,
(
roi
.
h
,
roi
.
w
))
def
test_rel_slices_are_valid
(
self
):
roiset
=
self
.
_make_roi_set
()
...
...
@@ -130,9 +130,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase):
roi_q
=
df
.
loc
[
df
.
label
==
la
,
:]
self
.
assertEqual
(
len
(
roi_q
),
1
)
roi
=
roi_q
.
iloc
[
0
]
h
=
int
(
roi
.
y1
-
roi
.
y0
)
w
=
int
(
roi
.
x1
-
roi
.
x0
)
self
.
assertEqual
((
h
,
w
),
acc
.
hw
)
self
.
assertEqual
((
roi
.
h
,
roi
.
w
),
acc
.
hw
)
def
test_make_expanded_3d_patches
(
self
):
roiset
=
self
.
_make_roi_set
()
...
...
@@ -218,8 +216,8 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase):
h
,
w
,
nc
,
nz
=
roi
.
patch_mask
.
shape
self
.
assertEqual
(
nc
,
1
)
self
.
assertEqual
(
nz
,
1
)
self
.
assertEqual
(
h
,
roi
.
y1
-
roi
.
y0
)
self
.
assertEqual
(
w
,
roi
.
x1
-
roi
.
x0
)
self
.
assertEqual
(
h
,
roi
.
h
)
self
.
assertEqual
(
w
,
roi
.
w
)
class
TestRoiSetMultichannelProducts
(
BaseTestRoiSetMonoProducts
,
unittest
.
TestCase
):
...
...
@@ -379,25 +377,22 @@ class TestRoiSetFromZmask(unittest.TestCase):
output_path
/
'
roiset_from_3d
'
,
roiset_test_data
[
'
pipeline_params
'
][
'
segmentation_channel
'
],
'
ref
'
,
params
=
RoiSetExportParams
(
patch_masks
=
{
'
pad_to
'
:
256
},
dataframe
=
True
)
params
=
RoiSetExportParams
()
)
where_df
=
output_path
/
'
roiset_from_3d
'
/
'
dataframe
'
/
'
ref.csv
'
self
.
assertTrue
(
where_df
.
exists
())
df_test
=
pd
.
read_csv
(
where_df
)
# check that patches are correct size
where_patch_masks
=
output_path
/
'
roiset_from_3d
'
/
'
patch_masks
'
where_patch_masks
=
output_path
/
'
roiset_from_3d
'
/
'
tight_
patch_masks
'
for
pmf
in
where_patch_masks
.
iterdir
():
self
.
assertTrue
(
pmf
.
suffix
.
upper
()
==
'
.PNG
'
)
la
=
int
(
re
.
search
(
r
'
la([\d]+)
'
,
str
(
pmf
)).
group
(
1
))
roi_q
=
df_test
.
loc
[
df_test
.
label
==
la
,
:]
self
.
assertEqual
(
len
(
roi_q
),
1
)
roi
=
roi_q
.
iloc
[
0
]
h
=
int
(
roi
.
y1
-
roi
.
y0
)
w
=
int
(
roi
.
x1
-
roi
.
x0
)
m_acc
=
generate_file_accessor
(
pmf
)
self
.
assertEqual
((
h
,
w
),
m_acc
.
hw
)
self
.
assertEqual
((
roi
.
h
,
roi
.
w
),
m_acc
.
hw
)
# df_test = pd.read_csv(where_df)
...
...
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