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
d056fb0b
Commit
d056fb0b
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Support single-channel annotated z-stack exports from RoiSet
parent
1d76d512
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
model_server/base/annotators.py
+12
-5
12 additions, 5 deletions
model_server/base/annotators.py
tests/test_roiset.py
+9
-1
9 additions, 1 deletion
tests/test_roiset.py
with
21 additions
and
6 deletions
model_server/base/annotators.py
+
12
−
5
View file @
d056fb0b
...
...
@@ -4,19 +4,26 @@ from PIL import Image, ImageDraw, ImageFont
from
model_server.base.process
import
rescale
def
draw_boxes_on_3d_image
(
roiset
,
draw_full_depth
=
False
,
**
kwargs
):
_
,
_
,
chroma
,
nz
=
roiset
.
acc_raw
.
shape
h
,
w
,
chroma
,
nz
=
roiset
.
acc_raw
.
shape
font_size
=
kwargs
.
get
(
'
font_size
'
,
18
)
linewidth
=
kwargs
.
get
(
'
linewidth
'
,
4
)
annotated
=
np
.
zeros
(
roiset
.
acc_raw
.
shape
,
dtype
=
roiset
.
acc_raw
.
dtype
)
if
ck
:
=
kwargs
.
get
(
'
channel
'
):
channels
=
[
ck
]
shape
=
(
h
,
w
,
1
,
nz
)
else
:
channels
=
range
(
0
,
chroma
)
shape
=
roiset
.
acc_raw
.
shape
annotated
=
np
.
zeros
(
shape
,
dtype
=
roiset
.
acc_raw
.
dtype
)
for
zi
in
range
(
0
,
nz
):
if
draw_full_depth
:
subset
=
roiset
.
get_df
()
else
:
subset
=
roiset
.
get_df
().
query
(
f
'
zi ==
{
zi
}
'
)
for
c
in
range
(
0
,
chroma
):
pilimg
=
Image
.
fromarray
(
roiset
.
acc_raw
.
data
[:,
:,
c
,
zi
])
for
c
i
in
range
(
0
,
len
(
channels
)
):
pilimg
=
Image
.
fromarray
(
roiset
.
acc_raw
.
data
[:,
:,
c
hannels
[
ci
]
,
zi
])
draw
=
ImageDraw
.
Draw
(
pilimg
)
draw
.
font
=
ImageFont
.
truetype
(
font
=
"
arial.ttf
"
,
size
=
font_size
)
...
...
@@ -26,7 +33,7 @@ def draw_boxes_on_3d_image(roiset, draw_full_depth=False, **kwargs):
if
kwargs
.
get
(
'
draw_label
'
)
is
True
:
draw
.
text
((
xm
,
roi
.
y0
),
f
'
{
roi
.
label
:
04
d
}
'
,
fill
=
'
white
'
,
anchor
=
'
mb
'
)
annotated
[:,
:,
c
,
zi
]
=
pilimg
annotated
[:,
:,
c
i
,
zi
]
=
pilimg
if
clip
:
=
kwargs
.
get
(
'
rescale_clip
'
):
...
...
This diff is collapsed.
Click to expand it.
tests/test_roiset.py
+
9
−
1
View file @
d056fb0b
...
...
@@ -229,5 +229,13 @@ class TestRoiSetMultichannelProducts(BaseTestRoiSetMonoProducts, unittest.TestCa
self
.
assertEqual
(
result
.
chroma
,
self
.
stack
.
chroma
)
self
.
assertEqual
(
result
.
nz
,
self
.
stack
.
nz
)
def
test_export_single_channel_annotated_zstack
(
self
):
file
=
self
.
roiset
.
export_annotated_zstack
(
output_path
/
'
annotated_zstack
'
,
channel
=
3
,
)
result
=
generate_file_accessor
(
Path
(
file
[
'
location
'
])
/
file
[
'
filename
'
])
self
.
assertEqual
(
result
.
hw
,
self
.
roiset
.
acc_raw
.
hw
)
self
.
assertEqual
(
result
.
nz
,
self
.
roiset
.
acc_raw
.
nz
)
self
.
assertEqual
(
result
.
chroma
,
1
)
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