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
e2261920
Commit
e2261920
authored
Jan 31, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix linearwrap + tf function
parent
31236d84
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
8 deletions
+21
-8
examples/GAN/Image2Image.py
examples/GAN/Image2Image.py
+2
-1
tensorpack/dataflow/image.py
tensorpack/dataflow/image.py
+16
-6
tensorpack/models/linearwrap.py
tensorpack/models/linearwrap.py
+3
-1
No files found.
examples/GAN/Image2Image.py
View file @
e2261920
...
...
@@ -155,6 +155,8 @@ def split_input(img):
def
colorization_input
(
img
):
assert
img
.
ndim
==
3
if
min
(
img
.
shape
[:
2
])
<
SHAPE
:
return
None
# skip the image
# create gray + RGB pairs
gray
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_RGB2GRAY
)[:,
:,
np
.
newaxis
]
return
[
gray
,
img
]
...
...
@@ -162,7 +164,6 @@ def colorization_input(img):
def
get_data
():
datadir
=
args
.
data
# assume each image is 512x256 split to left and right
imgs
=
glob
.
glob
(
os
.
path
.
join
(
datadir
,
'*.jpg'
))
ds
=
ImageFromFile
(
imgs
,
channel
=
3
,
shuffle
=
True
)
...
...
tensorpack/dataflow/image.py
View file @
e2261920
...
...
@@ -7,6 +7,7 @@ import cv2
from
.base
import
RNGDataFlow
from
.common
import
MapDataComponent
,
MapData
from
.imgaug
import
AugmentorList
from
..utils
import
logger
__all__
=
[
'ImageFromFile'
,
'AugmentImageComponent'
,
'AugmentImageComponents'
]
...
...
@@ -81,14 +82,23 @@ class AugmentImageComponents(MapData):
"""
self
.
augs
=
AugmentorList
(
augmentors
)
self
.
ds
=
ds
self
.
_nr_error
=
0
def
func
(
dp
):
im
=
dp
[
index
[
0
]]
im
,
prms
=
self
.
augs
.
_augment_return_params
(
im
)
dp
[
index
[
0
]]
=
im
for
idx
in
index
[
1
:]:
dp
[
idx
]
=
self
.
augs
.
_augment
(
dp
[
idx
],
prms
)
return
dp
try
:
im
=
dp
[
index
[
0
]]
im
,
prms
=
self
.
augs
.
_augment_return_params
(
im
)
dp
[
index
[
0
]]
=
im
for
idx
in
index
[
1
:]:
dp
[
idx
]
=
self
.
augs
.
_augment
(
dp
[
idx
],
prms
)
return
dp
except
KeyboardInterrupt
:
raise
except
Exception
:
self
.
_nr_error
+=
1
if
self
.
_nr_error
%
1000
==
0
:
logger
.
warn
(
"Got {} augmentation errors."
.
format
(
self
.
_nr_error
))
return
None
super
(
AugmentImageComponents
,
self
)
.
__init__
(
ds
,
func
)
...
...
tensorpack/models/linearwrap.py
View file @
e2261920
...
...
@@ -60,7 +60,9 @@ class LinearWrap(object):
logger
.
warn
(
"You're calling LinearWrap.__getattr__ with {}:"
" neither a layer nor 'tf'!"
.
format
(
layer_name
))
assert
isinstance
(
layer
,
ModuleType
)
import
tensorflow
as
tf
# noqa
layer
=
eval
(
layer_name
)
assert
isinstance
(
layer
,
ModuleType
),
layer
return
LinearWrap
.
_TFModuleFunc
(
layer
,
self
.
_t
)
def
apply
(
self
,
func
,
*
args
,
**
kwargs
):
...
...
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