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
83dc4a79
Commit
83dc4a79
authored
11 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Now just running into broadcast errors, presumably on patch mask boundaries
parent
b312c89c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!18
Completed (de)serialization of RoiSet
,
!16
Completed (de)serialization of RoiSet
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
model_server/base/roiset.py
+11
-5
11 additions, 5 deletions
model_server/base/roiset.py
tests/test_roiset.py
+35
-0
35 additions, 0 deletions
tests/test_roiset.py
with
46 additions
and
5 deletions
model_server/base/roiset.py
+
11
−
5
View file @
83dc4a79
...
...
@@ -223,13 +223,19 @@ class RoiSet(object):
acc_raw
:
GenericImageDataAccessor
,
df
:
pd
.
DataFrame
,
patch_masks
:
dict
,
# dict of ndarray, where key is integer label
params
:
RoiSetMetaParams
=
RoiSetMetaParams
(),
):
assert
len
(
df
)
==
len
(
patch_masks
)
se_patch_masks
=
pd
.
Series
(
patch_masks
)
# df_merged = pd.merge(df, se_patch_masks)
assert
all
(
patch_masks
.
keys
())
assert
df
.
apply
(
lambda
x
:
x
,
axis
=
1
)
assert
False
zmask
=
np
.
zeros
((
*
acc_raw
.
hw
,
1
,
acc_raw
.
nz
),
dtype
=
bool
)
def
_label_obj
(
r
):
sl
=
np
.
s_
[
r
.
ebb_y0
:
r
.
ebb_y1
,
r
.
ebb_x0
:
r
.
ebb_x1
,
:,
r
.
zi
:
r
.
zi
+
1
]
zmask
[
sl
]
=
patch_masks
[
r
.
label
]
df
.
apply
(
lambda
x
:
_label_obj
(
x
),
axis
=
1
)
obj_ids
=
_get_label_ids
(
zmask
,
allow_3d
=
True
,
connect_3d
=
False
)
return
RoiSet
(
acc_raw
,
obj_ids
,
params
)
@staticmethod
def
filter_df
(
df
:
pd
.
DataFrame
,
filters
:
RoiFilter
=
None
)
->
pd
.
DataFrame
:
...
...
This diff is collapsed.
Click to expand it.
tests/test_roiset.py
+
35
−
0
View file @
83dc4a79
...
...
@@ -3,6 +3,8 @@ import unittest
import
numpy
as
np
from
pathlib
import
Path
import
pandas
as
pd
from
model_server.conf.testing
import
output_path
,
roiset_test_data
from
model_server.base.roiset
import
RoiSetExportParams
,
RoiSetMetaParams
...
...
@@ -303,3 +305,36 @@ class TestRoiSetFromZmask(unittest.TestCase):
)
self
.
assertEqual
(
roiset
.
count
,
id_map
.
data
.
max
())
self
.
assertGreater
(
len
(
roiset
.
get_df
()[
'
zi
'
].
unique
()),
1
)
return
roiset
def
test_create_roiset_from_df_and_patch_masks
(
self
):
ref_roiset
=
self
.
test_create_roiset_from_2d_obj_ids
()
res
=
ref_roiset
.
run_exports
(
output_path
/
'
roiset_from_3d
'
,
roiset_test_data
[
'
pipeline_params
'
][
'
segmentation_channel
'
],
'
ref
'
,
params
=
RoiSetExportParams
(
patch_masks
=
{
'
pad_to
'
:
256
},
dataframe
=
True
)
)
where_df
=
output_path
/
'
roiset_from_3d
'
/
'
dataframe
'
/
'
ref.csv
'
self
.
assertTrue
(
where_df
.
exists
())
df_test
=
pd
.
read_csv
(
where_df
)
# zmask = np.zeros((*self.stack.hw, 1, self.stack.nz), dtype=bool)
print
(
'
hi
'
)
fn
=
output_path
/
'
roiset_from_3d
'
/
'
patch_masks
'
/
'
ref-la{:04d}-zi{:04d}.png
'
patch_masks
=
{}
def
_label_obj
(
r
):
sl
=
np
.
s_
[
r
.
ebb_y0
:
r
.
ebb_y1
,
r
.
ebb_x0
:
r
.
ebb_x1
,
:,
r
.
zi
:
r
.
zi
+
1
]
self
.
assertEqual
(
str
(
sl
),
r
.
slice
)
patch_masks
[
r
.
label
]
=
generate_file_accessor
(
str
(
fn
).
format
(
r
.
label
,
r
.
zi
)).
data
# zmask[sl] = True
df_test
.
apply
(
lambda
x
:
_label_obj
(
x
),
axis
=
1
)
roiset_test
=
RoiSet
.
from_df_and_patch_masks
(
self
.
stack
,
df_test
,
patch_masks
)
print
(
''
)
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