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
cf20671e
Commit
cf20671e
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Simplified patch export method
parent
3e7e34c7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
model_server/extensions/chaeo/products.py
+9
-34
9 additions, 34 deletions
model_server/extensions/chaeo/products.py
with
9 additions
and
34 deletions
model_server/extensions/chaeo/products.py
+
9
−
34
View file @
cf20671e
...
...
@@ -92,11 +92,6 @@ def get_patches_from_zmask_meta(
focus_metric
:
str
=
None
,
**
kwargs
)
->
pd
.
DataFrame
:
# patches = []
# for mi in zmask_meta:
# dfe = roiset.get_df().assign(patch=object())
# for i, roi in enumerate(dfe.itertuples()):
def
_make_patch
(
roi
):
patch3d
=
roiset
.
acc_raw
.
data
[
roi
.
slice
]
...
...
@@ -161,41 +156,21 @@ def get_patches_from_zmask_meta(
if
pad_to
:
patch
=
pad
(
patch
,
pad_to
)
# patches.append(patch)
return
patch
# dfe.loc[i, 'patch'] = patch
dfe
=
roiset
.
get_df
()
dfe
[
'
patch
'
]
=
roiset
.
get_df
().
apply
(
lambda
r
:
_make_patch
(
r
),
axis
=
1
)
return
dfe
# if not make_3d and pc == 1:
# return MonoPatchStack(patches)
# else:
# return Multichannel3dPatchStack(patches)
def
export_patches_from_zstack
(
where
:
Path
,
# stack: GenericImageDataAccessor,
# zmask_meta: list,
roiset
,
rescale_clip
:
float
=
0.0
,
pad_to
:
int
=
256
,
make_3d
:
bool
=
False
,
prefix
=
'
patch
'
,
focus_metric
:
str
=
None
,
**
kwargs
):
patches_df
=
get_patches_from_zmask_meta
(
roiset
,
# stack,
# zmask_meta,
# rescale_clip=rescale_clip,
pad_to
=
pad_to
,
make_3d
=
make_3d
,
focus_metric
=
focus_metric
,
**
kwargs
)
make_3d
=
kwargs
.
get
(
'
make_3d
'
,
False
)
patches_df
=
get_patches_from_zmask_meta
(
roiset
,
**
kwargs
)
pc
=
roiset
.
acc_raw
.
chroma
patches
=
list
(
patches_df
[
'
patch
'
])
...
...
@@ -204,13 +179,8 @@ def export_patches_from_zstack(
else
:
patches_acc
=
Multichannel3dPatchStack
(
patches
)
exported
=
[]
for
i
,
roi
in
enumerate
(
roiset
.
get_df
().
itertuples
()):
# just used for label info
# for i in range(0, len(zmask_meta)):
# mi = zmask_meta[i]
def
_export_patch
(
roi
):
patch
=
patches_acc
.
iat_yxcz
(
i
)
# obj = mi['info']
# idx = mi['df_index']
ext
=
'
tif
'
if
make_3d
else
'
png
'
fname
=
f
'
{
prefix
}
-la
{
roi
.
label
:
04
d
}
-zi
{
roi
.
zi
:
04
d
}
.
{
ext
}
'
...
...
@@ -223,6 +193,11 @@ def export_patches_from_zstack(
'
df_index
'
:
roi
.
Index
,
'
patch_filename
'
:
fname
,
})
exported
=
[]
for
i
,
roi
in
enumerate
(
patches_df
.
itertuples
()):
# just used for label info
_export_patch
(
roi
)
return
exported
...
...
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