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
a3736cc9
Commit
a3736cc9
authored
1 month ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
read CSVs via a utility method
parent
a4f81c46
No related branches found
Branches containing commit
No related tags found
2 merge requests
!4
Migrate project from rhodes/model_server to grp-almf/svlt
,
!3
Migrate from rhodes/model_server to grp-almf/svlt repo
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
model_server/base/api.py
+0
-1
0 additions, 1 deletion
model_server/base/api.py
model_server/base/roiset.py
+4
-2
4 additions, 2 deletions
model_server/base/roiset.py
tests/base/test_roiset.py
+3
-3
3 additions, 3 deletions
tests/base/test_roiset.py
with
7 additions
and
6 deletions
model_server/base/api.py
+
0
−
1
View file @
a3736cc9
...
@@ -262,5 +262,4 @@ def list_tasks() -> Dict[str, TaskInfo]:
...
@@ -262,5 +262,4 @@ def list_tasks() -> Dict[str, TaskInfo]:
@app.get
(
'
/phenobase/bounding_box
'
)
@app.get
(
'
/phenobase/bounding_box
'
)
def
get_phenobase_bounding_boxes
()
->
list
:
def
get_phenobase_bounding_boxes
()
->
list
:
# TODO: exception when casting this as list
return
session
.
phenobase
.
list_bounding_boxes
()
return
session
.
phenobase
.
list_bounding_boxes
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
model_server/base/roiset.py
+
4
−
2
View file @
a3736cc9
...
@@ -489,6 +489,9 @@ def insert_level(df: pd.DataFrame, name: str):
...
@@ -489,6 +489,9 @@ def insert_level(df: pd.DataFrame, name: str):
],
],
)
)
def
read_roiset_df
(
csv_path
:
Path
)
->
pd
.
DataFrame
:
return
pd
.
read_csv
(
csv_path
,
header
=
[
0
,
1
],
index_col
=
0
)
class
RoiSet
(
object
):
class
RoiSet
(
object
):
...
@@ -1287,7 +1290,6 @@ class RoiSet(object):
...
@@ -1287,7 +1290,6 @@ class RoiSet(object):
def
acc_obj_ids
(
self
):
def
acc_obj_ids
(
self
):
return
make_object_ids_from_df
(
self
.
_df
,
self
.
acc_raw
.
shape_dict
)
return
make_object_ids_from_df
(
self
.
_df
,
self
.
acc_raw
.
shape_dict
)
# TODO: move to dedicated CSV reader in tests and scripts
@classmethod
@classmethod
def
deserialize
(
cls
,
acc_raw
:
GenericImageDataAccessor
,
where
:
Path
,
prefix
=
'
roiset
'
)
->
Self
:
def
deserialize
(
cls
,
acc_raw
:
GenericImageDataAccessor
,
where
:
Path
,
prefix
=
'
roiset
'
)
->
Self
:
...
@@ -1299,7 +1301,7 @@ class RoiSet(object):
...
@@ -1299,7 +1301,7 @@ class RoiSet(object):
:param prefix: starting prefix of patch mask filenames
:param prefix: starting prefix of patch mask filenames
:return: RoiSet object
:return: RoiSet object
"""
"""
df
=
pd
.
read_
csv
(
where
/
'
dataframe
'
/
(
prefix
+
'
.csv
'
)
,
header
=
[
0
,
1
],
index_col
=
0
)
df
=
read_
roiset_df
(
where
/
'
dataframe
'
/
(
prefix
+
'
.csv
'
))
df
.
index
.
name
=
'
label
'
df
.
index
.
name
=
'
label
'
pa_masks
=
where
/
'
tight_patch_masks
'
pa_masks
=
where
/
'
tight_patch_masks
'
is_3d
=
is_df_3d
(
df
)
is_3d
=
is_df_3d
(
df
)
...
...
This diff is collapsed.
Click to expand it.
tests/base/test_roiset.py
+
3
−
3
View file @
a3736cc9
...
@@ -7,7 +7,7 @@ from pathlib import Path
...
@@ -7,7 +7,7 @@ from pathlib import Path
import
pandas
as
pd
import
pandas
as
pd
from
model_server.base.process
import
smooth
from
model_server.base.process
import
smooth
from
model_server.base.roiset
import
filter_df_overlap_bbox
,
filter_df_overlap_seg
,
IntensityThresholdInstanceMaskSegmentationModel
,
RoiSet
,
RoiSetExportParams
,
RoiSetMetaParams
from
model_server.base.roiset
import
filter_df_overlap_bbox
,
filter_df_overlap_seg
,
IntensityThresholdInstanceMaskSegmentationModel
,
read_roiset_df
,
RoiSet
,
RoiSetExportParams
,
RoiSetMetaParams
from
model_server.base.accessors
import
generate_file_accessor
,
InMemoryDataAccessor
,
PatchStack
,
write_accessor_data_to_file
from
model_server.base.accessors
import
generate_file_accessor
,
InMemoryDataAccessor
,
PatchStack
,
write_accessor_data_to_file
import
model_server.conf.testing
as
conf
import
model_server.conf.testing
as
conf
from
model_server.conf.testing
import
DummyInstanceMaskSegmentationModel
from
model_server.conf.testing
import
DummyInstanceMaskSegmentationModel
...
@@ -661,7 +661,7 @@ class TestRoiSetMultichannelProducts(BaseTestRoiSetMonoProducts, unittest.TestCa
...
@@ -661,7 +661,7 @@ class TestRoiSetMultichannelProducts(BaseTestRoiSetMonoProducts, unittest.TestCa
self
.
assertTrue
((
where
/
v
).
exists
())
self
.
assertTrue
((
where
/
v
).
exists
())
# test on paths in CSV
# test on paths in CSV
test_df
=
pd
.
read_
csv
(
where
/
res
[
'
dataframe
'
]
,
header
=
[
0
,
1
],
index_col
=
0
)
test_df
=
read_
roiset_df
(
where
/
res
[
'
dataframe
'
])
for
c
in
[
'
tight_patch_masks_path
'
,
'
patches_2d_path
'
,
'
patches_2d_annotated_path
'
]:
for
c
in
[
'
tight_patch_masks_path
'
,
'
patches_2d_path
'
,
'
patches_2d_annotated_path
'
]:
self
.
assertTrue
(
c
in
test_df
.
patches
.
columns
)
self
.
assertTrue
(
c
in
test_df
.
patches
.
columns
)
for
f
in
test_df
.
patches
[
c
]:
for
f
in
test_df
.
patches
[
c
]:
...
@@ -818,7 +818,7 @@ class TestRoiSetSerialization(unittest.TestCase):
...
@@ -818,7 +818,7 @@ class TestRoiSetSerialization(unittest.TestCase):
ref_roiset
.
serialize
(
where_ser
,
prefix
=
'
ref
'
)
ref_roiset
.
serialize
(
where_ser
,
prefix
=
'
ref
'
)
where_df
=
where_ser
/
'
dataframe
'
/
'
ref.csv
'
where_df
=
where_ser
/
'
dataframe
'
/
'
ref.csv
'
self
.
assertTrue
(
where_df
.
exists
())
self
.
assertTrue
(
where_df
.
exists
())
df_test
=
pd
.
read_
csv
(
where_df
,
header
=
[
0
,
1
],
index_col
=
0
)
df_test
=
read_
roiset_df
(
where_df
)
# check that patches are correct size
# check that patches are correct size
where_patch_masks
=
where_ser
/
'
tight_patch_masks
'
where_patch_masks
=
where_ser
/
'
tight_patch_masks
'
...
...
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