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
18ace72f
Commit
18ace72f
authored
4 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Can create accessor that concatenates two channels
parent
a6e13287
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
+8
-0
8 additions, 0 deletions
model_server/base/accessors.py
tests/base/test_accessors.py
+38
-1
38 additions, 1 deletion
tests/base/test_accessors.py
with
46 additions
and
1 deletion
model_server/base/accessors.py
+
8
−
0
View file @
18ace72f
...
...
@@ -180,6 +180,14 @@ class GenericImageDataAccessor(ABC):
'
filepath
'
:
''
,
}
def
append_channels
(
self
,
acc
):
return
self
.
_derived_accessor
(
np
.
concatenate
(
(
self
.
data
,
acc
.
data
),
axis
=
self
.
_ga
(
'
C
'
)
)
)
class
InMemoryDataAccessor
(
GenericImageDataAccessor
):
def
__init__
(
self
,
data
):
self
.
_data
=
self
.
conform_data
(
data
)
...
...
This diff is collapsed.
Click to expand it.
tests/base/test_accessors.py
+
38
−
1
View file @
18ace72f
...
...
@@ -207,6 +207,27 @@ class TestCziImageFileAccess(unittest.TestCase):
pxs
=
cf
.
pixel_scale_in_micrometers
self
.
assertAlmostEqual
(
pxs
[
'
X
'
],
data
[
'
czifile
'
][
'
um_per_pixel
'
],
places
=
3
)
def
test_append_channels
(
self
):
w
=
256
h
=
512
nc
=
2
nz
=
11
acc1
=
InMemoryDataAccessor
(
np
.
random
.
rand
(
h
,
w
,
nc
,
nz
))
acc2
=
InMemoryDataAccessor
(
np
.
random
.
rand
(
h
,
w
,
nc
,
nz
))
app
=
acc1
.
append_channels
(
acc2
)
self
.
assertEqual
(
app
.
shape
,
(
h
,
w
,
2
*
nc
,
nz
))
self
.
assertTrue
(
np
.
all
(
app
.
get_channels
([
0
,
1
]).
data
==
acc1
.
data
)
)
self
.
assertTrue
(
np
.
all
(
app
.
get_channels
([
2
,
3
]).
data
==
acc2
.
data
)
)
class
TestPatchStackAccessor
(
unittest
.
TestCase
):
def
setUp
(
self
)
->
None
:
...
...
@@ -352,4 +373,20 @@ class TestPatchStackAccessor(unittest.TestCase):
fp
=
output_path
/
'
patch_hyperstack.tif
'
acc
.
export_pyxcz
(
fp
)
acc2
=
make_patch_stack_from_file
(
fp
)
self
.
assertEqual
(
acc
.
shape
,
acc2
.
shape
)
\ No newline at end of file
self
.
assertEqual
(
acc
.
shape
,
acc2
.
shape
)
def
test_append_channels
(
self
):
acc
=
self
.
test_pczyx
()
app
=
acc
.
append_channels
(
acc
)
p
,
h
,
w
,
nc
,
nz
=
acc
.
shape
self
.
assertEqual
(
app
.
shape
,
(
p
,
h
,
w
,
2
*
nc
,
nz
))
self
.
assertTrue
(
np
.
all
(
app
.
get_channels
([
0
,
1
,
2
]).
data
==
acc
.
data
)
)
self
.
assertTrue
(
np
.
all
(
app
.
get_channels
([
3
,
4
,
5
]).
data
==
acc
.
data
)
)
\ 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