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
982f42b9
Commit
982f42b9
authored
Sep 23, 2018
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove FloatBox and IntBox
parent
95cdb963
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
32 deletions
+26
-32
docs/conf.py
docs/conf.py
+1
-0
examples/FasterRCNN/coco.py
examples/FasterRCNN/coco.py
+8
-7
examples/OpticalFlow/README.md
examples/OpticalFlow/README.md
+4
-4
tensorpack/dataflow/imgaug/base.py
tensorpack/dataflow/imgaug/base.py
+5
-5
tensorpack/utils/viz.py
tensorpack/utils/viz.py
+8
-16
No files found.
docs/conf.py
View file @
982f42b9
...
...
@@ -364,6 +364,7 @@ _DEPRECATED_NAMES = set([
'dump_dataflow_to_lmdb'
,
'dump_dataflow_to_tfrecord'
,
'pyplot2img'
,
'IntBox'
,
'FloatBox'
,
# renamed stuff:
'DumpTensor'
,
...
...
examples/FasterRCNN/coco.py
View file @
982f42b9
...
...
@@ -8,7 +8,6 @@ from tabulate import tabulate
import
tqdm
from
tensorpack.utils
import
logger
from
tensorpack.utils.rect
import
FloatBox
from
tensorpack.utils.timer
import
timed_operation
from
tensorpack.utils.argtools
import
log_once
...
...
@@ -130,13 +129,15 @@ class COCODetection(object):
x1
,
y1
,
w
,
h
=
obj
[
'bbox'
]
# bbox is originally in float
# x1/y1 means upper-left corner and w/h means true w/h. This can be verified by segmentation pixels.
# But we do assume that (0.0, 0.0) is upper-left corner of the first pixel
box
=
FloatBox
(
float
(
x1
),
float
(
y1
),
float
(
x1
+
w
),
float
(
y1
+
h
))
box
.
clip_by_shape
([
height
,
width
])
# But we do make an assumption here that (0.0, 0.0) is upper-left corner of the first pixel
x1
=
np
.
clip
(
float
(
x1
),
0
,
width
)
y1
=
np
.
clip
(
float
(
y1
),
0
,
height
)
w
=
np
.
clip
(
float
(
x1
+
w
),
0
,
width
)
-
x1
h
=
np
.
clip
(
float
(
y1
+
h
),
0
,
height
)
-
y1
# Require non-zero seg area and more than 1x1 box size
if
obj
[
'area'
]
>
1
and
box
.
is_box
()
and
box
.
area
()
>=
4
:
obj
[
'bbox'
]
=
[
box
.
x1
,
box
.
y1
,
box
.
x2
,
box
.
y2
]
if
obj
[
'area'
]
>
1
and
w
>
0
and
h
>
0
and
w
*
h
>=
4
:
obj
[
'bbox'
]
=
[
x1
,
y1
,
x1
+
w
,
y1
+
h
]
valid_objs
.
append
(
obj
)
if
add_mask
:
...
...
examples/OpticalFlow/README.md
View file @
982f42b9
...
...
@@ -23,7 +23,7 @@ which is better than other TensorFlow implementations.
### Usage
1.
Download the pre-trained model:
1.
Download the pre-trained model
(converted from caffe)
:
```
bash
wget http://models.tensorpack.com/OpticalFlow/flownet2.npz
...
...
@@ -36,7 +36,7 @@ wget http://models.tensorpack.com/OpticalFlow/flownet2-c.npz
2.
Run inference
```
bash
python flownet2.py
python flownet2.py
\
--left
left.png
--right
right.png
\
--load
flownet2.npz
--model
flownet2
```
...
...
tensorpack/dataflow/imgaug/base.py
View file @
982f42b9
...
...
@@ -113,20 +113,20 @@ class ImageAugmentor(Augmentor):
floating point images in range [0, 1] or [0, 255].
"""
def
augment_coords
(
self
,
coords
,
param
):
return
self
.
_augment_coords
(
coords
,
param
)
def
_augment_coords
(
self
,
coords
,
param
):
"""
Augment the coordinates given the param.
By default, keeps coordinates unchanged.
By default,
an augmentor
keeps coordinates unchanged.
If a subclass changes coordinates but couldn't implement this method,
it should ``raise NotImplementedError()``.
Args:
coords: Nx2 floating point n
p
array where each row is (x, y)
coords: Nx2 floating point n
umpy
array where each row is (x, y)
Returns:
new coords
"""
return
self
.
_augment_coords
(
coords
,
param
)
def
_augment_coords
(
self
,
coords
,
param
):
return
coords
...
...
tensorpack/utils/viz.py
View file @
982f42b9
...
...
@@ -8,7 +8,6 @@ import sys
import
io
from
.fs
import
mkdir_p
from
.argtools
import
shape2d
from
.rect
import
BoxBase
,
IntBox
from
.palette
import
PALETTE_RGB
try
:
...
...
@@ -367,8 +366,7 @@ def draw_boxes(im, boxes, labels=None, color=None):
"""
Args:
im (np.ndarray): a BGR image in range [0,255]. It will not be modified.
boxes (np.ndarray or list[BoxBase]): If an ndarray,
must be of shape Nx4 where the second dimension is [x1, y1, x2, y2].
boxes (np.ndarray): a numpy array of shape Nx4 where each row is [x1, y1, x2, y2].
labels: (list[str] or None)
color: a 3-tuple (in range [0, 255]). By default will choose automatically.
...
...
@@ -377,14 +375,7 @@ def draw_boxes(im, boxes, labels=None, color=None):
"""
FONT
=
cv2
.
FONT_HERSHEY_SIMPLEX
FONT_SCALE
=
0.4
if
isinstance
(
boxes
,
list
):
arr
=
np
.
zeros
((
len
(
boxes
),
4
),
dtype
=
'int32'
)
for
idx
,
b
in
enumerate
(
boxes
):
assert
isinstance
(
b
,
BoxBase
),
b
arr
[
idx
,
:]
=
[
int
(
b
.
x1
),
int
(
b
.
y1
),
int
(
b
.
x2
),
int
(
b
.
y2
)]
boxes
=
arr
else
:
boxes
=
boxes
.
astype
(
'int32'
)
boxes
=
np
.
asarray
(
boxes
,
dtype
=
'int32'
)
if
labels
is
not
None
:
assert
len
(
labels
)
==
len
(
boxes
),
"{} != {}"
.
format
(
len
(
labels
),
len
(
boxes
))
areas
=
(
boxes
[:,
2
]
-
boxes
[:,
0
]
+
1
)
*
(
boxes
[:,
3
]
-
boxes
[:,
1
]
+
1
)
...
...
@@ -415,17 +406,18 @@ def draw_boxes(im, boxes, labels=None, color=None):
if
top_left
[
1
]
<
0
:
# out of image
top_left
[
1
]
=
box
[
3
]
-
1.3
*
lineh
bottom_left
[
1
]
=
box
[
3
]
-
0.3
*
lineh
textbox
=
IntBox
(
int
(
top_left
[
0
]),
int
(
top_left
[
1
]),
int
(
top_left
[
0
]
+
linew
),
int
(
top_left
[
1
]
+
lineh
))
textbox
.
clip_by_shape
(
im
.
shape
[:
2
])
x1
,
y1
=
int
(
top_left
[
0
]),
int
(
top_left
[
1
])
x2
,
y2
=
int
(
top_left
[
0
]
+
linew
),
int
(
top_left
[
1
]
+
lineh
)
x1
,
x2
=
[
np
.
clip
(
x
,
0
,
img
.
shape
[
1
]
-
1
)
for
x
in
[
x1
,
x2
]]
y1
,
y2
=
[
np
.
clip
(
y
,
0
,
img
.
shape
[
0
]
-
1
)
for
y
in
[
y1
,
y2
]]
if
color
is
None
:
# find the best color
mean_color
=
textbox
.
roi
(
im
)
.
mean
(
axis
=
(
0
,
1
))
mean_color
=
im
[
y1
:
y2
+
1
,
x1
:
x2
+
1
]
.
mean
(
axis
=
(
0
,
1
))
best_color_ind
=
(
np
.
square
(
COLOR_CANDIDATES
-
mean_color
)
*
COLOR_DIFF_WEIGHT
)
.
sum
(
axis
=
1
)
.
argmax
()
best_color
=
COLOR_CANDIDATES
[
best_color_ind
]
.
tolist
()
cv2
.
putText
(
im
,
label
,
(
textbox
.
x1
,
textbox
.
y2
),
cv2
.
putText
(
im
,
label
,
(
x1
,
y2
),
FONT
,
FONT_SCALE
,
color
=
best_color
,
lineType
=
cv2
.
LINE_AA
)
cv2
.
rectangle
(
im
,
(
box
[
0
],
box
[
1
]),
(
box
[
2
],
box
[
3
]),
color
=
best_color
,
thickness
=
1
)
...
...
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