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
f7c02a0a
Commit
f7c02a0a
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Moved patch stack-specific ilastik model
parent
008c2bd2
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/examples/transfer_labels_to_ilastik_object_classifier.py
+3
-39
3 additions, 39 deletions
.../examples/transfer_labels_to_ilastik_object_classifier.py
extensions/chaeo/models.py
+43
-0
43 additions, 0 deletions
extensions/chaeo/models.py
with
46 additions
and
39 deletions
extensions/chaeo/examples/transfer_labels_to_ilastik_object_classifier.py
+
3
−
39
View file @
f7c02a0a
...
...
@@ -6,47 +6,11 @@ import numpy as np
import
pandas
as
pd
import
skimage
import
uuid
import
vigra
from
extensions.chaeo.accessors
import
MonoPatchStack
,
MonoPatchStackFromFile
from
extensions.
ilastik
.models
import
Ilasti
kObjectClassifier
FromSegmentationModel
from
model_server.accessors
import
generate_file_accessor
,
GenericImageDataAccessor
,
InMemoryDataAccessor
,
write_accessor_data_to_file
from
extensions.chaeo.accessors
import
MonoPatchStackFromFile
from
extensions.
chaeo
.models
import
PatchStac
kObjectClassifier
from
model_server.accessors
import
generate_file_accessor
,
GenericImageDataAccessor
,
write_accessor_data_to_file
class
PatchStackObjectClassifier
(
IlastikObjectClassifierFromSegmentationModel
):
"""
Wrap ilastik object classification for inputs comprising raw image and binary segmentation masks, both represented
as time-series images where each frame contains only one object.
"""
def
infer
(
self
,
input_acc
:
MonoPatchStack
,
segmentation_acc
:
MonoPatchStack
)
->
(
np
.
ndarray
,
dict
):
assert
segmentation_acc
.
is_mask
()
assert
input_acc
.
chroma
==
1
tagged_input_data
=
vigra
.
taggedView
(
input_acc
.
make_tczyx
(),
'
tczyx
'
)
tagged_seg_data
=
vigra
.
taggedView
(
segmentation_acc
.
make_tczyx
(),
'
tczyx
'
)
dsi
=
[
{
'
Raw Data
'
:
self
.
PreloadedArrayDatasetInfo
(
preloaded_array
=
tagged_input_data
),
'
Segmentation Image
'
:
self
.
PreloadedArrayDatasetInfo
(
preloaded_array
=
tagged_seg_data
),
}
]
obmaps
=
self
.
shell
.
workflow
.
batchProcessingApplet
.
run_export
(
dsi
,
export_to_array
=
True
)
# [z x h x w x n]
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
)
yxcz
=
np
.
moveaxis
(
obmaps
[
0
][:,
:,
:,
:,
0
],
[
2
,
3
,
1
,
0
],
[
0
,
1
,
2
,
3
]
)
assert
yxcz
.
shape
==
input_acc
.
shape
return
InMemoryDataAccessor
(
data
=
yxcz
),
{
'
success
'
:
True
}
def
get_dataset_info
(
h5
:
h5py
.
File
,
lane
:
int
=
0
):
"""
...
...
This diff is collapsed.
Click to expand it.
extensions/chaeo/models.py
0 → 100644
+
43
−
0
View file @
f7c02a0a
import
numpy
as
np
import
vigra
from
extensions.chaeo.accessors
import
MonoPatchStack
from
extensions.ilastik.models
import
IlastikObjectClassifierFromSegmentationModel
from
model_server.accessors
import
InMemoryDataAccessor
class
PatchStackObjectClassifier
(
IlastikObjectClassifierFromSegmentationModel
):
"""
Wrap ilastik object classification for inputs comprising raw image and binary segmentation masks, both represented
as time-series images where each frame contains only one object.
"""
def
infer
(
self
,
input_acc
:
MonoPatchStack
,
segmentation_acc
:
MonoPatchStack
)
->
(
np
.
ndarray
,
dict
):
assert
segmentation_acc
.
is_mask
()
assert
input_acc
.
chroma
==
1
tagged_input_data
=
vigra
.
taggedView
(
input_acc
.
make_tczyx
(),
'
tczyx
'
)
tagged_seg_data
=
vigra
.
taggedView
(
segmentation_acc
.
make_tczyx
(),
'
tczyx
'
)
dsi
=
[
{
'
Raw Data
'
:
self
.
PreloadedArrayDatasetInfo
(
preloaded_array
=
tagged_input_data
),
'
Segmentation Image
'
:
self
.
PreloadedArrayDatasetInfo
(
preloaded_array
=
tagged_seg_data
),
}
]
obmaps
=
self
.
shell
.
workflow
.
batchProcessingApplet
.
run_export
(
dsi
,
export_to_array
=
True
)
# [z x h x w x n]
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
)
yxcz
=
np
.
moveaxis
(
obmaps
[
0
][:,
:,
:,
:,
0
],
[
2
,
3
,
1
,
0
],
[
0
,
1
,
2
,
3
]
)
assert
yxcz
.
shape
==
input_acc
.
shape
return
InMemoryDataAccessor
(
data
=
yxcz
),
{
'
success
'
:
True
}
\ 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