Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
831d0dda
Commit
831d0dda
authored
Nov 17, 2018
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap albu/albumentations (#399)
parent
a9864bf0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
9 deletions
+31
-9
docs/conf.py
docs/conf.py
+2
-2
docs/modules/dataflow.imgaug.rst
docs/modules/dataflow.imgaug.rst
+3
-1
tensorpack/dataflow/imgaug/external.py
tensorpack/dataflow/imgaug/external.py
+23
-6
tensorpack/utils/develop.py
tensorpack/utils/develop.py
+3
-0
No files found.
docs/conf.py
View file @
831d0dda
...
...
@@ -26,12 +26,12 @@ ON_RTD = (os.environ.get('READTHEDOCS') == 'True')
MOCK_MODULES
=
[
'tabulate'
,
'h5py'
,
'cv2'
,
'zmq'
,
'lmdb'
,
'msgpack'
,
'msgpack_numpy'
,
'pyarrow'
,
'sklearn'
,
'sklearn.datasets'
,
'scipy'
,
'scipy.misc'
,
'scipy.io'
,
'tornado'
,
'tornado.concurrent'
,
'horovod'
,
'horovod.tensorflow'
,
'subprocess32'
,
'functools32'
,
'imgaug'
]
'subprocess32'
,
'functools32'
]
# it's better to have tensorflow installed (for some docs to show)
# but it's OK to mock it as well
...
...
docs/modules/dataflow.imgaug.rst
View file @
831d0dda
...
...
@@ -3,7 +3,9 @@ tensorpack.dataflow.imgaug package
This package contains Tensorpack's augmentors.
Note that other image augmentation libraries can be wrapped into Tensorpack's interface as well.
For example, see `imgaug.IAAugmentor <#tensorpack.dataflow.imgaug.IAAugmentor>`_.
For example, `imgaug.IAAugmentor <#tensorpack.dataflow.imgaug.IAAugmentor>`_
and `imgaug.Albumentations <#tensorpack.dataflow.imgaug.Albumentations`_
wrap two popular image augmentation libraries.
.. container:: custom-index
...
...
tensorpack/dataflow/imgaug/external.py
View file @
831d0dda
...
...
@@ -5,7 +5,7 @@ import numpy as np
from
.base
import
ImageAugmentor
__all__
=
[
'IAAugmentor'
]
__all__
=
[
'IAAugmentor'
,
'Albumentations'
]
class
IAAugmentor
(
ImageAugmentor
):
...
...
@@ -38,6 +38,7 @@ class IAAugmentor(ImageAugmentor):
return
aug
.
augment_image
(
img
)
def
_augment_coords
(
self
,
coords
,
param
):
import
imgaug
as
IA
aug
,
shape
=
param
points
=
[
IA
.
Keypoint
(
x
=
x
,
y
=
y
)
for
x
,
y
in
coords
]
points
=
IA
.
KeypointsOnImage
(
points
,
shape
=
shape
)
...
...
@@ -45,8 +46,24 @@ class IAAugmentor(ImageAugmentor):
return
np
.
asarray
([[
p
.
x
,
p
.
y
]
for
p
in
augmented
])
from
...utils.develop
import
create_dummy_class
# noqa
try
:
import
imgaug
as
IA
except
ImportError
:
IAAugmentor
=
create_dummy_class
(
'IAAugmentor'
,
'imgaug'
)
# noqa
class
Albumentations
(
ImageAugmentor
):
"""
Wrap an augmentor form the albumentations library: https://github.com/albu/albumentations
Coordinate augmentation is not supported by the library.
"""
def
__init__
(
self
,
augmentor
):
"""
Args:
augmentor (albumentations.BasicTransform):
"""
super
(
Albumentations
,
self
)
.
__init__
()
self
.
_aug
=
augmentor
def
_get_augment_params
(
self
,
img
):
return
self
.
_aug
.
get_params
()
def
_augment
(
self
,
img
,
param
):
return
self
.
_aug
.
apply
(
img
,
**
param
)
def
_augment_coords
(
self
,
coords
,
param
):
raise
NotImplementedError
()
tensorpack/utils/develop.py
View file @
831d0dda
...
...
@@ -29,6 +29,7 @@ def create_dummy_class(klass, dependency):
Returns:
class: a class object
"""
assert
not
building_rtfd
()
class
_DummyMetaClass
(
type
):
# throw error on class attribute access
...
...
@@ -55,6 +56,8 @@ def create_dummy_func(func, dependency):
Returns:
function: a function object
"""
assert
not
building_rtfd
()
if
isinstance
(
dependency
,
(
list
,
tuple
)):
dependency
=
','
.
join
(
dependency
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment