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
10dd0b50
You need to sign in or sign up before continuing.
Commit
10dd0b50
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Re-merged option to automatically MIP z-stacks sent to ilastik workflow
parent
9832ab04
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
model_server/base/accessors.py
+6
-3
6 additions, 3 deletions
model_server/base/accessors.py
model_server/extensions/ilastik/router.py
+3
-2
3 additions, 2 deletions
model_server/extensions/ilastik/router.py
tests/test_accessors.py
+10
-0
10 additions, 0 deletions
tests/test_accessors.py
with
19 additions
and
5 deletions
model_server/base/accessors.py
+
6
−
3
View file @
10dd0b50
...
...
@@ -38,9 +38,12 @@ class GenericImageDataAccessor(ABC):
def
is_mask
(
self
):
return
is_mask
(
self
.
_data
)
def
get_one_channel_data
(
self
,
channel
:
int
):
def
get_one_channel_data
(
self
,
channel
:
int
,
mip
:
bool
=
False
):
c
=
int
(
channel
)
return
InMemoryDataAccessor
(
self
.
data
[:,
:,
c
:(
c
+
1
),
:])
if
mip
:
return
InMemoryDataAccessor
(
self
.
data
[:,
:,
c
:(
c
+
1
),
:].
max
(
axis
=-
1
))
else
:
return
InMemoryDataAccessor
(
self
.
data
[:,
:,
c
:(
c
+
1
),
:])
@property
def
pixel_scale_in_micrometers
(
self
):
...
...
@@ -101,7 +104,7 @@ class TifSingleSeriesFileAccessor(GenericImageFileAccessor):
tf
=
tifffile
.
TiffFile
(
fpath
)
self
.
tf
=
tf
except
Exception
:
FileAccessorError
(
f
'
Unable to access data in
{
fpath
}
'
)
raise
FileAccessorError
(
f
'
Unable to access data in
{
fpath
}
'
)
if
len
(
tf
.
series
)
!=
1
:
raise
DataShapeError
(
f
'
Expect only one series in
{
fpath
}
'
)
...
...
This diff is collapsed.
Click to expand it.
model_server/extensions/ilastik/router.py
+
3
−
2
View file @
10dd0b50
...
...
@@ -48,7 +48,7 @@ def load_seg_to_obj_model(project_file: str, duplicate: bool = True) -> dict:
return
load_ilastik_model
(
ilm
.
IlastikObjectClassifierFromSegmentationModel
,
project_file
,
duplicate
=
duplicate
)
@router.put
(
'
/pixel_then_object_classification/infer
'
)
def
infer_px_then_ob_maps
(
px_model_id
:
str
,
ob_model_id
:
str
,
input_filename
:
str
,
channel
:
int
=
None
)
->
dict
:
def
infer_px_then_ob_maps
(
px_model_id
:
str
,
ob_model_id
:
str
,
input_filename
:
str
,
channel
:
int
=
None
,
mip
:
bool
=
False
)
->
dict
:
inpath
=
session
.
paths
[
'
inbound_images
'
]
/
input_filename
validate_workflow_inputs
([
px_model_id
,
ob_model_id
],
[
inpath
])
try
:
...
...
@@ -57,7 +57,8 @@ def infer_px_then_ob_maps(px_model_id: str, ob_model_id: str, input_filename: st
session
.
models
[
px_model_id
][
'
object
'
],
session
.
models
[
ob_model_id
][
'
object
'
],
session
.
paths
[
'
outbound_images
'
],
channel
=
channel
channel
=
channel
,
mip
=
mip
,
)
except
AssertionError
:
raise
HTTPException
(
f
'
Incompatible models
{
px_model_id
}
and/or
{
ob_model_id
}
'
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_accessors.py
+
10
−
0
View file @
10dd0b50
...
...
@@ -44,6 +44,16 @@ class TestCziImageFileAccess(unittest.TestCase):
sc
=
cf
.
get_one_channel_data
(
c
)
self
.
assertEqual
(
sc
.
shape
,
(
h
,
w
,
1
,
nz
))
def
test_get_single_channel_mip_from_zstack
(
self
):
w
=
256
h
=
512
nc
=
4
nz
=
11
c
=
3
cf
=
InMemoryDataAccessor
(
np
.
random
.
rand
(
h
,
w
,
nc
,
nz
))
sc
=
cf
.
get_one_channel_data
(
c
,
mip
=
True
)
self
.
assertEqual
(
sc
.
shape
,
(
h
,
w
,
1
,
1
))
def
test_write_single_channel_tif
(
self
):
ch
=
4
cf
=
CziImageFileAccessor
(
czifile
[
'
path
'
])
...
...
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