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
6aa8ab20
Commit
6aa8ab20
authored
Jul 11, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fix in imgaug
parent
c4b38010
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
6 deletions
+24
-6
examples/DoReFa-Net/svhn-digit-dorefa.py
examples/DoReFa-Net/svhn-digit-dorefa.py
+3
-0
tensorpack/dataflow/imgaug/base.py
tensorpack/dataflow/imgaug/base.py
+1
-1
tensorpack/dataflow/imgaug/crop.py
tensorpack/dataflow/imgaug/crop.py
+12
-2
tensorpack/dataflow/imgaug/noise.py
tensorpack/dataflow/imgaug/noise.py
+3
-3
tensorpack/dataflow/imgaug/noname.py
tensorpack/dataflow/imgaug/noname.py
+5
-0
No files found.
examples/DoReFa-Net/svhn-digit-dorefa.py
View file @
6aa8ab20
...
...
@@ -25,6 +25,9 @@ You'll need tcmalloc to avoid large memory consumption: https://github.com/tenso
This config, with (W,A,G)=(1,1,4), can reach 3.1~3.2
%
error after 150 epochs.
With the GaussianDeform augmentor, it will reach 2.8~2.9
%
(we are not using this augmentor in the paper).
with (W,A,G)=(1,2,4), error is 3.0~3.1
%
.
with (W,A,G)=(32,32,32), error is about 2.9
%
.
"""
BITW
=
1
...
...
tensorpack/dataflow/imgaug/base.py
View file @
6aa8ab20
...
...
@@ -61,7 +61,7 @@ class ImageAugmentor(object):
low
,
high
=
0
,
low
if
size
==
None
:
size
=
[]
return
low
+
self
.
rng
.
rand
(
*
size
)
*
(
high
-
low
)
return
self
.
rng
.
uniform
(
low
,
high
,
size
)
class
AugmentorList
(
ImageAugmentor
):
"""
...
...
tensorpack/dataflow/imgaug/crop.py
View file @
6aa8ab20
...
...
@@ -20,8 +20,18 @@ class RandomCrop(ImageAugmentor):
def
_get_augment_params
(
self
,
img
):
orig_shape
=
img
.
shape
h0
=
self
.
rng
.
randint
(
0
,
orig_shape
[
0
]
-
self
.
crop_shape
[
0
])
w0
=
self
.
rng
.
randint
(
0
,
orig_shape
[
1
]
-
self
.
crop_shape
[
1
])
assert
orig_shape
[
0
]
>=
self
.
crop_shape
[
0
]
\
and
orig_shape
[
1
]
>=
self
.
crop_shape
[
1
],
orig_shape
diffh
=
orig_shape
[
0
]
-
self
.
crop_shape
[
0
]
if
diffh
==
0
:
h0
=
0
else
:
h0
=
self
.
rng
.
randint
(
diffh
)
diffw
=
orig_shape
[
1
]
-
self
.
crop_shape
[
1
]
if
diffw
==
0
:
w0
=
0
else
:
w0
=
self
.
rng
.
randint
(
diffw
)
return
(
h0
,
w0
)
def
_augment
(
self
,
img
,
param
):
...
...
tensorpack/dataflow/imgaug/noise.py
View file @
6aa8ab20
...
...
@@ -14,11 +14,11 @@ class JpegNoise(ImageAugmentor):
self
.
_init
(
locals
())
def
_get_augment_params
(
self
,
img
):
return
self
.
_rand_range
(
*
self
.
quality_range
)
return
self
.
rng
.
randint
(
*
self
.
quality_range
)
def
_augment
(
self
,
img
,
q
):
return
cv2
.
imdecode
(
cv2
.
imencode
(
'.jpg'
,
img
,
[
cv2
.
IMWRITE_JPEG_QUALITY
,
q
])[
1
]
,
1
)
enc
=
cv2
.
imencode
(
'.jpg'
,
img
,
[
cv2
.
IMWRITE_JPEG_QUALITY
,
q
])[
1
]
return
cv2
.
imdecode
(
enc
,
1
)
class
GaussianNoise
(
ImageAugmentor
):
...
...
tensorpack/dataflow/imgaug/noname.py
View file @
6aa8ab20
...
...
@@ -3,6 +3,7 @@
# Author: Yuxin Wu <ppwwyyxx@gmail.com>
from
.base
import
ImageAugmentor
from
...utils
import
logger
import
numpy
as
np
import
cv2
...
...
@@ -68,6 +69,7 @@ class RandomResize(ImageAugmentor):
self
.
_init
(
locals
())
def
_get_augment_params
(
self
,
img
):
cnt
=
0
while
True
:
sx
=
self
.
_rand_range
(
*
self
.
xrange
)
sy
=
self
.
_rand_range
(
*
self
.
yrange
)
...
...
@@ -78,6 +80,9 @@ class RandomResize(ImageAugmentor):
diff
=
abs
(
newr
-
oldr
)
/
oldr
if
diff
<=
self
.
aspect_ratio_thres
:
return
(
destX
,
destY
)
cnt
+=
1
if
cnt
>
50
:
logger
.
warn
(
"RandomResize failed to augment an image"
)
def
_augment
(
self
,
img
,
dsize
):
return
cv2
.
resize
(
img
,
dsize
,
interpolation
=
cv2
.
INTER_CUBIC
)
...
...
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