Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PySegCNN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
earth_observation_public
PySegCNN
Commits
a1de5111
Commit
a1de5111
authored
4 years ago
by
Frisinghelli Daniel
Browse files
Options
Downloads
Patches
Plain Diff
Added a new module for future optional data augmentation methods
parent
1ea45d73
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pytorch/transforms.py
+71
-0
71 additions, 0 deletions
pytorch/transforms.py
with
71 additions
and
0 deletions
pytorch/transforms.py
0 → 100644
+
71
−
0
View file @
a1de5111
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 17 15:28:18 2020
@author: Daniel
"""
# externals
import
numpy
as
np
from
scipy
import
ndimage
class
Transformation
(
object
):
def
__init__
(
self
):
pass
def
apply
(
self
,
image
):
raise
NotImplementedError
class
VariantTransformation
(
Transformation
):
def
__init__
(
self
):
# requires transformation on the ground thruth
self
.
invariant
=
False
class
InvariantTransformation
(
Transformation
):
def
__init__
(
self
):
# transformation on the ground truth not required
self
.
invariant
=
True
class
FlipLr
(
VariantTransformation
):
def
__init__
(
self
):
super
().
__init__
()
def
apply
(
self
,
image
):
return
np
.
asarray
(
image
)[...,
::
-
1
]
class
FlipUd
(
VariantTransformation
):
def
__init__
(
self
):
super
().
__init__
()
def
_transform
(
self
,
image
):
return
np
.
asarray
(
image
)[...,
::
-
1
,
:]
class
Rotate
(
VariantTransformation
):
def
__init__
(
self
):
super
().
__init__
()
def
apply
(
self
,
image
,
angle
):
# check dimension of input image
ndim
=
np
.
asarray
(
image
).
ndim
# axes defining the rotational plane
rot_axes
=
(
0
,
1
)
if
ndim
>
2
:
rot_axes
=
(
ndim
-
2
,
ndim
-
1
)
return
ndimage
.
rotate
(
image
,
angle
,
axes
=
rot_axes
,
reshape
=
False
)
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