Commit c0a81d51 authored by Yuxin Wu's avatar Yuxin Wu

docs update

parent 860efcf0
...@@ -64,7 +64,7 @@ See [tutorials](http://tensorpack.readthedocs.io/en/latest/tutorial/index.html) ...@@ -64,7 +64,7 @@ See [tutorials](http://tensorpack.readthedocs.io/en/latest/tutorial/index.html)
Dependencies: Dependencies:
+ Python 2 or 3 + Python 2.7 or 3
+ TensorFlow >= 1.0.0 (>=1.1.0 for Multi-GPU) + TensorFlow >= 1.0.0 (>=1.1.0 for Multi-GPU)
+ Python bindings for OpenCV (Optional, but required by a lot of features) + Python bindings for OpenCV (Optional, but required by a lot of features)
``` ```
......
...@@ -78,7 +78,7 @@ def rpn_losses(anchor_labels, anchor_boxes, label_logits, box_logits): ...@@ -78,7 +78,7 @@ def rpn_losses(anchor_labels, anchor_boxes, label_logits, box_logits):
with tf.device('/cpu:0'): with tf.device('/cpu:0'):
for th in [0.5, 0.2, 0.1]: for th in [0.5, 0.2, 0.1]:
valid_prediction = tf.cast(valid_label_prob > th, tf.int32) 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( pos_prediction_corr = tf.count_nonzero(tf.logical_and(
valid_label_prob > th, valid_label_prob > th,
tf.equal(valid_prediction, valid_anchor_labels))) tf.equal(valid_prediction, valid_anchor_labels)))
...@@ -86,8 +86,8 @@ def rpn_losses(anchor_labels, anchor_boxes, label_logits, box_logits): ...@@ -86,8 +86,8 @@ def rpn_losses(anchor_labels, anchor_boxes, label_logits, box_logits):
pos_prediction_corr, pos_prediction_corr,
nr_pos, name='recall_th{}'.format(th))) nr_pos, name='recall_th{}'.format(th)))
summaries.append(tf.truediv( summaries.append(tf.truediv(
prediction_corr, pos_prediction_corr,
nr_valid, name='accuracy_th{}'.format(th))) nr_pos_prediction, name='precision_th{}'.format(th)))
label_loss = tf.nn.sigmoid_cross_entropy_with_logits( label_loss = tf.nn.sigmoid_cross_entropy_with_logits(
labels=tf.to_float(valid_anchor_labels), logits=valid_label_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): ...@@ -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( label_loss = tf.nn.sparse_softmax_cross_entropy_with_logits(
labels=labels, logits=label_logits) labels=labels, logits=label_logits)
label_loss = tf.reduce_mean(label_loss, name='label_loss') 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_inds = tf.where(labels > 0)[:, 0]
fg_labels = tf.gather(labels, fg_inds) fg_labels = tf.gather(labels, fg_inds)
...@@ -415,12 +412,15 @@ def fastrcnn_losses(labels, label_logits, fg_boxes, fg_box_logits): ...@@ -415,12 +412,15 @@ def fastrcnn_losses(labels, label_logits, fg_boxes, fg_box_logits):
tf.to_int32(fg_labels) - 1], axis=1) # #fgx2 tf.to_int32(fg_labels) - 1], axis=1) # #fgx2
fg_box_logits = tf.gather_nd(fg_box_logits, indices) fg_box_logits = tf.gather_nd(fg_box_logits, indices)
# some metrics to summarize with tf.name_scope('label_metrics'), tf.device('/cpu:0'):
fg_label_pred = tf.argmax(tf.gather(label_logits, fg_inds), axis=1) prediction = tf.argmax(label_logits, axis=1, name='label_prediction')
num_zero = tf.reduce_sum(tf.to_int32(tf.equal(fg_label_pred, 0)), name='num_zero') correct = tf.to_float(tf.equal(prediction, labels)) # boolean/integer gather is unavailable on GPU
false_negative = tf.truediv(num_zero, num_fg, name='false_negative') accuracy = tf.reduce_mean(correct, name='accuracy')
fg_accuracy = tf.reduce_mean( fg_label_pred = tf.argmax(tf.gather(label_logits, fg_inds), axis=1)
tf.gather(correct, fg_inds), name='fg_accuracy') 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( box_loss = tf.losses.huber_loss(
fg_boxes, fg_box_logits, reduction=tf.losses.Reduction.SUM) fg_boxes, fg_box_logits, reduction=tf.losses.Reduction.SUM)
......
...@@ -17,6 +17,10 @@ import tensorflow as tf ...@@ -17,6 +17,10 @@ import tensorflow as tf
""" """
Usage: 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 python -m tensorpack.utils.loadcaffe PATH/TO/CAFFE/{deploy.prototxt,bvlc_alexnet.caffemodel} alexnet.npy
./load-alexnet.py --load alexnet.npy --input cat.png ./load-alexnet.py --load alexnet.npy --input cat.png
""" """
......
...@@ -17,6 +17,11 @@ from tensorpack.dataflow.dataset import ILSVRCMeta ...@@ -17,6 +17,11 @@ from tensorpack.dataflow.dataset import ILSVRCMeta
""" """
Usage: Usage:
Download original caffe models at:
https://gist.github.com/ksimonyan/211839e770f7b538e2d8
Install caffe python bindings.
python -m tensorpack.utils.loadcaffe \ python -m tensorpack.utils.loadcaffe \
PATH/TO/VGG/{VGG_ILSVRC_16_layers_deploy.prototxt,VGG_ILSVRC_16_layers.caffemodel} vgg16.npy 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 ./load-vgg16.py --load vgg16.npy --input cat.png
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment