github源码地址:https://github.com/endernewton/tf-faster-rcnn 阅读源码时应该先找出主干的函数,整理出框架,然后再依据需要去细读各个函数的功能。
以tf-faster-rcnn-master/tools/demo.py作为程序入口,主要调用tf-faster-rcnn-master/lib/nets/network.py 、 tf-faster-rcnn-master/lib/nets/resnet_v1.py (若以resnet作为backbone的话)和 tf-faster-rcnn-master/lib/model/test.py中的函数。其中network.py中的类Network 是 resnet_v1.py中的Resnetv1 的父类。
if name == ‘main’:
net = resnetv1(~)net.create_architecture(~) rois, cls_prob, bbox_pred = self._build_network(~) net_conv = self._image_to_head(~) net_conv = self._build_base() net = resnet_utils.conv2d_same(self._image, ~) net_conv, _ = resnet_v1.resnet_v1(net_conv, ~) rois = self._region_proposal(net_conv, ~)pool5 = self._crop_pool_layer(net_conv, ~)fc7 = self._head_to_tail(pool5, ~)cls_prob, bbox_pred = self._region_classification(fc7, ~) saver.restore(sess, tfmodel)demo(sess, net, im_name) scores, boxes = im_detect(sess, net, im) _, scores, bbox_pred, rois = net.test_image(sess, blobs~) cls_score, cls_prob, bbox_pred, rois = sess.run(~)待续。