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
00ebd097
Commit
00ebd097
authored
Nov 13, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FastRCNN] fix box selection in evaluation
parent
10186aa1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
18 deletions
+15
-18
examples/FasterRCNN/README.md
examples/FasterRCNN/README.md
+1
-1
examples/FasterRCNN/eval.py
examples/FasterRCNN/eval.py
+3
-3
examples/FasterRCNN/train.py
examples/FasterRCNN/train.py
+11
-13
examples/README.md
examples/README.md
+0
-1
No files found.
examples/FasterRCNN/README.md
View file @
00ebd097
...
@@ -46,7 +46,7 @@ To evaluate the performance (pretrained models can be downloaded in [model zoo](
...
@@ -46,7 +46,7 @@ To evaluate the performance (pretrained models can be downloaded in [model zoo](
Mean Average Precision @IoU=0.50:0.95:
Mean Average Precision @IoU=0.50:0.95:
+
trainval35k/minival, FASTRCNN_BATCH=256: 33.
4
. Takes 49h on 8 TitanX.
+
trainval35k/minival, FASTRCNN_BATCH=256: 33.
7
. Takes 49h on 8 TitanX.
+
trainval35k/minival, FASTRCNN_BATCH=64: 32.2. Takes 31h on 8 TitanX.
+
trainval35k/minival, FASTRCNN_BATCH=64: 32.2. Takes 31h on 8 TitanX.
The hyperparameters are not carefully tuned. You can probably get better performance by e.g. training longer.
The hyperparameters are not carefully tuned. You can probably get better performance by e.g. training longer.
...
...
examples/FasterRCNN/eval.py
View file @
00ebd097
...
@@ -44,8 +44,8 @@ def get_tf_nms(num_output, thresh):
...
@@ -44,8 +44,8 @@ def get_tf_nms(num_output, thresh):
def
nms_fastrcnn_results
(
boxes
,
probs
):
def
nms_fastrcnn_results
(
boxes
,
probs
):
"""
"""
Args:
Args:
boxes: nx4 floatbox in float32
boxes: nx
#catx
4 floatbox in float32
probs: nx
C
probs: nx
#class
Returns:
Returns:
[DetectionResult]
[DetectionResult]
...
@@ -60,7 +60,7 @@ def nms_fastrcnn_results(boxes, probs):
...
@@ -60,7 +60,7 @@ def nms_fastrcnn_results(boxes, probs):
if
ids
.
size
==
0
:
if
ids
.
size
==
0
:
continue
continue
probs_k
=
probs
[
ids
,
klass
]
.
flatten
()
probs_k
=
probs
[
ids
,
klass
]
.
flatten
()
boxes_k
=
boxes
[
ids
,
:]
boxes_k
=
boxes
[
ids
,
klass
-
1
,
:]
selected_ids
=
nms_func
(
boxes_k
,
probs_k
)
selected_ids
=
nms_func
(
boxes_k
,
probs_k
)
selected_boxes
=
boxes_k
[
selected_ids
,
:]
.
copy
()
selected_boxes
=
boxes_k
[
selected_ids
,
:]
.
copy
()
ret
.
append
(
DetectionResult
(
klass
,
selected_boxes
,
probs_k
[
selected_ids
]))
ret
.
append
(
DetectionResult
(
klass
,
selected_boxes
,
probs_k
[
selected_ids
]))
...
...
examples/FasterRCNN/train.py
View file @
00ebd097
...
@@ -137,14 +137,11 @@ class Model(ModelDesc):
...
@@ -137,14 +137,11 @@ class Model(ModelDesc):
add_moving_summary
(
k
)
add_moving_summary
(
k
)
else
:
else
:
label_probs
=
tf
.
nn
.
softmax
(
fastrcnn_label_logits
,
name
=
'fastrcnn_all_probs'
)
# #proposal x #Class
label_probs
=
tf
.
nn
.
softmax
(
fastrcnn_label_logits
,
name
=
'fastrcnn_all_probs'
)
# #proposal x #Class
labels
=
tf
.
argmax
(
fastrcnn_label_logits
,
axis
=
1
)
anchors
=
tf
.
tile
(
tf
.
expand_dims
(
proposal_boxes
,
1
),
[
1
,
config
.
NUM_CLASS
-
1
,
1
])
# #proposal x #Cat x 4
fg_ind
,
fg_box_logits
=
fastrcnn_predict_boxes
(
labels
,
fastrcnn_box_logits
)
decoded_boxes
=
decode_bbox_target
(
fg_label_probs
=
tf
.
gather
(
label_probs
,
fg_ind
,
name
=
'fastrcnn_fg_probs'
)
fastrcnn_box_logits
/
fg_boxes
=
tf
.
gather
(
proposal_boxes
,
fg_ind
)
tf
.
constant
(
config
.
FASTRCNN_BBOX_REG_WEIGHTS
),
anchors
)
decoded_boxes
=
tf
.
identity
(
decoded_boxes
,
name
=
'fastrcnn_all_boxes'
)
fg_box_logits
=
fg_box_logits
/
tf
.
constant
(
config
.
FASTRCNN_BBOX_REG_WEIGHTS
)
decoded_boxes
=
decode_bbox_target
(
fg_box_logits
,
fg_boxes
)
# #fgx4, floatbox
decoded_boxes
=
tf
.
identity
(
decoded_boxes
,
name
=
'fastrcnn_fg_boxes'
)
def
_get_optimizer
(
self
):
def
_get_optimizer
(
self
):
lr
=
tf
.
get_variable
(
'learning_rate'
,
initializer
=
0.003
,
trainable
=
False
)
lr
=
tf
.
get_variable
(
'learning_rate'
,
initializer
=
0.003
,
trainable
=
False
)
...
@@ -210,8 +207,8 @@ def offline_evaluate(model_path, output_file):
...
@@ -210,8 +207,8 @@ def offline_evaluate(model_path, output_file):
session_init
=
get_model_loader
(
model_path
),
session_init
=
get_model_loader
(
model_path
),
input_names
=
[
'image'
],
input_names
=
[
'image'
],
output_names
=
[
output_names
=
[
'fastrcnn_
fg
_probs'
,
'fastrcnn_
all
_probs'
,
'fastrcnn_
fg
_boxes'
,
'fastrcnn_
all
_boxes'
,
]))
]))
df
=
get_eval_dataflow
()
df
=
get_eval_dataflow
()
df
=
PrefetchDataZMQ
(
df
,
1
)
df
=
PrefetchDataZMQ
(
df
,
1
)
...
@@ -227,8 +224,8 @@ def predict(model_path, input_file):
...
@@ -227,8 +224,8 @@ def predict(model_path, input_file):
session_init
=
get_model_loader
(
model_path
),
session_init
=
get_model_loader
(
model_path
),
input_names
=
[
'image'
],
input_names
=
[
'image'
],
output_names
=
[
output_names
=
[
'fastrcnn_
fg
_probs'
,
'fastrcnn_
all
_probs'
,
'fastrcnn_
fg
_boxes'
,
'fastrcnn_
all
_boxes'
,
]))
]))
img
=
cv2
.
imread
(
input_file
,
cv2
.
IMREAD_COLOR
)
img
=
cv2
.
imread
(
input_file
,
cv2
.
IMREAD_COLOR
)
results
=
detect_one_image
(
img
,
pred
)
results
=
detect_one_image
(
img
,
pred
)
...
@@ -239,7 +236,8 @@ def predict(model_path, input_file):
...
@@ -239,7 +236,8 @@ def predict(model_path, input_file):
class
EvalCallback
(
Callback
):
class
EvalCallback
(
Callback
):
def
_setup_graph
(
self
):
def
_setup_graph
(
self
):
self
.
pred
=
self
.
trainer
.
get_predictor
([
'image'
],
[
'fastrcnn_fg_probs'
,
'fastrcnn_fg_boxes'
])
self
.
pred
=
self
.
trainer
.
get_predictor
(
[
'image'
],
[
'fastrcnn_all_probs'
,
'fastrcnn_all_boxes'
])
self
.
df
=
PrefetchDataZMQ
(
get_eval_dataflow
(),
1
)
self
.
df
=
PrefetchDataZMQ
(
get_eval_dataflow
(),
1
)
def
_before_train
(
self
):
def
_before_train
(
self
):
...
...
examples/README.md
View file @
00ebd097
...
@@ -43,7 +43,6 @@ Training examples with __reproducible__ and meaningful performance.
...
@@ -43,7 +43,6 @@ Training examples with __reproducible__ and meaningful performance.
Example needs to satisfy one of the following:
Example needs to satisfy one of the following:
+
Reproduce performance of a published or well-known paper.
+
Reproduce performance of a published or well-known paper.
+
Get state-of-the-art performance on some task.
+
Illustrate a new way of using the library that is currently not covered.
+
Illustrate a new way of using the library that is currently not covered.
__Performance is important__
. Usually deep learning code is easy to write,
__Performance is important__
. Usually deep learning code is easy to write,
...
...
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