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
45c0a1e0
You need to sign in or sign up before continuing.
Commit
45c0a1e0
authored
Sep 08, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exception handling in zmq. clip_by_shape for floatbox
parent
cb8b48d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
28 deletions
+14
-28
tensorpack/dataflow/prefetch.py
tensorpack/dataflow/prefetch.py
+7
-1
tensorpack/utils/rect.py
tensorpack/utils/rect.py
+7
-27
No files found.
tensorpack/dataflow/prefetch.py
View file @
45c0a1e0
...
@@ -198,7 +198,13 @@ class PrefetchDataZMQ(ProxyDataFlow):
...
@@ -198,7 +198,13 @@ class PrefetchDataZMQ(ProxyDataFlow):
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
(
self
.
_hwm
)
self
.
socket
.
set_hwm
(
self
.
_hwm
)
self
.
socket
.
bind
(
self
.
pipename
)
try
:
self
.
socket
.
bind
(
self
.
pipename
)
except
zmq
.
ZMQError
:
logger
.
error
(
"ZMQError in socket.bind(). Perhaps you're
\
using pipes on a non-local file system. See documentation of PrefetchDataZMQ for more information."
)
raise
self
.
procs
=
[
PrefetchProcessZMQ
(
self
.
ds
,
self
.
pipename
,
self
.
_hwm
)
self
.
procs
=
[
PrefetchProcessZMQ
(
self
.
ds
,
self
.
pipename
,
self
.
_hwm
)
for
_
in
range
(
self
.
nr_proc
)]
for
_
in
range
(
self
.
nr_proc
)]
...
...
tensorpack/utils/rect.py
View file @
45c0a1e0
...
@@ -85,36 +85,11 @@ class IntBox(BoxBase):
...
@@ -85,36 +85,11 @@ class IntBox(BoxBase):
assert
self
.
is_valid_box
(
img
.
shape
[:
2
]),
"{} vs {}"
.
format
(
self
,
img
.
shape
[:
2
])
assert
self
.
is_valid_box
(
img
.
shape
[:
2
]),
"{} vs {}"
.
format
(
self
,
img
.
shape
[:
2
])
return
img
[
self
.
y1
:
self
.
y2
+
1
,
self
.
x1
:
self
.
x2
+
1
]
return
img
[
self
.
y1
:
self
.
y2
+
1
,
self
.
x1
:
self
.
x2
+
1
]
# def expand(self, frac):
# assert frac > 1.0, frac
# neww = self.w * frac
# newh = self.h * frac
# newx = self.x - (neww - self.w) * 0.5
# newy = self.y - (newh - self.h) * 0.5
# return Rect(*(map(int, [newx, newy, neww, newh])), allow_neg=True)
# def roi_zeropad(self, img):
# shp = list(img.shape)
# shp[0] = self.h
# shp[1] = self.w
# ret = np.zeros(tuple(shp), dtype=img.dtype)
# xstart = 0 if self.x >= 0 else -self.x
# ystart = 0 if self.y >= 0 else -self.y
# xmin = max(self.x0, 0)
# ymin = max(self.y0, 0)
# xmax = min(self.x1, img.shape[1])
# ymax = min(self.y1, img.shape[0])
# patch = img[ymin:ymax, xmin:xmax]
# ret[ystart:ystart + patch.shape[0], xstart:xstart + patch.shape[1]] = patch
# return ret
class
FloatBox
(
BoxBase
):
class
FloatBox
(
BoxBase
):
def
__init__
(
self
,
x1
,
y1
,
x2
,
y2
):
def
__init__
(
self
,
x1
,
y1
,
x2
,
y2
):
for
k
in
[
x1
,
y1
,
x2
,
y2
]:
for
k
in
[
x1
,
y1
,
x2
,
y2
]:
assert
isinstance
(
k
,
float
)
assert
isinstance
(
k
,
float
)
,
"type={},value={}"
.
format
(
type
(
k
),
k
)
super
(
FloatBox
,
self
)
.
__init__
(
x1
,
y1
,
x2
,
y2
)
super
(
FloatBox
,
self
)
.
__init__
(
x1
,
y1
,
x2
,
y2
)
@
property
@
property
...
@@ -130,9 +105,14 @@ class FloatBox(BoxBase):
...
@@ -130,9 +105,14 @@ class FloatBox(BoxBase):
return
FloatBox
(
intbox
.
x1
,
intbox
.
y1
,
return
FloatBox
(
intbox
.
x1
,
intbox
.
y1
,
intbox
.
x2
+
1
,
intbox
.
y2
+
1
)
intbox
.
x2
+
1
,
intbox
.
y2
+
1
)
def
clip_by_shape
(
self
,
shape
):
self
.
x1
=
np
.
clip
(
self
.
x1
,
0
,
shape
[
1
])
self
.
x2
=
np
.
clip
(
self
.
x2
,
0
,
shape
[
1
])
self
.
y1
=
np
.
clip
(
self
.
y1
,
0
,
shape
[
0
])
self
.
y2
=
np
.
clip
(
self
.
y2
,
0
,
shape
[
0
])
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
x
=
IntBox
(
2
,
1
,
3
,
3
)
x
=
IntBox
(
2
,
1
,
3
,
3
)
img
=
np
.
random
.
rand
(
3
,
3
)
img
=
np
.
random
.
rand
(
3
,
3
)
print
(
img
)
print
(
img
)
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