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
8f917c01
Commit
8f917c01
authored
Mar 15, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove pipedir from zmq. fix resnet rgb/bgr (fix #176)
parent
2d5984db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
9 deletions
+14
-9
examples/ResNet/imagenet-resnet.py
examples/ResNet/imagenet-resnet.py
+9
-4
tensorpack/dataflow/prefetch.py
tensorpack/dataflow/prefetch.py
+5
-5
No files found.
examples/ResNet/imagenet-resnet.py
View file @
8f917c01
...
@@ -31,6 +31,8 @@ class Model(ModelDesc):
...
@@ -31,6 +31,8 @@ class Model(ModelDesc):
image
,
label
=
inputs
image
,
label
=
inputs
image
=
tf
.
cast
(
image
,
tf
.
float32
)
*
(
1.0
/
255
)
image
=
tf
.
cast
(
image
,
tf
.
float32
)
*
(
1.0
/
255
)
# Wrong mean/std are used for compatibility with pre-trained models.
# Should actually add a RGB-BGR conversion here.
image_mean
=
tf
.
constant
([
0.485
,
0.456
,
0.406
],
dtype
=
tf
.
float32
)
image_mean
=
tf
.
constant
([
0.485
,
0.456
,
0.406
],
dtype
=
tf
.
float32
)
image_std
=
tf
.
constant
([
0.229
,
0.224
,
0.225
],
dtype
=
tf
.
float32
)
image_std
=
tf
.
constant
([
0.229
,
0.224
,
0.225
],
dtype
=
tf
.
float32
)
image
=
(
image
-
image_mean
)
/
image_std
image
=
(
image
-
image_mean
)
/
image_std
...
@@ -159,11 +161,14 @@ def get_data(train_or_test):
...
@@ -159,11 +161,14 @@ def get_data(train_or_test):
[
imgaug
.
Brightness
(
30
,
clip
=
False
),
[
imgaug
.
Brightness
(
30
,
clip
=
False
),
imgaug
.
Contrast
((
0.8
,
1.2
),
clip
=
False
),
imgaug
.
Contrast
((
0.8
,
1.2
),
clip
=
False
),
imgaug
.
Saturation
(
0.4
),
imgaug
.
Saturation
(
0.4
),
# rgb-bgr conversion
imgaug
.
Lighting
(
0.1
,
imgaug
.
Lighting
(
0.1
,
eigval
=
[
0.2175
,
0.0188
,
0.0045
],
eigval
=
[
0.2175
,
0.0188
,
0.0045
][::
-
1
],
eigvec
=
[[
-
0.5675
,
0.7192
,
0.4009
],
eigvec
=
np
.
array
(
[
-
0.5808
,
-
0.0045
,
-
0.8140
],
[[
-
0.5675
,
0.7192
,
0.4009
],
[
-
0.5836
,
-
0.6948
,
0.4203
]]
[
-
0.5808
,
-
0.0045
,
-
0.8140
],
[
-
0.5836
,
-
0.6948
,
0.4203
]],
dtype
=
'float32'
)[::
-
1
,
::
-
1
]
)]),
)]),
imgaug
.
Clip
(),
imgaug
.
Clip
(),
imgaug
.
Flip
(
horiz
=
True
),
imgaug
.
Flip
(
horiz
=
True
),
...
...
tensorpack/dataflow/prefetch.py
View file @
8f917c01
...
@@ -106,16 +106,17 @@ class PrefetchDataZMQ(ProxyDataFlow):
...
@@ -106,16 +106,17 @@ class PrefetchDataZMQ(ProxyDataFlow):
Prefetch data from a DataFlow using multiple processes, with ZMQ for
Prefetch data from a DataFlow using multiple processes, with ZMQ for
communication.
communication.
A local directory is needed to put the ZMQ pipes.
You can set this with env var $TENSORPACK_PIPEDIR if you're running on non-local FS such as NFS or GlusterFS.
Note that this dataflow is not fork-safe. You cannot nest this dataflow
Note that this dataflow is not fork-safe. You cannot nest this dataflow
into another PrefetchDataZMQ or PrefetchData.
into another PrefetchDataZMQ or PrefetchData.
"""
"""
def
__init__
(
self
,
ds
,
nr_proc
=
1
,
pipedir
=
None
,
hwm
=
50
):
def
__init__
(
self
,
ds
,
nr_proc
=
1
,
hwm
=
50
):
"""
"""
Args:
Args:
ds (DataFlow): input DataFlow.
ds (DataFlow): input DataFlow.
nr_proc (int): number of processes to use.
nr_proc (int): number of processes to use.
pipedir (str): a local directory where the pipes should be put.
Useful if you're running on non-local FS such as NFS or GlusterFS.
hwm (int): the zmq "high-water mark" for both sender and receiver.
hwm (int): the zmq "high-water mark" for both sender and receiver.
"""
"""
super
(
PrefetchDataZMQ
,
self
)
.
__init__
(
ds
)
super
(
PrefetchDataZMQ
,
self
)
.
__init__
(
ds
)
...
@@ -128,8 +129,7 @@ class PrefetchDataZMQ(ProxyDataFlow):
...
@@ -128,8 +129,7 @@ class PrefetchDataZMQ(ProxyDataFlow):
self
.
context
=
zmq
.
Context
()
self
.
context
=
zmq
.
Context
()
self
.
socket
=
self
.
context
.
socket
(
zmq
.
PULL
)
self
.
socket
=
self
.
context
.
socket
(
zmq
.
PULL
)
if
pipedir
is
None
:
pipedir
=
os
.
environ
.
get
(
'TENSORPACK_PIPEDIR'
,
'.'
)
pipedir
=
os
.
environ
.
get
(
'TENSORPACK_PIPEDIR'
,
'.'
)
assert
os
.
path
.
isdir
(
pipedir
),
pipedir
assert
os
.
path
.
isdir
(
pipedir
),
pipedir
self
.
pipename
=
"ipc://{}/dataflow-pipe-"
.
format
(
pipedir
.
rstrip
(
'/'
))
+
str
(
uuid
.
uuid1
())[:
6
]
self
.
pipename
=
"ipc://{}/dataflow-pipe-"
.
format
(
pipedir
.
rstrip
(
'/'
))
+
str
(
uuid
.
uuid1
())[:
6
]
self
.
socket
.
set_hwm
(
hwm
)
self
.
socket
.
set_hwm
(
hwm
)
...
...
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