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
44de964a
Commit
44de964a
authored
Oct 30, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lighting augmentation
parent
2246ab81
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
1 deletion
+28
-1
tensorpack/dataflow/imgaug/imgproc.py
tensorpack/dataflow/imgaug/imgproc.py
+28
-1
No files found.
tensorpack/dataflow/imgaug/imgproc.py
View file @
44de964a
...
@@ -118,8 +118,9 @@ class Clip(ImageAugmentor):
...
@@ -118,8 +118,9 @@ class Clip(ImageAugmentor):
return
img
return
img
class
Saturation
(
ImageAugmentor
):
class
Saturation
(
ImageAugmentor
):
""" Saturation, see 'fb.resnet.torch' https://github.com/facebook/fb.resnet.torch/blob/master/datasets/transforms.lua#L218"""
def
__init__
(
self
,
alpha
=
0.4
):
def
__init__
(
self
,
alpha
=
0.4
):
""" Saturation, see 'fb.resnet.torch' https://github.com/facebook/fb.resnet.torch/blob/master/datasets/transforms.lua#L218
"""
super
(
Saturation
,
self
)
.
__init__
()
super
(
Saturation
,
self
)
.
__init__
()
assert
alpha
<
1
assert
alpha
<
1
self
.
_init
(
locals
())
self
.
_init
(
locals
())
...
@@ -130,3 +131,29 @@ class Saturation(ImageAugmentor):
...
@@ -130,3 +131,29 @@ class Saturation(ImageAugmentor):
def
_augment
(
self
,
img
,
v
):
def
_augment
(
self
,
img
,
v
):
grey
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2GRAY
)
grey
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2GRAY
)
return
img
*
v
+
(
grey
*
(
1
-
v
))[:,:,
np
.
newaxis
]
return
img
*
v
+
(
grey
*
(
1
-
v
))[:,:,
np
.
newaxis
]
class
Lighting
(
ImageAugmentor
):
def
__init__
(
self
,
std
,
eigval
,
eigvec
):
""" Lighting noise.
See `ImageNet Classification with Deep Convolutional Neural Networks - Alex`
The implementation follows 'fb.resnet.torch': https://github.com/facebook/fb.resnet.torch/blob/master/datasets/transforms.lua#L184
:param eigvec: each column is one eigen vector
"""
eigval
=
np
.
asarray
(
eigval
)
eigvec
=
np
.
asarray
(
eigvec
)
assert
eigval
.
shape
==
(
3
,)
assert
eigvec
.
shape
==
(
3
,
3
)
self
.
_init
(
locals
())
def
_get_augment_params
(
self
,
img
):
assert
img
.
shape
[
2
]
==
3
return
self
.
rng
.
randn
(
3
)
*
self
.
std
def
_augment
(
self
,
img
,
v
):
v
=
v
*
self
.
eigval
v
=
v
.
reshape
((
3
,
1
))
inc
=
np
.
dot
(
self
.
eigvec
,
v
)
.
reshape
((
3
,))
img
+=
inc
return
img
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