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
b54bfadd
Commit
b54bfadd
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Test coverage of patch stack object classification
parent
f21346e9
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
+11
-10
11 additions, 10 deletions
model_server/extensions/ilastik/models.py
model_server/extensions/ilastik/tests/test_ilastik.py
+6
-2
6 additions, 2 deletions
model_server/extensions/ilastik/tests/test_ilastik.py
with
17 additions
and
12 deletions
model_server/extensions/ilastik/models.py
+
11
−
10
View file @
b54bfadd
...
...
@@ -189,7 +189,10 @@ class PatchStackObjectClassifier(IlastikObjectClassifierFromSegmentationModel):
def
infer
(
self
,
input_acc
:
PatchStack
,
segmentation_acc
:
PatchStack
)
->
(
np
.
ndarray
,
dict
):
assert
segmentation_acc
.
is_mask
()
assert
input_acc
.
chroma
==
1
if
not
input_acc
.
chroma
==
1
:
raise
InvalidInputImageError
(
'
Object classifier expects only monochrome patches
'
)
if
not
input_acc
.
nz
==
1
:
raise
InvalidInputImageError
(
'
Object classifier expects only 2d patches
'
)
tagged_input_data
=
vigra
.
taggedView
(
input_acc
.
pczyx
,
'
tczyx
'
)
tagged_seg_data
=
vigra
.
taggedView
(
segmentation_acc
.
pczyx
,
'
tczyx
'
)
...
...
@@ -205,14 +208,12 @@ class PatchStackObjectClassifier(IlastikObjectClassifierFromSegmentationModel):
assert
len
(
obmaps
)
==
1
,
'
ilastik generated more than one object map
'
# for some reason ilastik scrambles these axes to
Z
(1)YX(1)
assert
obmaps
[
0
].
shape
==
(
input_acc
.
nz
,
1
,
input_acc
.
hw
[
0
],
input_acc
.
hw
[
1
],
1
)
yxz
=
np
.
moveaxis
(
obmaps
[
0
][:,
0
,
:,
:,
0
],
[
1
,
2
,
0
],
[
0
,
1
,
2
]
# for some reason ilastik scrambles these axes to
P
(1)YX(1)
; unclear which should be Z and C
assert
obmaps
[
0
].
shape
==
(
input_acc
.
count
,
1
,
input_acc
.
hw
[
0
],
input_acc
.
hw
[
1
],
1
)
p
yx
c
z
=
np
.
moveaxis
(
obmaps
[
0
],
[
0
,
1
,
2
,
3
,
4
],
[
0
,
4
,
1
,
2
,
3
]
)
assert
yxz
.
shape
[
0
:
2
]
==
input_acc
.
hw
assert
yxz
.
shape
[
2
]
==
input_acc
.
nz
return
PatchStack
(
data
=
yxz
),
{
'
success
'
:
True
}
return
PatchStack
(
data
=
pyxcz
),
{
'
success
'
:
True
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
model_server/extensions/ilastik/tests/test_ilastik.py
+
6
−
2
View file @
b54bfadd
...
...
@@ -292,5 +292,9 @@ class TestIlastikObjectClassification(unittest.TestCase):
def
test_classify_patches
(
self
):
raw_patches
=
self
.
roiset
.
get_raw_patches
()
patch_masks
=
self
.
roiset
.
get_patch_masks
()
res
=
self
.
object_classifier
.
infer
(
raw_patches
,
patch_masks
)
self
.
assertEqual
(
0
,
1
)
res_patches
,
_
=
self
.
object_classifier
.
infer
(
raw_patches
,
patch_masks
)
self
.
assertEqual
(
res_patches
.
count
,
self
.
roiset
.
count
)
for
pi
in
range
(
0
,
res_patches
.
count
):
# assert that there is only one nonzero label per patch
unique
=
np
.
unique
(
res_patches
.
iat
(
pi
))
self
.
assertEqual
(
len
(
unique
),
2
)
self
.
assertEqual
(
unique
[
0
],
0
)
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