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
e15332fd
Commit
e15332fd
authored
Dec 28, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove some deprecations
parent
7da83a51
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
90 deletions
+3
-90
docs/conf.py
docs/conf.py
+0
-2
tensorpack/callbacks/steps.py
tensorpack/callbacks/steps.py
+2
-5
tensorpack/dataflow/imgaug/crop.py
tensorpack/dataflow/imgaug/crop.py
+1
-83
No files found.
docs/conf.py
View file @
e15332fd
...
@@ -366,12 +366,10 @@ def autodoc_skip_member(app, what, name, obj, skip, options):
...
@@ -366,12 +366,10 @@ def autodoc_skip_member(app, what, name, obj, skip, options):
if
name
in
[
if
name
in
[
'MultiGPUTrainerBase'
,
'MultiGPUTrainerBase'
,
'get_predictors'
,
'get_predictors'
,
'RandomCropAroundBox'
,
'GaussianDeform'
,
'GaussianDeform'
,
'dump_chkpt_vars'
,
'dump_chkpt_vars'
,
'DumpTensor'
,
'DumpTensor'
,
'StagingInputWrapper'
,
'StagingInputWrapper'
,
'StepTensorPrinter'
,
'set_tower_func'
,
'set_tower_func'
,
'TryResumeTraining'
,
'TryResumeTraining'
,
'LeakyReLU'
,
'LeakyReLU'
,
...
...
tensorpack/callbacks/steps.py
View file @
e15332fd
...
@@ -15,7 +15,7 @@ from ..tfutils.common import (
...
@@ -15,7 +15,7 @@ from ..tfutils.common import (
get_op_tensor_name
,
get_global_step_var
)
get_op_tensor_name
,
get_global_step_var
)
from
.base
import
Callback
from
.base
import
Callback
__all__
=
[
'TensorPrinter'
,
'
StepTensorPrinter'
,
'
ProgressBar'
]
__all__
=
[
'TensorPrinter'
,
'ProgressBar'
]
class
TensorPrinter
(
Callback
):
class
TensorPrinter
(
Callback
):
...
@@ -29,7 +29,7 @@ class TensorPrinter(Callback):
...
@@ -29,7 +29,7 @@ class TensorPrinter(Callback):
names(list): list of string, the names of the tensors to print.
names(list): list of string, the names of the tensors to print.
"""
"""
names
=
[
get_op_tensor_name
(
n
)[
1
]
for
n
in
names
]
names
=
[
get_op_tensor_name
(
n
)[
1
]
for
n
in
names
]
logger
.
warn
(
"Using
print_stat or tf.Print in the graph is much faster than Step
TensorPrinter!"
)
logger
.
warn
(
"Using
tf.Print in the graph is much faster than
TensorPrinter!"
)
self
.
_names
=
names
self
.
_names
=
names
def
_setup_graph
(
self
):
def
_setup_graph
(
self
):
...
@@ -45,9 +45,6 @@ class TensorPrinter(Callback):
...
@@ -45,9 +45,6 @@ class TensorPrinter(Callback):
logger
.
info
(
"{}: {}"
.
format
(
n
,
v
))
logger
.
info
(
"{}: {}"
.
format
(
n
,
v
))
StepTensorPrinter
=
TensorPrinter
class
ProgressBar
(
Callback
):
class
ProgressBar
(
Callback
):
""" A progress bar based on tqdm. Enabled by default. """
""" A progress bar based on tqdm. Enabled by default. """
...
...
tensorpack/dataflow/imgaug/crop.py
View file @
e15332fd
...
@@ -2,17 +2,11 @@
...
@@ -2,17 +2,11 @@
# File: crop.py
# File: crop.py
# Author: Yuxin Wu <ppwwyyxx@gmail.com>
# Author: Yuxin Wu <ppwwyyxx@gmail.com>
from
six.moves
import
range
import
numpy
as
np
from
.base
import
ImageAugmentor
from
...utils.rect
import
IntBox
from
...utils.develop
import
log_deprecated
from
...utils.argtools
import
shape2d
from
...utils.argtools
import
shape2d
from
.transform
import
TransformAugmentorBase
,
CropTransform
from
.transform
import
TransformAugmentorBase
,
CropTransform
__all__
=
[
'RandomCrop'
,
'CenterCrop'
,
'RandomCrop
AroundBox'
,
'RandomCrop
RandomShape'
]
__all__
=
[
'RandomCrop'
,
'CenterCrop'
,
'RandomCropRandomShape'
]
class
RandomCrop
(
TransformAugmentorBase
):
class
RandomCrop
(
TransformAugmentorBase
):
...
@@ -56,78 +50,6 @@ class CenterCrop(TransformAugmentorBase):
...
@@ -56,78 +50,6 @@ class CenterCrop(TransformAugmentorBase):
return
CropTransform
(
h0
,
w0
,
self
.
crop_shape
[
0
],
self
.
crop_shape
[
1
])
return
CropTransform
(
h0
,
w0
,
self
.
crop_shape
[
0
],
self
.
crop_shape
[
1
])
def
perturb_BB
(
image_shape
,
bb
,
max_perturb_pixel
,
rng
=
None
,
max_aspect_ratio_diff
=
0.3
,
max_try
=
100
):
"""
Perturb a bounding box.
Args:
image_shape: [h, w]
bb (IntBox): original bounding box
max_perturb_pixel: perturbation on each coordinate
max_aspect_ratio_diff: result can't have an aspect ratio too different from the original
max_try: if cannot find a valid bounding box, return the original
Returns:
new bounding box
"""
orig_ratio
=
bb
.
h
*
1.0
/
bb
.
w
if
rng
is
None
:
rng
=
np
.
random
.
RandomState
()
for
_
in
range
(
max_try
):
p
=
rng
.
randint
(
-
max_perturb_pixel
,
max_perturb_pixel
,
[
4
])
newbb
=
bb
.
copy
()
newbb
.
x1
+=
p
[
0
]
newbb
.
y1
+=
p
[
1
]
newbb
.
x2
=
bb
.
x2
+
p
[
2
]
newbb
.
y2
=
bb
.
y2
+
p
[
3
]
if
not
newbb
.
is_valid_box
(
image_shape
):
continue
new_ratio
=
newbb
.
h
*
1.0
/
newbb
.
w
diff
=
abs
(
new_ratio
-
orig_ratio
)
if
diff
/
orig_ratio
>
max_aspect_ratio_diff
:
continue
return
newbb
return
bb
# TODO deprecated. shouldn't include strange augmentors like this.
class
RandomCropAroundBox
(
ImageAugmentor
):
"""
Crop a box around a bounding box by some random perturbation.
"""
def
__init__
(
self
,
perturb_ratio
,
max_aspect_ratio_diff
=
0.3
):
"""
Args:
perturb_ratio (float): perturb distance will be in
``[0, perturb_ratio * sqrt(w * h)]``
max_aspect_ratio_diff (float): keep aspect ratio difference within the range
"""
super
(
RandomCropAroundBox
,
self
)
.
__init__
()
log_deprecated
(
"RandomCropAroundBox"
,
"It's neither common nor well-defined. Please implement something by yourself."
,
"2017-11-30"
)
self
.
_init
(
locals
())
def
_get_augment_params
(
self
,
img
):
shape
=
img
.
shape
[:
2
]
box
=
IntBox
(
0
,
0
,
shape
[
1
]
-
1
,
shape
[
0
]
-
1
)
dist
=
self
.
perturb_ratio
*
np
.
sqrt
(
shape
[
0
]
*
shape
[
1
])
newbox
=
perturb_BB
(
shape
,
box
,
dist
,
self
.
rng
,
self
.
max_aspect_ratio_diff
)
return
newbox
def
_augment
(
self
,
img
,
newbox
):
return
newbox
.
roi
(
img
)
def
_augment_coords
(
self
,
coords
,
newbox
):
coords
[:,
0
]
=
coords
[:,
0
]
-
newbox
.
x1
coords
[:,
1
]
=
coords
[:,
1
]
-
newbox
.
y1
return
coords
class
RandomCropRandomShape
(
TransformAugmentorBase
):
class
RandomCropRandomShape
(
TransformAugmentorBase
):
""" Random crop with a random shape"""
""" Random crop with a random shape"""
...
@@ -157,7 +79,3 @@ class RandomCropRandomShape(TransformAugmentorBase):
...
@@ -157,7 +79,3 @@ class RandomCropRandomShape(TransformAugmentorBase):
y0
=
0
if
diffh
==
0
else
self
.
rng
.
randint
(
diffh
)
y0
=
0
if
diffh
==
0
else
self
.
rng
.
randint
(
diffh
)
x0
=
0
if
diffw
==
0
else
self
.
rng
.
randint
(
diffw
)
x0
=
0
if
diffw
==
0
else
self
.
rng
.
randint
(
diffw
)
return
CropTransform
(
y0
,
x0
,
h
,
w
)
return
CropTransform
(
y0
,
x0
,
h
,
w
)
if
__name__
==
'__main__'
:
print
(
perturb_BB
([
100
,
100
],
IntBox
(
3
,
3
,
50
,
50
),
50
))
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