Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
model_server
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
Christopher Randolph Rhodes
model_server
Commits
a2c2fa51
Commit
a2c2fa51
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Corrected translational error in mask file output
parent
f8295af0
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
extensions/chaeo/products.py
+16
-4
16 additions, 4 deletions
extensions/chaeo/products.py
extensions/chaeo/tests/test_zstack.py
+13
-1
13 additions, 1 deletion
extensions/chaeo/tests/test_zstack.py
with
29 additions
and
5 deletions
extensions/chaeo/products.py
+
16
−
4
View file @
a2c2fa51
...
...
@@ -57,6 +57,7 @@ def _write_patch_to_file(where, fname, data):
def
export_patch_masks_from_zstack
(
where
:
Path
,
stack
:
GenericImageDataAccessor
,
zmask_meta
:
list
,
pad_to
:
int
=
256
,
prefix
=
'
mask
'
,
...
...
@@ -64,15 +65,26 @@ def export_patch_masks_from_zstack(
exported
=
[]
for
mi
in
zmask_meta
:
obj
=
mi
[
'
info
'
]
mask
=
np
.
expand_dims
(
mi
[
'
mask
'
],
(
2
,
3
))
sl
=
mi
[
'
slice
'
]
rbb
=
mi
[
'
relative_bounding_box
'
]
x0
=
rbb
[
'
x0
'
]
y0
=
rbb
[
'
y0
'
]
x1
=
rbb
[
'
x1
'
]
y1
=
rbb
[
'
y1
'
]
sp_sl
=
np
.
s_
[
y0
:
y1
,
x0
:
x1
,
:,
:]
h
,
w
=
stack
.
data
[
sl
].
shape
[
0
:
2
]
patch
=
np
.
zeros
((
h
,
w
,
1
,
1
),
dtype
=
'
uint8
'
)
patch
[
sp_sl
][:,
:,
0
,
0
]
=
mi
[
'
mask
'
]
*
255
if
pad_to
:
mask
=
pad
(
mask
,
pad_to
)
patch
=
pad
(
patch
,
pad_to
)
ext
=
'
png
'
fname
=
f
'
{
prefix
}
-la
{
obj
.
label
:
04
d
}
-zi
{
obj
.
zi
:
04
d
}
.
{
ext
}
'
mask8bit
=
255
*
mask
.
astype
(
'
uint8
'
)
_write_patch_to_file
(
where
,
fname
,
mask8bit
)
_write_patch_to_file
(
where
,
fname
,
patch
)
exported
.
append
(
fname
)
return
exported
...
...
This diff is collapsed.
Click to expand it.
extensions/chaeo/tests/test_zstack.py
+
13
−
1
View file @
a2c2fa51
...
...
@@ -5,7 +5,7 @@ import numpy as np
from
conf.testing
import
output_path
from
extensions.chaeo.conf.testing
import
multichannel_zstack
,
pixel_classifier
,
pipeline_params
from
extensions.chaeo.products
import
export_patches_from_zstack
,
export_multichannel_patches_from_zstack
from
extensions.chaeo.products
import
export_patches_from_zstack
,
export_multichannel_patches_from_zstack
,
export_patch_masks_from_zstack
from
extensions.chaeo.zmask
import
build_zmask_from_object_mask
from
model_server.accessors
import
generate_file_accessor
,
InMemoryDataAccessor
,
write_accessor_data_to_file
from
extensions.ilastik.models
import
IlastikObjectClassifierModel
,
IlastikPixelClassifierModel
...
...
@@ -164,4 +164,16 @@ class TestZStackDerivedDataProducts(unittest.TestCase):
contour_channel
=
1
,
overlay_gain
=
(
0.1
,
1.0
,
1.0
)
)
self
.
assertGreaterEqual
(
len
(
files
),
1
)
def
test_make_binary_masks_from_zmask
(
self
):
zmask
,
meta
=
self
.
test_zmask_makes_correct_boxes
(
filters
=
{
'
area
'
:
(
1e3
,
1e4
)},
expand_box_by
=
(
128
,
2
)
)
files
=
export_patch_masks_from_zstack
(
output_path
/
'
2d_mask_patches
'
,
InMemoryDataAccessor
(
self
.
stack
.
data
),
meta
,
)
self
.
assertGreaterEqual
(
len
(
files
),
1
)
\ No newline at end of file
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