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
ebeaa046
You need to sign in or sign up before continuing.
Commit
ebeaa046
authored
Aug 16, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add BrightnessScale
parent
ca91326d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
11 deletions
+43
-11
.travis.yml
.travis.yml
+5
-2
tensorpack/dataflow/imgaug/imgproc.py
tensorpack/dataflow/imgaug/imgproc.py
+32
-4
tensorpack/utils/viz.py
tensorpack/utils/viz.py
+6
-4
tests/run-tests.sh
tests/run-tests.sh
+0
-1
No files found.
.travis.yml
View file @
ebeaa046
...
@@ -20,10 +20,10 @@ matrix:
...
@@ -20,10 +20,10 @@ matrix:
include
:
include
:
-
os
:
linux
-
os
:
linux
python
:
2.7
python
:
2.7
env
:
TF_VERSION=1.3.0rc
0
TF_TYPE=release
env
:
TF_VERSION=1.3.0rc
2
TF_TYPE=release
-
os
:
linux
-
os
:
linux
python
:
3.5
python
:
3.5
env
:
TF_VERSION=1.3.0rc
0
TF_TYPE=release
env
:
TF_VERSION=1.3.0rc
2
TF_TYPE=release
-
os
:
linux
-
os
:
linux
python
:
2.7
python
:
2.7
env
:
TF_VERSION=1.head TF_TYPE=nightly
env
:
TF_VERSION=1.head TF_TYPE=nightly
...
@@ -55,6 +55,7 @@ script:
...
@@ -55,6 +55,7 @@ script:
-
mkdir -p $HOME/tensorpack_data
-
mkdir -p $HOME/tensorpack_data
-
export TENSORPACK_DATASET=$HOME/tensorpack_data
-
export TENSORPACK_DATASET=$HOME/tensorpack_data
-
$TRAVIS_BUILD_DIR/tests/run-tests.sh
-
$TRAVIS_BUILD_DIR/tests/run-tests.sh
-
cd $TRAVIS_BUILD_DIR
# go back to root so that deploy may work
notifications
:
notifications
:
email
:
email
:
...
@@ -69,6 +70,8 @@ notifications:
...
@@ -69,6 +70,8 @@ notifications:
on_failure
:
always
# options: [always|never|change] default: always
on_failure
:
always
# options: [always|never|change] default: always
on_start
:
never
# options: [always|never|change] default: always
on_start
:
never
# options: [always|never|change] default: always
# see https://docs.travis-ci.com/user/deployment/pypi/
deploy
:
deploy
:
-
provider
:
pypi
-
provider
:
pypi
user
:
ppwwyyxx
user
:
ppwwyyxx
...
...
tensorpack/dataflow/imgaug/imgproc.py
View file @
ebeaa046
...
@@ -7,7 +7,7 @@ from ...utils import logger
...
@@ -7,7 +7,7 @@ from ...utils import logger
import
numpy
as
np
import
numpy
as
np
import
cv2
import
cv2
__all__
=
[
'Hue'
,
'Brightness'
,
'Contrast'
,
'MeanVarianceNormalize'
,
__all__
=
[
'Hue'
,
'Brightness'
,
'
BrightnessScale'
,
'
Contrast'
,
'MeanVarianceNormalize'
,
'GaussianBlur'
,
'Gamma'
,
'Clip'
,
'Saturation'
,
'Lighting'
,
'MinMaxNormalize'
]
'GaussianBlur'
,
'Gamma'
,
'Clip'
,
'Saturation'
,
'Lighting'
,
'MinMaxNormalize'
]
...
@@ -44,17 +44,19 @@ class Hue(ImageAugmentor):
...
@@ -44,17 +44,19 @@ class Hue(ImageAugmentor):
class
Brightness
(
ImageAugmentor
):
class
Brightness
(
ImageAugmentor
):
"""
"""
Randomly adjust brightness
.
Adjust brightness by adding a random number
.
"""
"""
def
__init__
(
self
,
delta
,
clip
=
True
):
def
__init__
(
self
,
delta
,
clip
=
True
):
"""
"""
Randomly add a value within [-delta,delta], and clip in [0,255] if clip is True.
Args:
delta (float): Randomly add a value within [-delta,delta]
clip (bool): clip results to [0,255].
"""
"""
super
(
Brightness
,
self
)
.
__init__
()
super
(
Brightness
,
self
)
.
__init__
()
assert
delta
>
0
assert
delta
>
0
self
.
_init
(
locals
())
self
.
_init
(
locals
())
def
_get_augment_params
(
self
,
img
):
def
_get_augment_params
(
self
,
_
):
v
=
self
.
_rand_range
(
-
self
.
delta
,
self
.
delta
)
v
=
self
.
_rand_range
(
-
self
.
delta
,
self
.
delta
)
return
v
return
v
...
@@ -67,6 +69,32 @@ class Brightness(ImageAugmentor):
...
@@ -67,6 +69,32 @@ class Brightness(ImageAugmentor):
return
img
.
astype
(
old_dtype
)
return
img
.
astype
(
old_dtype
)
class
BrightnessScale
(
ImageAugmentor
):
"""
Adjust brightness by scaling by a random factor.
"""
def
__init__
(
self
,
range
,
clip
=
True
):
"""
Args:
range (tuple): Randomly scale the image by a factor in (range[0], range[1])
clip (bool): clip results to [0,255].
"""
super
(
BrightnessScale
,
self
)
.
__init__
()
self
.
_init
(
locals
())
def
_get_augment_params
(
self
,
_
):
v
=
self
.
_rand_range
(
*
self
.
range
)
return
v
def
_augment
(
self
,
img
,
v
):
old_dtype
=
img
.
dtype
img
=
img
.
astype
(
'float32'
)
img
*=
v
if
self
.
clip
or
old_dtype
==
np
.
uint8
:
img
=
np
.
clip
(
img
,
0
,
255
)
return
img
.
astype
(
old_dtype
)
class
Contrast
(
ImageAugmentor
):
class
Contrast
(
ImageAugmentor
):
"""
"""
Apply ``x = (x - mean) * contrast_factor + mean`` to each channel.
Apply ``x = (x - mean) * contrast_factor + mean`` to each channel.
...
...
tensorpack/utils/viz.py
View file @
ebeaa046
...
@@ -20,7 +20,8 @@ except ImportError:
...
@@ -20,7 +20,8 @@ except ImportError:
__all__
=
[
'pyplot2img'
,
'interactive_imshow'
,
__all__
=
[
'pyplot2img'
,
'interactive_imshow'
,
'stack_patches'
,
'gen_stack_patches'
,
'stack_patches'
,
'gen_stack_patches'
,
'dump_dataflow_images'
,
'intensity_to_rgb'
]
'dump_dataflow_images'
,
'intensity_to_rgb'
,
'draw_boxes'
]
def
pyplot2img
(
plt
):
def
pyplot2img
(
plt
):
...
@@ -356,13 +357,14 @@ def intensity_to_rgb(intensity, cmap='cubehelix', normalize=False):
...
@@ -356,13 +357,14 @@ def intensity_to_rgb(intensity, cmap='cubehelix', normalize=False):
def
draw_boxes
(
im
,
boxes
,
labels
=
None
,
color
=
None
):
def
draw_boxes
(
im
,
boxes
,
labels
=
None
,
color
=
None
):
"""
"""
Args:
Args:
im (np.ndarray): a BGR image. will not be modified
im (np.ndarray): a BGR image. It will not be modified.
boxes (np.ndarray or list[BoxBase]):
boxes (np.ndarray or list[BoxBase]): If an ndarray,
must be of shape Nx4 where the second dimension is [x1, y1, x2, y2].
labels: (list[str] or None)
labels: (list[str] or None)
color: a 3-tuple (in range [0, 255]). By default will choose automatically.
color: a 3-tuple (in range [0, 255]). By default will choose automatically.
Returns:
Returns:
np.ndarray
np.ndarray
: a new image.
"""
"""
FONT
=
cv2
.
FONT_HERSHEY_SIMPLEX
FONT
=
cv2
.
FONT_HERSHEY_SIMPLEX
FONT_SCALE
=
0.4
FONT_SCALE
=
0.4
...
...
tests/run-tests.sh
View file @
ebeaa046
...
@@ -7,6 +7,5 @@ cd $DIR
...
@@ -7,6 +7,5 @@ cd $DIR
export
TF_CPP_MIN_LOG_LEVEL
=
2
export
TF_CPP_MIN_LOG_LEVEL
=
2
python
-m
unittest discover
-v
python
-m
unittest discover
-v
cd
..
# python -m tensorpack.models._test
# python -m tensorpack.models._test
# segfault for no reason (https://travis-ci.org/ppwwyyxx/tensorpack/jobs/217702985)
# segfault for no reason (https://travis-ci.org/ppwwyyxx/tensorpack/jobs/217702985)
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