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
3b34d7e4
Commit
3b34d7e4
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Batch script to generate coloring book-like line profiles from pixel classifier
parent
1aa7b51b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
extensions/chaeo/batch_jobs/coloring_book.py
+52
-0
52 additions, 0 deletions
extensions/chaeo/batch_jobs/coloring_book.py
with
52 additions
and
0 deletions
extensions/chaeo/batch_jobs/coloring_book.py
0 → 100644
+
52
−
0
View file @
3b34d7e4
from
pathlib
import
Path
import
numpy
as
np
import
pandas
as
pd
from
skimage.filters
import
gaussian
from
skimage.measure
import
label
,
regionprops_table
import
tifffile
from
extensions.chaeo.accessors
import
MonoPatchStack
from
extensions.ilastik.models
import
IlastikPixelClassifierModel
from
model_server.accessors
import
write_accessor_data_to_file
,
InMemoryDataAccessor
if
__name__
==
'
__main__
'
:
root
=
Path
(
'
c:/Users/rhodes/projects/proj0011-plankton-seg/exp0024
'
)
px_ilp
=
root
/
'
px02.ilp
'
sigma
=
1.0
thresh
=
0.15
min_area
=
400
tf
=
tifffile
.
imread
(
root
/
'
20231008-162336-z04-TL.tif
'
)
instack
=
MonoPatchStack
(
np
.
moveaxis
(
tf
,
0
,
-
1
))
px_mod
=
IlastikPixelClassifierModel
(
params
=
{
'
project_file
'
:
px_ilp
})
pxmaps
=
[]
def
pipeline
(
yx_img
):
pxmap
,
_
=
px_mod
.
infer
(
InMemoryDataAccessor
(
yx_img
))
smoothed
=
gaussian
(
pxmap
.
get_one_channel_data
(
0
).
data
,
sigma
=
sigma
)
mask
=
smoothed
>
thresh
proc_mask
=
mask
lamap
=
label
(
proc_mask
).
astype
(
'
uint16
'
)
df
=
(
pd
.
DataFrame
(
regionprops_table
(
lamap
[:,
:,
0
,
0
],
properties
=
(
'
label
'
,
'
area
'
)
)
)
)
la_keep
=
df
.
loc
[
df
[
'
area
'
]
>
min_area
,
'
label
'
].
unique
()
fil_mask
=
np
.
isin
(
lamap
,
la_keep
)
inv
=
np
.
invert
(
fil_mask
)
return
InMemoryDataAccessor
(
inv
)
results
=
[]
for
i
in
range
(
0
,
instack
.
count
):
res
=
pipeline
(
instack
.
iat
(
i
))
results
.
append
(
res
)
outfile
=
root
/
'
output
'
/
f
'
res_
{
i
:
04
d
}
.tif
'
outfile
.
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
write_accessor_data_to_file
(
outfile
,
res
)
print
(
'
Finished
'
)
\ 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