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
6b7cdc2e
Commit
6b7cdc2e
authored
4 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Added alternate constructor for RoiSet from either YX or YXZ monochromatic data
parent
adc4795d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
model_server/base/accessors.py
+9
-0
9 additions, 0 deletions
model_server/base/accessors.py
tests/base/test_accessors.py
+21
-2
21 additions, 2 deletions
tests/base/test_accessors.py
with
30 additions
and
2 deletions
model_server/base/accessors.py
+
9
−
0
View file @
6b7cdc2e
...
...
@@ -223,6 +223,15 @@ class InMemoryDataAccessor(GenericImageDataAccessor):
self
.
_data
=
self
.
conform_data
(
data
)
self
.
lazy
=
False
@classmethod
def
from_mono
(
cls
,
data
):
if
len
(
data
.
shape
)
==
2
:
# interpret as YX
return
cls
(
np
.
expand_dims
(
data
,
(
2
,
3
)))
if
len
(
data
.
shape
)
==
3
:
return
cls
(
np
.
expand_dims
(
data
,
2
))
else
:
raise
InvalidDataShape
(
f
'
Expecting either YX or YXZ monochromatic data
'
)
class
GenericImageFileAccessor
(
GenericImageDataAccessor
):
# image data is loaded from a file
def
__init__
(
self
,
fpath
:
Path
,
lazy
=
False
):
"""
...
...
This diff is collapsed.
Click to expand it.
tests/base/test_accessors.py
+
21
−
2
View file @
6b7cdc2e
...
...
@@ -114,6 +114,25 @@ class TestCziImageFileAccess(unittest.TestCase):
acc
=
InMemoryDataAccessor
(
_random_int
(
h
,
w
,
nc
,
nz
))
self
.
assertEqual
(
acc
.
get_mono
(
0
).
data_mono
.
shape
,
(
h
,
w
,
nz
))
def
test_make_from_mono_2d
(
self
):
w
=
256
h
=
512
nda
=
_random_int
(
h
,
w
)
acc
=
InMemoryDataAccessor
.
from_mono
(
nda
)
self
.
assertEqual
(
acc
.
chroma
,
1
)
self
.
assertEqual
(
acc
.
hw
,
(
h
,
w
))
self
.
assertEqual
(
acc
.
nz
,
1
)
def
test_make_from_mono_3d
(
self
):
w
=
256
h
=
512
nz
=
11
nda
=
_random_int
(
h
,
w
,
nz
)
acc
=
InMemoryDataAccessor
.
from_mono
(
nda
)
self
.
assertEqual
(
acc
.
chroma
,
1
)
self
.
assertEqual
(
acc
.
hw
,
(
h
,
w
))
self
.
assertEqual
(
acc
.
nz
,
nz
)
def
test_crop_yx
(
self
):
w
=
256
h
=
512
...
...
@@ -320,8 +339,8 @@ class TestPatchStackAccessor(unittest.TestCase):
# test that this persists after channel selection
for
i
in
range
(
0
,
acc
.
count
):
self
.
assertEqual
(
patches
[
i
].
shape
[
0
:
2
],
acc
.
get_channels
([
0
]).
iat
_data
(
i
,
crop
=
True
).
shape
[
0
:
2
])
self
.
assertEqual
(
patches
[
i
].
shape
[
3
],
acc
.
get_channels
([
0
]).
iat
_data
(
i
,
crop
=
True
).
shape
[
3
])
self
.
assertEqual
(
patches
[
i
].
shape
[
0
:
2
],
acc
.
get_channels
([
0
]).
iat
(
i
,
crop
=
True
).
shape
[
0
:
2
])
self
.
assertEqual
(
patches
[
i
].
shape
[
3
],
acc
.
get_channels
([
0
]).
iat
(
i
,
crop
=
True
).
shape
[
3
])
def
test_write_nonuniform_patches
(
self
):
w
=
256
...
...
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