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
a97508f8
You need to sign in or sign up before continuing.
Commit
a97508f8
authored
Feb 26, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixedcrop aug
parent
59b16fa9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
13 deletions
+25
-13
tensorpack/dataflow/imgaug/crop.py
tensorpack/dataflow/imgaug/crop.py
+9
-12
tensorpack/dataflow/imgaug/noname.py
tensorpack/dataflow/imgaug/noname.py
+16
-1
No files found.
tensorpack/dataflow/imgaug/crop.py
View file @
a97508f8
...
...
@@ -4,9 +4,8 @@
# Author: Yuxin Wu <ppwwyyxx@gmail.com>
from
.base
import
ImageAugmentor
import
cv2
__all__
=
[
'RandomCrop'
,
'CenterCrop'
,
'
Resize
'
]
__all__
=
[
'RandomCrop'
,
'CenterCrop'
,
'
FixedCrop
'
]
class
RandomCrop
(
ImageAugmentor
):
""" Randomly crop the image into a smaller one """
...
...
@@ -38,16 +37,14 @@ class CenterCrop(ImageAugmentor):
if
img
.
coords
:
raise
NotImplementedError
()
class
Resize
(
ImageAugmentor
):
"""Resize image to a target size"""
def
__init__
(
self
,
shape
):
"""
Args:
shape: (h, w)
"""
class
FixedCrop
(
ImageAugmentor
):
""" Crop a rectangle at a given location"""
def
__init__
(
self
,
rangex
,
rangey
):
self
.
_init
(
locals
())
def
_augment
(
self
,
img
):
img
.
arr
=
cv2
.
resize
(
img
.
arr
,
self
.
shape
[::
-
1
],
interpolation
=
cv2
.
INTER_CUBIC
)
orig_shape
=
img
.
arr
.
shape
img
.
arr
=
img
.
arr
[
self
.
rangey
[
0
]:
self
.
rangey
[
1
],
self
.
rangex
[
0
]:
self
.
rangex
[
1
]]
if
img
.
coords
:
raise
NotImplementedError
()
tensorpack/dataflow/imgaug/noname.py
View file @
a97508f8
...
...
@@ -7,7 +7,7 @@ from .base import ImageAugmentor
import
numpy
as
np
import
cv2
__all__
=
[
'Flip'
,
'MapImage'
]
__all__
=
[
'Flip'
,
'MapImage'
,
'Resize'
]
class
Flip
(
ImageAugmentor
):
def
__init__
(
self
,
horiz
=
False
,
vert
=
False
,
prob
=
0.5
):
...
...
@@ -40,3 +40,18 @@ class MapImage(ImageAugmentor):
def
_augment
(
self
,
img
):
img
.
arr
=
self
.
func
(
img
.
arr
)
class
Resize
(
ImageAugmentor
):
"""Resize image to a target size"""
def
__init__
(
self
,
shape
):
"""
Args:
shape: (h, w)
"""
self
.
_init
(
locals
())
def
_augment
(
self
,
img
):
img
.
arr
=
cv2
.
resize
(
img
.
arr
,
self
.
shape
[::
-
1
],
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