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
ee2d250e
Commit
ee2d250e
authored
4 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Method to test whether accessor can be used as a mask
parent
ce351a1b
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
+3
-0
3 additions, 0 deletions
model_server/base/accessors.py
tests/base/test_accessors.py
+18
-1
18 additions, 1 deletion
tests/base/test_accessors.py
with
21 additions
and
1 deletion
model_server/base/accessors.py
+
3
−
0
View file @
ee2d250e
...
...
@@ -41,6 +41,9 @@ class GenericImageDataAccessor(ABC):
def
is_mask
(
self
):
return
is_mask
(
self
.
_data
)
def
can_mask
(
self
,
acc
):
return
self
.
is_mask
()
and
self
.
shape
==
acc
.
get_mono
(
0
).
shape
def
get_channels
(
self
,
channels
:
list
,
mip
:
bool
=
False
):
carr
=
[
int
(
c
)
for
c
in
channels
]
if
mip
:
...
...
This diff is collapsed.
Click to expand it.
tests/base/test_accessors.py
+
18
−
1
View file @
ee2d250e
...
...
@@ -336,6 +336,23 @@ class TestPatchStackAccessor(unittest.TestCase):
self
.
assertEqual
(
acc
.
get_mono
(
channel
=
0
,
mip
=
True
).
data_yx
.
shape
,
(
n
,
h
,
w
))
return
acc
def
test_can_mask
(
self
):
w
=
30
h
=
20
n
=
2
nz
=
3
nc
=
3
acc1
=
PatchStack
(
_random_int
(
n
,
h
,
w
,
nc
,
nz
))
acc2
=
PatchStack
(
_random_int
(
n
,
2
*
h
,
w
,
nc
,
nz
))
mask
=
PatchStack
(
_random_int
(
n
,
h
,
w
,
1
,
nz
)
>
0.5
)
self
.
assertFalse
(
acc1
.
is_mask
())
self
.
assertFalse
(
acc2
.
is_mask
())
self
.
assertTrue
(
mask
.
is_mask
())
self
.
assertFalse
(
acc1
.
can_mask
(
acc2
))
self
.
assertFalse
(
acc1
.
can_mask
(
acc2
))
self
.
assertTrue
(
mask
.
can_mask
(
acc1
))
self
.
assertFalse
(
mask
.
can_mask
(
acc2
))
def
test_object_df
(
self
):
w
=
30
h
=
20
...
...
@@ -343,7 +360,7 @@ class TestPatchStackAccessor(unittest.TestCase):
nz
=
3
nc
=
3
acc
=
PatchStack
(
_random_int
(
n
,
h
,
w
,
nc
,
nz
))
mask_data
=
np
.
zeros
((
n
,
h
,
w
,
nc
,
nz
),
dtype
=
'
uint8
'
)
mask_data
=
np
.
zeros
((
n
,
h
,
w
,
1
,
nz
),
dtype
=
'
uint8
'
)
mask_data
[
0
,
0
:
5
,
0
:
5
,
:,
:]
=
255
mask_data
[
1
,
0
:
10
,
0
:
10
,
:,
:]
=
255
mask
=
PatchStack
(
mask_data
)
...
...
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