endernewton / tf-faster-rcnn

Tensorflow Faster RCNN for Object Detection
https://arxiv.org/pdf/1702.02138.pdf
MIT License
3.65k stars 1.57k forks source link

Could anyone explain how to add a new network? #342

Open f27ny105t5123 opened 6 years ago

f27ny105t5123 commented 6 years ago

I'm trying to add the inception v4 network into the faster-rcnn for a higher accuracy.

I use the slim.inception_v4 as the network architecture code and write the child class of Network myself as the code below.

from nets.network import Network
 class inceptionv4(Network):
   def __init__(self):
     Network.__init__(self)
     self._feat_stride = [16, ]
     self._feat_compress = [1. / float(self._feat_stride[0]), ]
     self._scope = "InceptionV4"
   def _image_to_head(self, is_training, reuse=None):
     print("image_to_head")
     net, _= inception_v4(self._image, num_classes=self._num_classes, scope=self._scope, create_aux_logits=False)
     return net
   def _head_to_tail(self, pool5, is_training, reuse=None):
     print("head_to_tail")
   def get_variables_to_restore(self, variables, var_keep_dic):
     print("get_variables_to_restore")
   def fix_variables(self, sess, pretrained_model):
     print("fix_variables")

It's not work. Could anyone help me to solve this? Much obliged :dancer:

Traceback (most recent call last): File "./tools/trainval_net.py", line 142, in max_iters=args.max_iters) File "/home/b324-gmx/tf-faster-rcnn-master/tools/../lib/model/train_val.py", line 377, in train_net sw.train_model(sess, max_iters) File "/home/b324-gmx/tf-faster-rcnn-master/tools/../lib/model/train_val.py", line 248, in train_model lr, train_op = self.construct_graph(sess) File "/home/b324-gmx/tf-faster-rcnn-master/tools/../lib/model/train_val.py", line 123, in construct_graph anchor_ratios=cfg.ANCHOR_RATIOS) File "/home/b324-gmx/tf-faster-rcnn-master/tools/../lib/nets/network.py", line 389, in create_architecture rois, cls_prob, bbox_pred = self._build_network(training) File "/home/b324-gmx/tf-faster-rcnn-master/tools/../lib/nets/network.py", line 215, in _build_network rois = self._region_proposal(net_conv, is_training, initializer) File "/home/b324-gmx/tf-faster-rcnn-master/tools/../lib/nets/network.py", line 293, in _region_proposal scope="rpn_conv/3x3") File "/home/b324-gmx/.local/lib/python3.5/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 181, in func_with_args return func(*args, **current_args) File "/home/b324-gmx/.local/lib/python3.5/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1011, in convolution input_rank) ValueError: ('Convolution not supported for input with rank', 2) Command exited with non-zero status 1

Dontfall commented 6 years ago

Excuse me, did you succeed later? @f27ny105t5123