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
5cdf1d33
Commit
5cdf1d33
authored
Apr 20, 2018
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better picklability for "spawn" mp context
parent
fa0f57da
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
37 deletions
+42
-37
tensorpack/dataflow/common.py
tensorpack/dataflow/common.py
+11
-10
tensorpack/dataflow/image.py
tensorpack/dataflow/image.py
+28
-26
tensorpack/dataflow/parallel.py
tensorpack/dataflow/parallel.py
+3
-1
No files found.
tensorpack/dataflow/common.py
View file @
5cdf1d33
...
@@ -295,16 +295,17 @@ class MapDataComponent(MapData):
...
@@ -295,16 +295,17 @@ class MapDataComponent(MapData):
return None to discard this datapoint.
return None to discard this datapoint.
index (int): index of the component.
index (int): index of the component.
"""
"""
index
=
int
(
index
)
self
.
_index
=
int
(
index
)
self
.
_func
=
func
super
(
MapDataComponent
,
self
)
.
__init__
(
ds
,
self
.
_mapper
)
def
f
(
dp
):
def
_mapper
(
self
,
dp
):
r
=
func
(
dp
[
index
])
r
=
self
.
_func
(
dp
[
self
.
_
index
])
if
r
is
None
:
if
r
is
None
:
return
None
return
None
dp
=
list
(
dp
)
# shallow copy to avoid modifying the list
dp
=
list
(
dp
)
# shallow copy to avoid modifying the list
dp
[
index
]
=
r
dp
[
self
.
_
index
]
=
r
return
dp
return
dp
super
(
MapDataComponent
,
self
)
.
__init__
(
ds
,
f
)
class
RepeatedData
(
ProxyDataFlow
):
class
RepeatedData
(
ProxyDataFlow
):
...
...
tensorpack/dataflow/image.py
View file @
5cdf1d33
...
@@ -103,23 +103,22 @@ class AugmentImageComponent(MapDataComponent):
...
@@ -103,23 +103,22 @@ class AugmentImageComponent(MapDataComponent):
self
.
augs
=
augmentors
self
.
augs
=
augmentors
else
:
else
:
self
.
augs
=
AugmentorList
(
augmentors
)
self
.
augs
=
AugmentorList
(
augmentors
)
self
.
_copy
=
copy
exception_handler
=
ExceptionHandler
(
catch_exceptions
)
self
.
_exception_handler
=
ExceptionHandler
(
catch_exceptions
)
super
(
AugmentImageComponent
,
self
)
.
__init__
(
ds
,
self
.
_aug_mapper
,
index
)
def
func
(
x
):
check_dtype
(
x
)
with
exception_handler
.
catch
():
if
copy
:
x
=
copy_mod
.
deepcopy
(
x
)
return
self
.
augs
.
augment
(
x
)
super
(
AugmentImageComponent
,
self
)
.
__init__
(
ds
,
func
,
index
)
def
reset_state
(
self
):
def
reset_state
(
self
):
self
.
ds
.
reset_state
()
self
.
ds
.
reset_state
()
self
.
augs
.
reset_state
()
self
.
augs
.
reset_state
()
def
_aug_mapper
(
self
,
x
):
check_dtype
(
x
)
with
self
.
_exception_handler
.
catch
():
if
self
.
_copy
:
x
=
copy_mod
.
deepcopy
(
x
)
return
self
.
augs
.
augment
(
x
)
class
AugmentImageCoordinates
(
MapData
):
class
AugmentImageCoordinates
(
MapData
):
"""
"""
...
@@ -142,27 +141,30 @@ class AugmentImageCoordinates(MapData):
...
@@ -142,27 +141,30 @@ class AugmentImageCoordinates(MapData):
else
:
else
:
self
.
augs
=
AugmentorList
(
augmentors
)
self
.
augs
=
AugmentorList
(
augmentors
)
exception_handler
=
ExceptionHandler
(
catch_exceptions
)
self
.
_img_index
=
img_index
self
.
_coords_index
=
coords_index
self
.
_copy
=
copy
self
.
_exception_handler
=
ExceptionHandler
(
catch_exceptions
)
def
func
(
dp
):
super
(
AugmentImageCoordinates
,
self
)
.
__init__
(
ds
,
self
.
_aug_mapper
)
with
exception_handler
.
catch
():
img
,
coords
=
dp
[
img_index
],
dp
[
coords_index
]
def
reset_state
(
self
):
self
.
ds
.
reset_state
()
self
.
augs
.
reset_state
()
def
_aug_mapper
(
self
,
dp
):
with
self
.
_exception_handler
.
catch
():
img
,
coords
=
dp
[
self
.
_img_index
],
dp
[
self
.
_coords_index
]
check_dtype
(
img
)
check_dtype
(
img
)
validate_coords
(
coords
)
validate_coords
(
coords
)
if
copy
:
if
self
.
_
copy
:
img
,
coords
=
copy_mod
.
deepcopy
((
img
,
coords
))
img
,
coords
=
copy_mod
.
deepcopy
((
img
,
coords
))
img
,
prms
=
self
.
augs
.
_augment_return_params
(
img
)
img
,
prms
=
self
.
augs
.
_augment_return_params
(
img
)
dp
[
img_index
]
=
img
dp
[
self
.
_
img_index
]
=
img
coords
=
self
.
augs
.
_augment_coords
(
coords
,
prms
)
coords
=
self
.
augs
.
_augment_coords
(
coords
,
prms
)
dp
[
coords_index
]
=
coords
dp
[
self
.
_
coords_index
]
=
coords
return
dp
return
dp
super
(
AugmentImageCoordinates
,
self
)
.
__init__
(
ds
,
func
)
def
reset_state
(
self
):
self
.
ds
.
reset_state
()
self
.
augs
.
reset_state
()
class
AugmentImageComponents
(
MapData
):
class
AugmentImageComponents
(
MapData
):
"""
"""
...
...
tensorpack/dataflow/parallel.py
View file @
5cdf1d33
...
@@ -170,7 +170,9 @@ class MultiProcessPrefetchData(ProxyDataFlow):
...
@@ -170,7 +170,9 @@ class MultiProcessPrefetchData(ProxyDataFlow):
nr_proc (int): number of processes to use.
nr_proc (int): number of processes to use.
"""
"""
if
os
.
name
==
'nt'
:
if
os
.
name
==
'nt'
:
logger
.
warn
(
"MultiProcessPrefetchData may not support windows!"
)
logger
.
warn
(
"MultiProcessPrefetchData does support windows.
\
However, windows requires more strict picklability on processes, which may
\
lead of failure on some of the code."
)
super
(
MultiProcessPrefetchData
,
self
)
.
__init__
(
ds
)
super
(
MultiProcessPrefetchData
,
self
)
.
__init__
(
ds
)
try
:
try
:
self
.
_size
=
ds
.
size
()
self
.
_size
=
ds
.
size
()
...
...
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