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
4aacaa00
You need to sign in or sign up before continuing.
Commit
4aacaa00
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Batch runner passes only JSON-normalized data to workflow, and saves this to CSV for each iteration
parent
50eb5c6e
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
extensions/chaeo/examples/batch_run_patches.py
+3
-21
3 additions, 21 deletions
extensions/chaeo/examples/batch_run_patches.py
extensions/chaeo/workflows.py
+4
-5
4 additions, 5 deletions
extensions/chaeo/workflows.py
with
7 additions
and
26 deletions
extensions/chaeo/examples/batch_run_patches.py
+
3
−
21
View file @
4aacaa00
...
...
@@ -6,7 +6,6 @@ from time import localtime, strftime
import
pandas
as
pd
from
extensions.chaeo.workflows
import
export_patches_from_multichannel_zstack
from
extensions.ilastik.models
import
IlastikPixelClassifierModel
from
model_server.accessors
import
InMemoryDataAccessor
,
write_accessor_data_to_file
if
__name__
==
'
__main__
'
:
...
...
@@ -27,9 +26,6 @@ if __name__ == '__main__':
csv_args
=
{
'
mode
'
:
'
w
'
,
'
header
'
:
True
}
# when creating file
px_ilp
=
Path
.
home
()
/
'
model-server
'
/
'
ilastik
'
/
'
AF405-bodies_boundaries.ilp
'
px_model
=
IlastikPixelClassifierModel
(
params
=
{
'
project_file
'
:
px_ilp
}
)
for
ff
in
where_czi
.
iterdir
():
pattern
=
'
Selection--W([\d]+)--P([\d]+)-T([\d]+)
'
...
...
@@ -41,10 +37,9 @@ if __name__ == '__main__':
if
int
(
ma
.
groups
()[
1
])
>
10
:
# skip second half of set
continue
export_kwargs
=
{
'
input_zstack_path
'
:
(
where_czi
/
ff
).
__str__
(),
'
px_model
'
:
px_model
.
model_id
,
'
ilastik_project_file
'
:
px_ilp
.
__str__
()
,
'
pxmap_threshold
'
:
0.25
,
'
pixel_class
'
:
0
,
'
zmask_channel
'
:
0
,
...
...
@@ -55,19 +50,6 @@ if __name__ == '__main__':
'
zmask_expand_box_by
'
:
(
128
,
0
),
}
# result = export_patches_from_multichannel_zstack(
# input_zstack_path=where_czi / ff,
# px_model=px_model,
# pxmap_threshold=0.25,
# pixel_class=0,
# zmask_channel=0,
# patches_channel=4,
# where_output=where_output,
# mask_type='boxes',
# zmask_filters={'area': (1e3, 1e8)},
# zmask_expand_box_by=(128, 0),
# )
result
=
export_patches_from_multichannel_zstack
(
**
export_kwargs
)
# parse and record results
...
...
@@ -75,6 +57,7 @@ if __name__ == '__main__':
df
[
'
filename
'
]
=
ff
.
name
df
.
to_csv
(
where_output
/
'
df_objects.csv
'
,
**
csv_args
)
pd
.
DataFrame
(
result
[
'
timer_results
'
],
index
=
[
0
]).
to_csv
(
where_output
/
'
timer_results.csv
'
,
**
csv_args
)
pd
.
json_normalize
(
export_kwargs
).
to_csv
(
where_output
/
'
workflow_params.csv
'
,
**
csv_args
)
csv_args
=
{
'
mode
'
:
'
a
'
,
'
header
'
:
False
}
# append to CSV from here on
# export intermediate data if flagged
...
...
@@ -82,5 +65,4 @@ if __name__ == '__main__':
write_accessor_data_to_file
(
where_output
/
k
/
(
ff
.
stem
+
'
.tif
'
),
InMemoryDataAccessor
(
result
[
'
interm
'
][
k
])
)
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
extensions/chaeo/workflows.py
+
4
−
5
View file @
4aacaa00
from
pathlib
import
Path
from
typing
import
Dict
from
pydantic
import
BaseModel
from
extensions.ilastik.models
import
IlastikPixelClassifierModel
from
extensions.chaeo.annotators
import
draw_boxes_on_3d_image
from
extensions.chaeo.products
import
export_patches_from_zstack
...
...
@@ -13,7 +10,7 @@ from model_server.workflows import Timer
def
export_patches_from_multichannel_zstack
(
input_zstack_path
:
str
,
px_model_id
:
str
,
ilastik_project_file
:
str
,
pxmap_threshold
:
float
,
pixel_class
:
int
,
zmask_channel
:
int
,
...
...
@@ -34,7 +31,9 @@ def export_patches_from_multichannel_zstack(
mip
=
InMemoryDataAccessor
(
stack
.
get_one_channel_data
(
channel
=
0
).
data
.
max
(
axis
=-
1
,
keepdims
=
True
)
)
# px_model =
px_model
=
IlastikPixelClassifierModel
(
params
=
{
'
project_file
'
:
Path
(
ilastik_project_file
)}
)
pxmap
,
_
=
px_model
.
infer
(
mip
)
ti
.
click
(
'
infer_pixel_probability
'
)
...
...
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