Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qim3d
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
QIM
Tools
qim3d
Commits
9d72262c
Commit
9d72262c
authored
1 month ago
by
s193396
Browse files
Options
Downloads
Patches
Plain Diff
fixed docstring for augmentations
parent
505419af
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
qim3d/ml/__init__.py
+2
-2
2 additions, 2 deletions
qim3d/ml/__init__.py
qim3d/ml/_augmentations.py
+17
-20
17 additions, 20 deletions
qim3d/ml/_augmentations.py
with
19 additions
and
22 deletions
qim3d/ml/__init__.py
+
2
−
2
View file @
9d72262c
from
._augmentations
import
Augmentation
from
._data
import
Dataset
,
prepare_data
loader
s
,
prepare_data
set
s
from
._ml_utils
import
inference
,
volume_inference
,
model_summary
,
train_model
from
._data
import
Dataset
,
prepare_data
set
s
,
prepare_data
loader
s
from
._ml_utils
import
model_summary
,
train_model
,
inference
from
.models
import
*
\ No newline at end of file
This diff is collapsed.
Click to expand it.
qim3d/ml/_augmentations.py
+
17
−
20
View file @
9d72262c
...
...
@@ -6,34 +6,30 @@ class Augmentation:
Args:
resize (str, optional): Specifies how the images should be reshaped to the appropriate size.
trainsform_train (str, optional): level of transformation for the training set.
transform_validation (str, optional): level of transformation for the validation set.
transform_test (str, optional): level of transformation for the test set.
mean (float, optional): The mean value for normalizing pixel intensities.
std (float, optional): The standard deviation value for normalizing pixel intensities.
trainsform_train (str, optional): Level of transformation for the training set.
transform_validation (str, optional): Level of transformation for the validation set.
transform_test (str, optional): Level of transformation for the test set.
Raises:
ValueError: If the ´resize´ is neither
'
crop
'
,
'
resize
'
or
'
padding
'
.
ValueError: If the ´resize´ is neither
'
crop
'
,
'
resize
'
n
or
'
padding
'
.
Example:
my_augmentation = Augmentation(resize =
'
crop
'
, transform_train =
'
heavy
'
)
my_augmentation = Augmentation(resize =
'
crop
'
, transform_train =
'
light
'
)
"""
def
__init__
(
self
,
resize
:
str
=
'
crop
'
,
transform_train
:
str
=
'
moderate
'
,
transform_validation
:
str
|
None
=
None
,
transform_test
:
str
|
None
=
None
,
mean
:
float
=
0.5
,
std
:
float
=
0.5
,
):
def
__init__
(
self
,
resize
:
str
=
'
crop
'
,
transform_train
:
str
=
'
moderate
'
,
transform_validation
:
str
|
None
=
None
,
transform_test
:
str
|
None
=
None
,
):
if
resize
not
in
[
'
crop
'
,
'
reshape
'
,
'
padding
'
]:
raise
ValueError
(
f
"
Invalid resize type:
{
resize
}
. Use either
'
crop
'
,
'
resize
'
or
'
padding
'
.
"
)
msg
=
f
"
Invalid resize type:
{
resize
}
. Use either
'
crop
'
,
'
resize
'
or
'
padding
'
.
"
raise
ValueError
(
msg
)
self
.
resize
=
resize
self
.
mean
=
mean
self
.
std
=
std
self
.
transform_train
=
transform_train
self
.
transform_validation
=
transform_validation
self
.
transform_test
=
transform_test
...
...
@@ -47,7 +43,8 @@ class Augmentation:
level (str, optional): Level of augmentation. One of [None,
'
light
'
,
'
moderate
'
,
'
heavy
'
].
Raises:
ValueError: If `level` is neither None, light, moderate nor heavy.
ValueError: If `img_shape` is not 3D.
ValueError: If `level` is neither None,
'
light
'
,
'
moderate
'
nor
'
heavy
'
.
"""
from
monai.transforms
import
(
Compose
,
RandRotate90d
,
RandFlipd
,
RandAffined
,
ToTensor
,
\
...
...
@@ -69,7 +66,7 @@ class Augmentation:
# Baseline augmentations
# TODO: Figure out how to properly do normalization in 3D (normalization should be done channel-wise)
baseline_aug
=
[
ToTensor
()]
baseline_aug
=
[
ToTensor
()]
#, NormalizeIntensityd(keys=["image"])]
# Resize augmentations
if
self
.
resize
==
'
crop
'
:
...
...
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