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
b5d80b38
Commit
b5d80b38
authored
4 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
IlastikPixelClassifierModel can optionally rescale pxmap output to range of its input
parent
39c75c95
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/extensions/ilastik/models.py
+10
-2
10 additions, 2 deletions
model_server/extensions/ilastik/models.py
tests/test_ilastik/test_ilastik.py
+3
-0
3 additions, 0 deletions
tests/test_ilastik/test_ilastik.py
with
13 additions
and
2 deletions
model_server/extensions/ilastik/models.py
+
10
−
2
View file @
b5d80b38
...
...
@@ -152,9 +152,12 @@ class IlastikPixelClassifierModel(IlastikModel, SemanticSegmentationModel):
)
return
InMemoryDataAccessor
(
data
=
yxcz
)
def
infer_patch_stack
(
self
,
img
:
PatchStack
,
crop
=
True
,
**
kwargs
)
->
(
np
.
ndarray
,
dict
):
def
infer_patch_stack
(
self
,
img
:
PatchStack
,
crop
=
True
,
normalize
=
False
,
**
kwargs
)
->
(
np
.
ndarray
,
dict
):
"""
Iterative over a patch stack, call inference separately on each cropped patch
:param img: patch stack of input data
:param crop: pass list of cropped (generally non-uniform) patches to classifier if True
:param normalize: scale the inference result (generally 0.0 to 1.0) to the range of img if True
"""
dsi
=
[
{
...
...
@@ -165,7 +168,12 @@ class IlastikPixelClassifierModel(IlastikModel, SemanticSegmentationModel):
]
pxmaps
=
self
.
shell
.
workflow
.
batchProcessingApplet
.
run_export
(
dsi
,
export_to_array
=
True
)
# [z x h x w x n]
yxcz
=
[
np
.
moveaxis
(
pm
,
[
1
,
2
,
3
,
0
],
[
0
,
1
,
2
,
3
])
for
pm
in
pxmaps
]
return
PatchStack
(
yxcz
)
if
normalize
:
return
PatchStack
(
yxcz
).
apply
(
lambda
x
:
(
x
*
img
.
dtype_max
).
astype
(
img
.
dtype
)
)
else
:
return
PatchStack
(
yxcz
)
def
label_pixel_class
(
self
,
img
:
GenericImageDataAccessor
,
**
kwargs
):
pxmap
=
self
.
infer
(
img
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_ilastik/test_ilastik.py
+
3
−
0
View file @
b5d80b38
...
...
@@ -150,6 +150,9 @@ class TestIlastikPixelClassification(unittest.TestCase):
self
.
assertEqual
(
pxmap
.
nz
,
acc
.
nz
)
self
.
assertEqual
(
pxmap
.
count
,
acc
.
count
)
norm_pxmap
=
self
.
model
.
infer_patch_stack
(
acc
,
normalize
=
True
)
self
.
assertEqual
(
norm_pxmap
.
dtype
,
'
uint8
'
)
def
test_run_object_classifier_from_pixel_predictions
(
self
):
self
.
test_run_pixel_classifier
()
fp
=
czifile
[
'
path
'
]
...
...
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