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
d1e56aa1
Commit
d1e56aa1
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
More rough-in to reconcile object classifier result with object labels
parent
e76de5a3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
extensions/chaeo/workflows.py
+23
-7
23 additions, 7 deletions
extensions/chaeo/workflows.py
with
23 additions
and
7 deletions
extensions/chaeo/workflows.py
+
23
−
7
View file @
d1e56aa1
...
...
@@ -7,8 +7,9 @@ import pandas as pd
from
skimage.morphology
import
dilation
from
sklearn.model_selection
import
train_test_split
from
extensions.
ilastik.models
import
IlastikPixelClassifierModel
from
extensions.
chaeo.accessors
import
MonoPatchStack
from
extensions.chaeo.annotators
import
draw_boxes_on_3d_image
from
extensions.chaeo.models
import
PatchStackObjectClassifier
from
extensions.chaeo.products
import
export_patches_from_zstack
,
export_patch_masks_from_zstack
,
export_multichannel_patches_from_zstack
,
get_patches_from_zmask_meta
,
get_patch_masks_from_zmask_meta
from
extensions.chaeo.zmask
import
build_zmask_from_object_mask
,
project_stack_from_focal_points
from
extensions.ilastik.models
import
IlastikPixelClassifierModel
...
...
@@ -224,7 +225,11 @@ def get_object_map_from_zstack(
zmask_expand_box_by
:
int
=
None
,
**
kwargs
,
)
->
Dict
:
assert
len
(
models
)
==
2
pixel_classifier
=
models
[
0
]
assert
isinstance
(
pixel_classifier
,
IlastikPixelClassifierModel
)
object_classifier
=
models
[
1
]
assert
isinstance
(
object_classifier
,
PatchStackObjectClassifier
)
ti
,
stack
,
fstem
,
obmask
,
pxmap
,
zmask
,
zmask_meta
,
df
,
interm
=
get_zmask_meta
(
input_file_path
,
...
...
@@ -256,14 +261,25 @@ def get_object_map_from_zstack(
)
# send patches and mask stacks to object classifier
mod
=
PatchStackObjectClassifier
({
'
project_file
'
:
where_patch_stack
/
ilp
})
result_acc
,
_
=
mod
.
infer
(
raw
,
mask
)
# write_accessor_data_to_file(where_patch_stack / f'zstack_train_result_{suffix}.tif', result_acc)
result_acc
,
_
=
MonoPatchStack
(
object_classifier
.
infer
(
patches_acc
,
patch_masks_acc
)
)
object_labels_map
=
np
.
copy
(
interm
[
'
label_map
'
])
assert
object_labels_map
.
shape
==
interm
[
'
label_map
'
].
shape
assert
object_labels_map
.
dtype
==
interm
[
'
label_map
'
].
dtype
# assign labels to object map:
for
ii
,
mi
in
enumerate
(
zmask_meta
):
obj
=
mi
[
'
info
'
]
la
=
obj
.
label
for
ii
in
range
(
0
,
len
(
zmask_meta
)):
mi
=
zmask_meta
[
ii
]
object_label_id
=
mi
[
'
info
'
].
label
result_label_map
=
result_acc
.
iat
(
ii
)
unique_values
=
np
.
unique
(
result_label_map
)
assert
len
(
unique_values
)
==
2
assert
unique_values
[
0
]
==
0
inferred_class
=
result_acc
.
iat
(
ii
)
ii_mask
=
object_labels_map
==
object_label_id
object_labels_map
[
ii_mask
]
=
unique_values
[
1
]
patch
=
patches_acc
.
iat
(
ii
)
...
...
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