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
10186aa1
Commit
10186aa1
authored
Nov 13, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FasterRCNN] crop_and_resize takes index as well
parent
e1e2ee8d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
examples/FasterRCNN/model.py
examples/FasterRCNN/model.py
+11
-10
No files found.
examples/FasterRCNN/model.py
View file @
10186aa1
...
@@ -285,16 +285,15 @@ def sample_fast_rcnn_targets(boxes, gt_boxes, gt_labels):
...
@@ -285,16 +285,15 @@ def sample_fast_rcnn_targets(boxes, gt_boxes, gt_labels):
@
under_name_scope
()
@
under_name_scope
()
def
crop_and_resize
(
image
,
boxes
,
size
):
def
crop_and_resize
(
image
,
boxes
,
box_ind
,
crop_
size
):
"""
"""
Better-aligned version of tf.image.crop_and_resize,
Better-aligned version of tf.image.crop_and_resize,
following our definition of floating point boxes.
following our definition of floating point boxes.
Args:
Args:
image:
1
CHW
image:
N
CHW
boxes: nx4, x1y1x2y2
boxes: nx4, x1y1x2y2
size (int):
box_ind: (n,)
crop_size (int):
Returns:
Returns:
n,C,size,size
n,C,size,size
"""
"""
...
@@ -330,12 +329,11 @@ def crop_and_resize(image, boxes, size):
...
@@ -330,12 +329,11 @@ def crop_and_resize(image, boxes, size):
return
tf
.
concat
([
ny0
,
nx0
,
ny0
+
nh
,
nx0
+
nw
],
axis
=
1
)
return
tf
.
concat
([
ny0
,
nx0
,
ny0
+
nh
,
nx0
+
nw
],
axis
=
1
)
image_shape
=
tf
.
shape
(
image
)[
2
:]
image_shape
=
tf
.
shape
(
image
)[
2
:]
boxes
=
transform_fpcoor_for_tf
(
boxes
,
image_shape
,
[
size
,
size
])
boxes
=
transform_fpcoor_for_tf
(
boxes
,
image_shape
,
[
crop_size
,
crop_
size
])
image
=
tf
.
transpose
(
image
,
[
0
,
2
,
3
,
1
])
# 1hwc
image
=
tf
.
transpose
(
image
,
[
0
,
2
,
3
,
1
])
# 1hwc
ret
=
tf
.
image
.
crop_and_resize
(
ret
=
tf
.
image
.
crop_and_resize
(
image
,
boxes
,
image
,
boxes
,
box_ind
,
tf
.
zeros
([
tf
.
shape
(
boxes
)[
0
]],
dtype
=
tf
.
int32
),
crop_size
=
[
crop_size
,
crop_size
])
crop_size
=
[
size
,
size
])
ret
=
tf
.
transpose
(
ret
,
[
0
,
3
,
1
,
2
])
# ncss
ret
=
tf
.
transpose
(
ret
,
[
0
,
3
,
1
,
2
])
# ncss
return
ret
return
ret
...
@@ -356,7 +354,10 @@ def roi_align(featuremap, boxes, output_shape):
...
@@ -356,7 +354,10 @@ def roi_align(featuremap, boxes, output_shape):
boxes
=
tf
.
stop_gradient
(
boxes
)
# TODO
boxes
=
tf
.
stop_gradient
(
boxes
)
# TODO
# sample 4 locations per roi bin
# sample 4 locations per roi bin
ret
=
crop_and_resize
(
featuremap
,
boxes
,
output_shape
*
2
)
ret
=
crop_and_resize
(
featuremap
,
boxes
,
tf
.
zeros
([
tf
.
shape
(
boxes
)[
0
]],
dtype
=
tf
.
int32
),
output_shape
*
2
)
ret
=
tf
.
nn
.
avg_pool
(
ret
,
[
1
,
1
,
2
,
2
],
[
1
,
1
,
2
,
2
],
padding
=
'SAME'
,
data_format
=
'NCHW'
)
ret
=
tf
.
nn
.
avg_pool
(
ret
,
[
1
,
1
,
2
,
2
],
[
1
,
1
,
2
,
2
],
padding
=
'SAME'
,
data_format
=
'NCHW'
)
return
ret
return
ret
...
...
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