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
b9037651
Commit
b9037651
authored
10 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Test coverage of ilastik workflow and API endpoint that currently restricts multichannel inputs
parent
9a811694
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!50
Release 2024.06.03
,
!40
ilastik workflow and API allow multichannel inputs
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
model_server/extensions/ilastik/tests/test_ilastik.py
+50
-8
50 additions, 8 deletions
model_server/extensions/ilastik/tests/test_ilastik.py
with
50 additions
and
8 deletions
model_server/extensions/ilastik/tests/test_ilastik.py
+
50
−
8
View file @
b9037651
...
...
@@ -7,6 +7,7 @@ import numpy as np
from
model_server.conf.testing
import
czifile
,
ilastik_classifiers
,
output_path
,
roiset_test_data
from
model_server.base.accessors
import
CziImageFileAccessor
,
generate_file_accessor
,
InMemoryDataAccessor
,
PatchStack
,
write_accessor_data_to_file
from
model_server.extensions.ilastik
import
models
as
ilm
from
model_server.extensions.ilastik.workflows
import
infer_px_then_ob_model
from
model_server.base.models
import
InvalidObjectLabelsError
from
model_server.base.roiset
import
_get_label_ids
,
RoiSet
,
RoiSetMetaParams
from
model_server.base.workflows
import
classify_pixels
...
...
@@ -325,7 +326,7 @@ class TestIlastikOnMultichannelInputs(TestServerBaseClass):
super
(
TestIlastikOnMultichannelInputs
,
self
).
setUp
()
self
.
pa_px_classifier
=
ilastik_classifiers
[
'
px_color_zstack
'
]
self
.
pa_ob_classifier
=
ilastik_classifiers
[
'
ob_color_zstack
'
]
self
.
input_image
=
generate_file_accessor
(
roiset_test_data
[
'
multichannel_zstack
'
][
'
path
'
]
)
self
.
pa_
input_image
=
roiset_test_data
[
'
multichannel_zstack
'
][
'
path
'
]
def
_copy_input_file_to_server
(
self
):
from
shutil
import
copyfile
...
...
@@ -340,21 +341,62 @@ class TestIlastikOnMultichannelInputs(TestServerBaseClass):
)
def
test_classify_pixels
(
self
):
self
.
assertGreater
(
self
.
input_image
.
chroma
,
1
)
img
=
generate_file_accessor
(
self
.
pa_input_image
)
self
.
assertGreater
(
img
.
chroma
,
1
)
mod
=
ilm
.
IlastikPixelClassifierModel
(
params
=
{
'
project_file
'
:
self
.
pa_px_classifier
})
pxmap
=
mod
.
infer
(
self
.
input_image
)[
0
]
self
.
assertEqual
(
pxmap
.
hw
,
self
.
input_image
.
hw
)
self
.
assertEqual
(
pxmap
.
nz
,
self
.
input_image
.
nz
)
pxmap
=
mod
.
infer
(
img
)[
0
]
self
.
assertEqual
(
pxmap
.
hw
,
img
.
hw
)
self
.
assertEqual
(
pxmap
.
nz
,
img
.
nz
)
return
pxmap
def
test_classify_objects
(
self
):
pxmap
=
self
.
test_classify_pixels
()
img
=
generate_file_accessor
(
self
.
pa_input_image
)
mod
=
ilm
.
IlastikObjectClassifierFromPixelPredictionsModel
(
params
=
{
'
project_file
'
:
self
.
pa_ob_classifier
})
obmap
=
mod
.
infer
(
self
.
input_image
,
pxmap
)[
0
]
self
.
assertEqual
(
obmap
.
hw
,
self
.
input_image
.
hw
)
self
.
assertEqual
(
obmap
.
nz
,
self
.
input_image
.
nz
)
obmap
=
mod
.
infer
(
img
,
pxmap
)[
0
]
self
.
assertEqual
(
obmap
.
hw
,
img
.
hw
)
self
.
assertEqual
(
obmap
.
nz
,
img
.
nz
)
def
_call_workflow
(
self
,
channel
):
return
infer_px_then_ob_model
(
self
.
pa_input_image
,
ilm
.
IlastikPixelClassifierModel
(
params
=
{
'
project_file
'
:
self
.
pa_px_classifier
}),
ilm
.
IlastikObjectClassifierFromPixelPredictionsModel
(
params
=
{
'
project_file
'
:
self
.
pa_ob_classifier
}),
output_path
,
channel
=
channel
,
)
def
test_workflow
(
self
):
with
self
.
assertRaises
(
ilm
.
IlastikInputShapeError
):
self
.
_call_workflow
(
channel
=
0
)
res
=
self
.
_call_workflow
(
channel
=
None
)
def
test_api
(
self
):
resp_load
=
self
.
_put
(
'
ilastik/seg/load/
'
,
query
=
{
'
project_file
'
:
str
(
self
.
pa_px_classifier
)},
)
self
.
assertEqual
(
resp_load
.
status_code
,
200
,
resp_load
.
json
())
px_model_id
=
resp_load
.
json
()[
'
model_id
'
]
resp_load
=
self
.
_put
(
'
ilastik/pxmap_to_obj/load/
'
,
query
=
{
'
project_file
'
:
str
(
self
.
pa_ob_classifier
)},
)
self
.
assertEqual
(
resp_load
.
status_code
,
200
,
resp_load
.
json
())
ob_model_id
=
resp_load
.
json
()[
'
model_id
'
]
resp_infer
=
self
.
_put
(
'
ilastik/pixel_then_object_classification/infer/
'
,
query
=
{
'
px_model_id
'
:
px_model_id
,
'
ob_model_id
'
:
ob_model_id
,
'
input_filename
'
:
self
.
pa_input_image
,
# 'channel': 0,
}
)
self
.
assertEqual
(
resp_infer
.
status_code
,
200
,
resp_infer
.
content
.
decode
())
class
TestIlastikObjectClassification
(
unittest
.
TestCase
):
...
...
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