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
c0a81d51
Commit
c0a81d51
authored
Nov 16, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs update
parent
860efcf0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
13 deletions
+22
-13
README.md
README.md
+1
-1
examples/FasterRCNN/model.py
examples/FasterRCNN/model.py
+12
-12
examples/load-alexnet.py
examples/load-alexnet.py
+4
-0
examples/load-vgg16.py
examples/load-vgg16.py
+5
-0
No files found.
README.md
View file @
c0a81d51
...
...
@@ -64,7 +64,7 @@ See [tutorials](http://tensorpack.readthedocs.io/en/latest/tutorial/index.html)
Dependencies:
+
Python 2 or 3
+
Python 2
.7
or 3
+
TensorFlow >= 1.0.0 (>=1.1.0 for Multi-GPU)
+
Python bindings for OpenCV (Optional, but required by a lot of features)
```
...
...
examples/FasterRCNN/model.py
View file @
c0a81d51
...
...
@@ -78,7 +78,7 @@ def rpn_losses(anchor_labels, anchor_boxes, label_logits, box_logits):
with
tf
.
device
(
'/cpu:0'
):
for
th
in
[
0.5
,
0.2
,
0.1
]:
valid_prediction
=
tf
.
cast
(
valid_label_prob
>
th
,
tf
.
int32
)
prediction_corr
=
tf
.
count_nonzero
(
tf
.
equal
(
valid_prediction
,
valid_anchor_labels
)
)
nr_pos_prediction
=
tf
.
count_nonzero
(
valid_prediction
,
name
=
'num_pos_prediction'
)
pos_prediction_corr
=
tf
.
count_nonzero
(
tf
.
logical_and
(
valid_label_prob
>
th
,
tf
.
equal
(
valid_prediction
,
valid_anchor_labels
)))
...
...
@@ -86,8 +86,8 @@ def rpn_losses(anchor_labels, anchor_boxes, label_logits, box_logits):
pos_prediction_corr
,
nr_pos
,
name
=
'recall_th{}'
.
format
(
th
)))
summaries
.
append
(
tf
.
truediv
(
prediction_corr
,
nr_
valid
,
name
=
'accuracy
_th{}'
.
format
(
th
)))
p
os_p
rediction_corr
,
nr_
pos_prediction
,
name
=
'precision
_th{}'
.
format
(
th
)))
label_loss
=
tf
.
nn
.
sigmoid_cross_entropy_with_logits
(
labels
=
tf
.
to_float
(
valid_anchor_labels
),
logits
=
valid_label_logits
)
...
...
@@ -403,9 +403,6 @@ def fastrcnn_losses(labels, label_logits, fg_boxes, fg_box_logits):
label_loss
=
tf
.
nn
.
sparse_softmax_cross_entropy_with_logits
(
labels
=
labels
,
logits
=
label_logits
)
label_loss
=
tf
.
reduce_mean
(
label_loss
,
name
=
'label_loss'
)
prediction
=
tf
.
argmax
(
label_logits
,
axis
=
1
,
name
=
'label_prediction'
)
correct
=
tf
.
to_float
(
tf
.
equal
(
prediction
,
labels
))
# boolean/integer gather is unavailable on GPU
accuracy
=
tf
.
reduce_mean
(
correct
,
name
=
'accuracy'
)
fg_inds
=
tf
.
where
(
labels
>
0
)[:,
0
]
fg_labels
=
tf
.
gather
(
labels
,
fg_inds
)
...
...
@@ -415,12 +412,15 @@ def fastrcnn_losses(labels, label_logits, fg_boxes, fg_box_logits):
tf
.
to_int32
(
fg_labels
)
-
1
],
axis
=
1
)
# #fgx2
fg_box_logits
=
tf
.
gather_nd
(
fg_box_logits
,
indices
)
# some metrics to summarize
fg_label_pred
=
tf
.
argmax
(
tf
.
gather
(
label_logits
,
fg_inds
),
axis
=
1
)
num_zero
=
tf
.
reduce_sum
(
tf
.
to_int32
(
tf
.
equal
(
fg_label_pred
,
0
)),
name
=
'num_zero'
)
false_negative
=
tf
.
truediv
(
num_zero
,
num_fg
,
name
=
'false_negative'
)
fg_accuracy
=
tf
.
reduce_mean
(
tf
.
gather
(
correct
,
fg_inds
),
name
=
'fg_accuracy'
)
with
tf
.
name_scope
(
'label_metrics'
),
tf
.
device
(
'/cpu:0'
):
prediction
=
tf
.
argmax
(
label_logits
,
axis
=
1
,
name
=
'label_prediction'
)
correct
=
tf
.
to_float
(
tf
.
equal
(
prediction
,
labels
))
# boolean/integer gather is unavailable on GPU
accuracy
=
tf
.
reduce_mean
(
correct
,
name
=
'accuracy'
)
fg_label_pred
=
tf
.
argmax
(
tf
.
gather
(
label_logits
,
fg_inds
),
axis
=
1
)
num_zero
=
tf
.
reduce_sum
(
tf
.
to_int32
(
tf
.
equal
(
fg_label_pred
,
0
)),
name
=
'num_zero'
)
false_negative
=
tf
.
truediv
(
num_zero
,
num_fg
,
name
=
'false_negative'
)
fg_accuracy
=
tf
.
reduce_mean
(
tf
.
gather
(
correct
,
fg_inds
),
name
=
'fg_accuracy'
)
box_loss
=
tf
.
losses
.
huber_loss
(
fg_boxes
,
fg_box_logits
,
reduction
=
tf
.
losses
.
Reduction
.
SUM
)
...
...
examples/load-alexnet.py
View file @
c0a81d51
...
...
@@ -17,6 +17,10 @@ import tensorflow as tf
"""
Usage:
Download caffe models at https://github.com/BVLC/caffe/tree/master/models/bvlc_alexnet
Install caffe python bindings.
python -m tensorpack.utils.loadcaffe PATH/TO/CAFFE/{deploy.prototxt,bvlc_alexnet.caffemodel} alexnet.npy
./load-alexnet.py --load alexnet.npy --input cat.png
"""
...
...
examples/load-vgg16.py
View file @
c0a81d51
...
...
@@ -17,6 +17,11 @@ from tensorpack.dataflow.dataset import ILSVRCMeta
"""
Usage:
Download original caffe models at:
https://gist.github.com/ksimonyan/211839e770f7b538e2d8
Install caffe python bindings.
python -m tensorpack.utils.loadcaffe
\
PATH/TO/VGG/{VGG_ILSVRC_16_layers_deploy.prototxt,VGG_ILSVRC_16_layers.caffemodel} vgg16.npy
./load-vgg16.py --load vgg16.npy --input cat.png
...
...
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