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
74716ae8
Commit
74716ae8
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Split some HDF5 into util module
parent
68b683fc
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
+9
-38
9 additions, 38 deletions
.../examples/transfer_labels_to_ilastik_object_classifier.py
extensions/chaeo/h5util.py
+34
-0
34 additions, 0 deletions
extensions/chaeo/h5util.py
with
43 additions
and
38 deletions
extensions/chaeo/examples/transfer_labels_to_ilastik_object_classifier.py
+
9
−
38
View file @
74716ae8
...
...
@@ -8,41 +8,11 @@ import skimage
import
uuid
from
extensions.chaeo.accessors
import
MonoPatchStackFromFile
from
extensions.chaeo.h5util
import
get_dataset_info
from
extensions.chaeo.models
import
PatchStackObjectClassifier
from
model_server.accessors
import
generate_file_accessor
,
GenericImageDataAccessor
,
write_accessor_data_to_file
def
get_dataset_info
(
h5
:
h5py
.
File
,
lane
:
int
=
0
):
"""
Report out specific datasets in ilastik project file HDF5
:param h5: handle to ilastik project file, as h5py.File object
:param lane: ilastik lane identifier
:return: (dict) selected data values from project file
"""
lns
=
f
'
{
lane
:
04
d
}
'
lane
=
f
'
Input Data/infos/lane
{
lns
}
'
info
=
{}
for
gk
in
[
'
Raw Data
'
,
'
Segmentation Image
'
]:
info
[
gk
]
=
{}
for
dk
in
[
'
location
'
,
'
filePath
'
,
'
shape
'
,
'
nickname
'
]:
try
:
info
[
gk
][
dk
]
=
h5
[
f
'
{
lane
}
/
{
gk
}
/
{
dk
}
'
][()]
except
Exception
as
e
:
print
(
e
)
try
:
info
[
gk
][
'
id
'
]
=
uuid
.
UUID
(
h5
[
f
'
{
lane
}
/
{
gk
}
/datasetId
'
][()].
decode
())
except
ValueError
as
e
:
info
[
gk
][
'
id
'
]
=
'
<invalid UUID>
'
info
[
gk
][
'
axistags
'
]
=
json
.
loads
(
h5
[
f
'
{
lane
}
/
{
gk
}
/axistags
'
][()].
decode
())
info
[
gk
][
'
axes
'
]
=
[
ax
[
'
key
'
]
for
ax
in
info
[
gk
][
'
axistags
'
][
'
axes
'
]]
obj_cl_group
=
h5
[
f
'
ObjectClassification/LabelInputs/
{
lns
}
'
]
info
[
'
misc
'
]
=
{
'
number_of_label_inputs
'
:
len
(
obj_cl_group
.
items
())
}
return
info
def
generate_ilastik_object_classifier
(
template_ilp
:
str
,
where
:
str
,
...
...
@@ -180,15 +150,16 @@ def compare_object_maps(truth: GenericImageDataAccessor, inferred: GenericImageD
if
__name__
==
'
__main__
'
:
root
=
Path
(
'
c:/Users/rhodes/projects/proj0011-plankton-seg/
'
)
template_ilp
=
root
/
'
exp0014/template_obj.ilp
'
where_patch_stack
=
root
/
'
exp0009/output/labeled_patches-202310
18
-000
6
'
where_patch_stack
=
root
/
'
exp0009/output/labeled_patches-202310
30
-000
1
'
# auto-populate an object classifier
auto_ilp
=
generate_ilastik_object_classifier
(
template_ilp
,
where_patch_stack
,
stack_name
=
'
train
'
,
proj_name
=
'
auto_obj_before
'
)
# auto_ilp = generate_ilastik_object_classifier(
# template_ilp,
# where_patch_stack,
# stack_name='train',
# proj_name='auto_obj_before'
# )
auto_ilp
=
'
auto_obj_before.ilp
'
def
infer_and_compare_training_set
(
ilp
,
suffix
):
# infer object labels from the same data used to train the classifier
...
...
This diff is collapsed.
Click to expand it.
extensions/chaeo/h5util.py
0 → 100644
+
34
−
0
View file @
74716ae8
import
json
import
uuid
import
h5py
def
get_dataset_info
(
h5
:
h5py
.
File
,
lane
:
int
=
0
):
"""
Report out specific datasets in ilastik project file HDF5
:param h5: handle to ilastik project file, as h5py.File object
:param lane: ilastik lane identifier
:return: (dict) selected data values from project file
"""
lns
=
f
'
{
lane
:
04
d
}
'
lane
=
f
'
Input Data/infos/lane
{
lns
}
'
info
=
{}
for
gk
in
[
'
Raw Data
'
,
'
Segmentation Image
'
]:
info
[
gk
]
=
{}
for
dk
in
[
'
location
'
,
'
filePath
'
,
'
shape
'
,
'
nickname
'
]:
try
:
info
[
gk
][
dk
]
=
h5
[
f
'
{
lane
}
/
{
gk
}
/
{
dk
}
'
][()]
except
Exception
as
e
:
print
(
e
)
try
:
info
[
gk
][
'
id
'
]
=
uuid
.
UUID
(
h5
[
f
'
{
lane
}
/
{
gk
}
/datasetId
'
][()].
decode
())
except
ValueError
as
e
:
info
[
gk
][
'
id
'
]
=
'
<invalid UUID>
'
info
[
gk
][
'
axistags
'
]
=
json
.
loads
(
h5
[
f
'
{
lane
}
/
{
gk
}
/axistags
'
][()].
decode
())
info
[
gk
][
'
axes
'
]
=
[
ax
[
'
key
'
]
for
ax
in
info
[
gk
][
'
axistags
'
][
'
axes
'
]]
obj_cl_group
=
h5
[
f
'
ObjectClassification/LabelInputs/
{
lns
}
'
]
info
[
'
misc
'
]
=
{
'
number_of_label_inputs
'
:
len
(
obj_cl_group
.
items
())
}
return
info
\ 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