<p>For building your own <code>Faster RCNN Models</code>, you can follow the instructions mentioned in the <a href="https://github.com/tensorflow/models/blob/1af55e018eebce03fb61bba9959a04672536107d/research/object_detection/g3doc/defining_your_own_model.md" rel="nofollow noreferrer">Official Tensorflow Github Repository</a>.</p>

<p>The advantage of following these instructions is that if you face any problem, you can file an issue in <a href="https://github.com/tensorflow/models/issues" rel="nofollow noreferrer">this Repo</a> and you will be assisted by Google Engineers.</p>

<p>Specifying the steps mentioned in the <a href="https://github.com/tensorflow/models/blob/1af55e018eebce03fb61bba9959a04672536107d/research/object_detection/g3doc/instance_segmentation.md" rel="nofollow noreferrer">Github Repo</a> for the benefit of the community (just in case that link breaks).</p>

<p><strong>Defining a new Faster R-CNN or SSD Feature Extractor:</strong></p>

<p>In most cases, you probably will not implement a <code>DetectionModel</code> from scratch --- instead you might create a new feature extractor to be used by one of the SSD or Faster R-CNN meta-architectures. (We think of meta-architectures as classes that define entire families of models using the <code>DetectionModel</code> abstraction).</p>

<p>Note: For the following discussion to make sense, we recommend first becoming familiar with the <a href="https://arxiv.org/abs/1506.01497" rel="nofollow noreferrer">Faster R-CNN</a> paper.</p>

<p>Let’s now imagine that you have invented a brand new network architecture (say, “InceptionV100”) for classification and want to see how InceptionV100 would behave as a feature extractor for detection (say, with Faster R-CNN). A similar procedure would hold for SSD models, but we’ll discuss Faster R-CNN.</p>

<p>To use InceptionV100, we will have to define a new <code>FasterRCNNFeatureExtractor</code> and pass it to our FasterRCNNMetaArch constructor as input. See <code>object_detection/meta_architectures/faster_rcnn_meta_arch.py</code> for definitions of <code>FasterRCNNFeatureExtractor</code> and <code>FasterRCNNMetaArch</code>, respectively. A <code>FasterRCNNFeatureExtractor</code> must define a few functions:</p>

<ul>
<li><code>preprocess</code>: Run any preprocessing of input values that is necessary prior to running the detector on an input image.</li>
<li><code>_extract_proposal_features</code>: Extract first stage Region Proposal Network (RPN) features.</li>
<li><code>_extract_box_classifier_features</code>: Extract second stage Box Classifier features.</li>
<li><code>restore_from_classification_checkpoint_fn</code>: Load a checkpoint into the Tensorflow graph.</li>
</ul>

<p>See the <code>object_detection/models/faster_rcnn_resnet_v1_feature_extractor.py</code> definition as one example. Some remarks:</p>

<ul>
<li>We typically initialize the weights of this feature extractor using those from the <a href="https://github.com/tensorflow/models/tree/master/research/slim#pre-trained-models" rel="nofollow noreferrer">Slim Resnet-101 classification checkpoint</a>, and we know that images were preprocessed when training this checkpoint by subtracting a channel mean from each input image. Thus, we implement the preprocess function to replicate the same channel mean subtraction behavior.</li>
<li>The “full” resnet classification network defined in slim is cut into two parts --- all but the last “resnet block” is put into the <code>_extract_proposal_features</code> function and the final block is separately defined in the <code>_extract_box_classifier_features</code> function. In general, some experimentation may be required to decide on an optimal layer at which to “cut” your feature extractor into these two pieces for Faster R-CNN.</li>
</ul>

<p>For more information, please refer <a href="https://github.com/tensorflow/models/blob/1af55e018eebce03fb61bba9959a04672536107d/research/object_detection/g3doc/defining_your_own_model.md" rel="nofollow noreferrer">this link</a> and this Github Repo for <a href="https://github.com/tensorflow/models/" rel="nofollow noreferrer">Tensorflow Models</a>.</p>

<p>Hope this helps. Happy Learning!</p>
Can't train faster rcnn
<p>I want build my own Faster Rcnn model, I download an example from <a href="https://github.com/dBeker/Faster-RCNN-TensorFlow-Python3" rel="nofollow noreferrer">https://github.com/dBeker/Faster-RCNN-TensorFlow-Python3</a>  </p>

<p>I get an error when running the code, and I don't know why</p>

<pre><code>Traceback (most recent call last):
  File "C:/Users/l/Desktop/Faster-RCNN/train.py", line 216, in &lt;module&gt;
    train.train()
  File "C:/Users/l/Desktop/Faster-RCNN/train.py", line 148, in train
    blobs = self.data_layer.forward()
  File "C:\Users\l\Desktop\Faster-RCNN\lib\layer_utils\roi_data_layer.py", line 75, in forward
    blobs = self._get_next_minibatch()
  File "C:\Users\l\Desktop\Faster-RCNN\lib\layer_utils\roi_data_layer.py", line 71, in _get_next_minibatch
    return get_minibatch(minibatch_db, self._num_classes)
  File "C:\Users\l\Desktop\Faster-RCNN\lib\utils\minibatch.py", line 30, in get_minibatch
    im_blob, im_scales = _get_image_blob(roidb, random_scale_inds)
  File "C`enter code here`:\Users\l\Desktop\Faster-RCNN\lib\utils\minibatch.py", line 67, in _get_image_blob
    im, im_scale = prep_im_for_blob(im, cfg.FLAGS2["pixel_means"], target_size, cfg.FLAGS.max_size)
  File "C:\Users\l\Desktop\Faster-RCNN\lib\utils\blob.py", line 35, in prep_im_for_blob
    im = im.astype(np.float32, copy=False)
AttributeError: 'NoneType' object has no attribute 'astype'
</code></pre>