Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mu-map
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tamino Huxohl
mu-map
Commits
82eb0bf4
Commit
82eb0bf4
authored
2 years ago
by
Tamino Huxohl
Browse files
Options
Downloads
Patches
Plain Diff
fix parameter updates to patch dataset
parent
c4ac5562
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
mu_map/dataset/patches.py
+33
-9
33 additions, 9 deletions
mu_map/dataset/patches.py
with
33 additions
and
9 deletions
mu_map/dataset/patches.py
+
33
−
9
View file @
82eb0bf4
...
@@ -37,6 +37,7 @@ class MuMapPatchDataset(MuMapDataset):
...
@@ -37,6 +37,7 @@ class MuMapPatchDataset(MuMapDataset):
self
.
patches_per_image
=
patches_per_image
self
.
patches_per_image
=
patches_per_image
self
.
patch_size
=
patch_size
self
.
patch_size
=
patch_size
self
.
patch_size_z
=
patch_size_z
self
.
patch_size_z
=
patch_size_z
self
.
patch_offset
=
patch_offset
self
.
shuffle
=
shuffle
self
.
shuffle
=
shuffle
self
.
patches
=
[]
self
.
patches
=
[]
...
@@ -57,8 +58,14 @@ class MuMapPatchDataset(MuMapDataset):
...
@@ -57,8 +58,14 @@ class MuMapPatchDataset(MuMapDataset):
z_range
=
(
0
,
max
(
recon
.
shape
[
0
]
-
self
.
patch_size_z
,
0
))
z_range
=
(
0
,
max
(
recon
.
shape
[
0
]
-
self
.
patch_size_z
,
0
))
# sometimes the mu_maps have fewer than 32 slices
# sometimes the mu_maps have fewer than 32 slices
# in this case the z-axis will be padded to the patch size, but this means we only have a single option for z
# in this case the z-axis will be padded to the patch size, but this means we only have a single option for z
y_range
=
(
20
,
recon
.
shape
[
1
]
-
self
.
patch_size
-
20
)
y_range
=
(
x_range
=
(
20
,
recon
.
shape
[
2
]
-
self
.
patch_size
-
20
)
self
.
patch_offset
,
recon
.
shape
[
1
]
-
self
.
patch_size
-
self
.
patch_offset
,
)
x_range
=
(
self
.
patch_offset
,
recon
.
shape
[
2
]
-
self
.
patch_size
-
self
.
patch_offset
,
)
# compute padding for z axis
# compute padding for z axis
padding
=
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
]
padding
=
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
]
...
@@ -103,27 +110,44 @@ if __name__ == "__main__":
...
@@ -103,27 +110,44 @@ if __name__ == "__main__":
from
mu_map.util
import
to_grayscale
,
grayscale_to_rgb
from
mu_map.util
import
to_grayscale
,
grayscale_to_rgb
param_keys
=
list
(
MuMapPatchDataset
.
__init__
.
__annotations__
.
keys
())[
1
:]
param_keys
=
list
(
MuMapPatchDataset
.
__init__
.
__annotations__
.
keys
())[
1
:]
param_defaults
=
MuMapPatchDataset
.
__init__
.
__defaults__
[
1
:]
param_defaults
=
MuMapPatchDataset
.
__init__
.
__defaults__
param_help
=
[
"
number of patches for each image
"
,
"
patch size in x- and y-direction
"
,
"
patch size in z-direction
"
,
"
offset to ignore image borders
"
,
"
shuffle the dataset
"
,
]
parser
=
argparse
.
ArgumentParser
(
parser
=
argparse
.
ArgumentParser
(
help
=
"
Visualize the patches in a MuMapPatchDataset
"
,
description
=
"
Visualize the patches in a MuMapPatchDataset
"
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
,
)
)
parser
.
add_argument
(
parser
.
add_argument
(
"
dataset_dir
"
,
"
--
dataset_dir
"
,
type
=
str
,
type
=
str
,
defaul
=
"
data/initial/
"
,
defaul
t
=
"
data/initial/
"
,
help
=
"
the directory of the dataset
"
,
help
=
"
the directory of the dataset
"
,
)
)
for
key
,
_default
in
zip
(
param_keys
,
param_defaults
):
for
key
,
_default
,
_help
in
zip
(
param_keys
,
param_defaults
,
param_help
):
parser
.
add_argument
(
f
"
--
{
key
}
"
,
type
=
type
(
_default
),
default
=
_default
)
parser
.
add_argument
(
f
"
--
{
key
}
"
,
type
=
type
(
_default
),
default
=
_default
,
help
=
_help
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
print
(
args
)
wname
=
"
Dataset
"
wname
=
"
Dataset
"
cv
.
namedWindow
(
wname
,
cv
.
WINDOW_NORMAL
)
cv
.
namedWindow
(
wname
,
cv
.
WINDOW_NORMAL
)
cv
.
resizeWindow
(
wname
,
1600
,
900
)
cv
.
resizeWindow
(
wname
,
1600
,
900
)
dataset
=
MuMapPatchDataset
(
"
data/initial/
"
,
patches_per_image
=
1
)
dataset
=
MuMapPatchDataset
(
"
data/initial/
"
,
patches_per_image
=
args
.
patches_per_image
,
patch_size
=
args
.
patch_size
,
patch_size_z
=
args
.
patch_size_z
,
patch_offset
=
args
.
patch_offset
,
shuffle
=
args
.
shuffle
,
)
print
(
f
"
Images (Patches) in the dataset
{
len
(
dataset
)
}
"
)
print
(
f
"
Images (Patches) in the dataset
{
len
(
dataset
)
}
"
)
...
...
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