class_docstr: Base class for FCIS.
  
  This is a base class for FCIS links supporting instance segmentation
  API [#]_. The following three stages constitute FCIS.
  
  1. **Feature extraction**: Images are taken and their         feature maps are calculated.
  2. **Region Proposal Networks**: Given the feature maps calculated in         the previous stage, produce set of RoIs around objects.
  3. **Localization, Segmentation and Classification Heads**: Using feature         maps that belong to the proposed RoIs, segment regions of the         objects, classify the categories of the objects in the RoIs and         improve localizations.
  
  Each stage is carried out by one of the callable
  :class:`chainer.Chain` objects :obj:`feature`, :obj:`rpn` and :obj:`head`.
  There are two functions :meth:`predict` and :meth:`forward` to conduct
  instance segmentation.
  :meth:`predict` takes images and returns masks, object labels
  and their scores.
  :meth:`forward` is provided for a scnerario when intermediate outputs
  are needed, for instance, for training and debugging.
  
  Links that support instance segmentation API have method :meth:`predict`
  with the same interface. Please refer to :meth:`predict` for further
  details.
  
  .. [#] Yi Li, Haozhi Qi, Jifeng Dai, Xiangyang Ji, Yichen Wei.     Fully Convolutional Instance-aware Semantic Segmentation. CVPR 2017.
  
  Args:
      extractor (callable Chain): A callable that takes a BCHW image
          array and returns feature maps.
      rpn (callable Chain): A callable that has the same interface as
          :class:`~chainercv.links.model.faster_rcnn.RegionProposalNetwork`.
          Please refer to the documentation found there.
      head (callable Chain): A callable that takes a BCHW array,
          RoIs and batch indices for RoIs.
          This returns class-agnostic segmentation scores, class-agnostic
          localization parameters, class scores, improved RoIs and batch
          indices for RoIs.
      mean (numpy.ndarray): A value to be subtracted from an image
          in :meth:`prepare`.
      min_size (int): A preprocessing parameter for :meth:`prepare`. Please
          refer to a docstring found for :meth:`prepare`.
      max_size (int): A preprocessing parameter for :meth:`prepare`.
      loc_normalize_mean (tuple of four floats): Mean values of
          localization estimates.
      loc_normalize_std (tupler of four floats): Standard deviation
          of localization estimates.
class_docstr_tok: ["Base","class","for","FCIS",".","This","is","a","base","class","for","FCIS","links","supporting","instance","segmentation","API","[","#","]","_",".","The","following","three","stages","constitute","FCIS",".","1",".","*","*","Feature","extraction","*","*",":","Images","are","taken","and","their","feature","maps","are","calculated",".","2",".","*","*","Region","Proposal","Networks","*","*",":","Given","the","feature","maps","calculated","in","the","previous","stage",",","produce","set","of","RoIs","around","objects",".","3",".","*","*","Localization",",","Segmentation","and","Classification","Heads","*","*",":","Using","feature","maps","that","belong","to","the","proposed","RoIs",",","segment","regions","of","the","objects",",","classify","the","categories","of","the","objects","in","the","RoIs","and","improve","localizations",".","Each","stage","is","carried","out","by","one","of","the","callable",":","class",":","`","chainer.Chain","`","objects",":","obj",":","`","feature","`",",",":","obj",":","`","rpn","`","and",":","obj",":","`","head","`",".","There","are","two","functions",":","meth",":","`","predict","`","and",":","meth",":","`","forward","`","to","conduct","instance","segmentation",".",":","meth",":","`","predict","`","takes","images","and","returns","masks",",","object","labels","and","their","scores",".",":","meth",":","`","forward","`","is","provided","for","a","scnerario","when","intermediate","outputs","are","needed",",","for","instance",",","for","training","and","debugging",".","Links","that","support","instance","segmentation","API","have","method",":","meth",":","`","predict","`","with","the","same","interface",".","Please","refer","to",":","meth",":","`","predict","`","for","further","details",".","..","[","#","]","Yi","Li",",","Haozhi","Qi",",","Jifeng","Dai",",","Xiangyang","Ji",",","Yichen","Wei",".","Fully","Convolutional","Instance-aware","Semantic","Segmentation",".","CVPR","2017",".","Args",":","extractor","(","callable","Chain",")",":","A","callable","that","takes","a","BCHW","image","array","and","returns","feature","maps",".","rpn","(","callable","Chain",")",":","A","callable","that","has","the","same","interface","as",":","class",":","`","~chainercv.links.model.faster_rcnn.RegionProposalNetwork","`",".","Please","refer","to","the","documentation","found","there",".","head","(","callable","Chain",")",":","A","callable","that","takes","a","BCHW","array",",","RoIs","and","batch","indices","for","RoIs",".","This","returns","class-agnostic","segmentation","scores",",","class-agnostic","localization","parameters",",","class","scores",",","improved","RoIs","and","batch","indices","for","RoIs",".","mean","(","numpy.ndarray",")",":","A","value","to","be","subtracted","from","an","image","in",":","meth",":","`","prepare","`",".","min_size","(","int",")",":","A","preprocessing","parameter","for",":","meth",":","`","prepare","`",".","Please","refer","to","a","docstring","found","for",":","meth",":","`","prepare","`",".","max_size","(","int",")",":","A","preprocessing","parameter","for",":","meth",":","`","prepare","`",".","loc_normalize_mean","(","tuple","of","four","floats",")",":","Mean","values","of","localization","estimates",".","loc_normalize_std","(","tupler","of","four","floats",")",":","Standard","deviation","of","localization","estimates","."]
docstr: Forward FCIS.
  
  Scaling paramter :obj:`scale` is used by RPN to determine the
  threshold to select small objects, which are going to be
  rejected irrespective of their confidence scores.
  
  Here are notations used.
  
  * :math:`N` is the number of batch size
  * :math:`R'` is the total number of RoIs produced across batches.             Given :math:`R_i` proposed RoIs from the :math:`i` th image,             :math:`R' = \sum _{i=1} ^ N R_i`.
  * :math:`L` is the number of classes excluding the background.
  * :math:`RH` is the height of pooled image by Position Sensitive             ROI pooling.
  * :math:`RW` is the height of pooled image by Position Sensitive             ROI pooling.
  
  Classes are ordered by the background, the first class, ..., and
  the :math:`L` th class.
  
  Args:
      x (~chainer.Variable): 4D image variable.
      scales (tuple of floats): Amount of scaling applied to each input
          image during preprocessing.
  
  Returns:
      Variable, Variable, Variable, array, array:
      Returns tuple of five values listed below.
  
      * **roi_ag_seg_scores**: Class-agnostic clipped mask scores for                 the proposed ROIs. Its shape is :math:`(R', 2, RH, RW)`
      * **ag_locs**: Class-agnostic offsets and scalings for                 the proposed RoIs.  Its shape is :math:`(R', 2, 4)`.
      * **roi_cls_scores**: Class predictions for the proposed RoIs.                 Its shape is :math:`(R', L + 1)`.
      * **rois**: RoIs proposed by RPN. Its shape is                 :math:`(R', 4)`.
      * **roi_indices**: Batch indices of RoIs. Its shape is                 :math:`(R',)`.
docstr_tok: ["Forward","FCIS",".","Scaling","paramter",":","obj",":","`","scale","`","is","used","by","RPN","to","determine","the","threshold","to","select","small","objects",",","which","are","going","to","be","rejected","irrespective","of","their","confidence","scores",".","Here","are","notations","used",".","*",":","math",":","`","N","`","is","the","number","of","batch","size","*",":","math",":","`","R","'","`","is","the","total","number","of","RoIs","produced","across","batches",".","Given",":","math",":","`","R_i","`","proposed","RoIs","from","the",":","math",":","`","i","`","th","image",",",":","math",":","`","R","'","=","\\sum","_","{","i=1","}","^","N","R_i","`",".","*",":","math",":","`","L","`","is","the","number","of","classes","excluding","the","background",".","*",":","math",":","`","RH","`","is","the","height","of","pooled","image","by","Position","Sensitive","ROI","pooling",".","*",":","math",":","`","RW","`","is","the","height","of","pooled","image","by","Position","Sensitive","ROI","pooling",".","Classes","are","ordered","by","the","background",",","the","first","class",",","...",",","and","the",":","math",":","`","L","`","th","class",".","Args",":","x","(","~chainer.Variable",")",":","4D","image","variable",".","scales","(","tuple","of","floats",")",":","Amount","of","scaling","applied","to","each","input","image","during","preprocessing",".","Returns",":","Variable",",","Variable",",","Variable",",","array",",","array",":","Returns","tuple","of","five","values","listed","below",".","*","*","*","roi_ag_seg_scores","*","*",":","Class-agnostic","clipped","mask","scores","for","the","proposed","ROIs",".","Its","shape","is",":","math",":","`","(","R","'",",","2",",","RH",",","RW",")","`","*","*","*","ag_locs","*","*",":","Class-agnostic","offsets","and","scalings","for","the","proposed","RoIs",".","Its","shape","is",":","math",":","`","(","R","'",",","2",",","4",")","`",".","*","*","*","roi_cls_scores","*","*",":","Class","predictions","for","the","proposed","RoIs",".","Its","shape","is",":","math",":","`","(","R","'",",","L","+","1",")","`",".","*","*","*","rois","*","*",":","RoIs","proposed","by","RPN",".","Its","shape","is",":","math",":","`","(","R","'",",","4",")","`",".","*","*","*","roi_indices","*","*",":","Batch","indices","of","RoIs",".","Its","shape","is",":","math",":","`","(","R","'",",",")","`","."]
code: def forward(self, x, scales=None):
      """Forward FCIS.
  
          Scaling paramter :obj:`scale` is used by RPN to determine the
          threshold to select small objects, which are going to be
          rejected irrespective of their confidence scores.
  
          Here are notations used.
  
          * :math:`N` is the number of batch size
          * :math:`R'` is the total number of RoIs produced across batches. \
              Given :math:`R_i` proposed RoIs from the :math:`i` th image, \
              :math:`R' = \\sum _{i=1} ^ N R_i`.
          * :math:`L` is the number of classes excluding the background.
          * :math:`RH` is the height of pooled image by Position Sensitive \
              ROI pooling.
          * :math:`RW` is the height of pooled image by Position Sensitive \
              ROI pooling.
  
          Classes are ordered by the background, the first class, ..., and
          the :math:`L` th class.
  
          Args:
              x (~chainer.Variable): 4D image variable.
              scales (tuple of floats): Amount of scaling applied to each input
                  image during preprocessing.
  
          Returns:
              Variable, Variable, Variable, array, array:
              Returns tuple of five values listed below.
  
              * **roi_ag_seg_scores**: Class-agnostic clipped mask scores for \
                  the proposed ROIs. Its shape is :math:`(R', 2, RH, RW)`
              * **ag_locs**: Class-agnostic offsets and scalings for \
                  the proposed RoIs.  Its shape is :math:`(R', 2, 4)`.
              * **roi_cls_scores**: Class predictions for the proposed RoIs. \
                  Its shape is :math:`(R', L + 1)`.
              * **rois**: RoIs proposed by RPN. Its shape is \
                  :math:`(R', 4)`.
              * **roi_indices**: Batch indices of RoIs. Its shape is \
                  :math:`(R',)`.
  
          """
      img_size = x.shape[2:]
  
      # Feature Extractor
      rpn_features, roi_features = self.extractor(x)
      rpn_locs, rpn_scores, rois, roi_indices, anchor = self.rpn(
          rpn_features, img_size, scales
      )
      (
          roi_ag_seg_scores,
          roi_ag_locs,
          roi_cls_scores,
          rois,
          roi_indices,
      ) = self.head(roi_features, rois, roi_indices, img_size)
      return (
          roi_ag_seg_scores,
          roi_ag_locs,
          roi_cls_scores,
          rois,
          roi_indices,
      )
  
file_path: chainercv/chainercv/experimental/links/model/fcis/fcis.py
imports: from __future__ import division
  import chainer
  import chainer.functions
  import numpy
  from chainercv.experimental.links.model.fcis.utils.mask_voting import mask_voting
  from chainercv.transforms.image.resize import resize
label_desc: Use image node_id 3 for calling the FCIS obj's underlying member method code with example usage: obj.forward(x, scales) and returns: roi_ag_seg_scores,  roi_ag_locs,  roi_cls_scores,  rois,  roi_indices