parameters: (net, image_name)
return_statement: return detection_out
docstring: Detect object classes in an image using pre-computed object proposals.
docstring_summary: Detect object classes in an image using pre-computed object proposals.
docstring_tokens: Detect object classes in an image using pre - computed object proposals .
function: def extract(net, image_name):
      """Detect object classes in an image using pre-computed object proposals."""
  
      # Load the demo image
      im_file = os.path.join(cfg.DATA_DIR, 'demo', image_name)
      im = cv2.imread(im_file)
  
      # Detect all object classes and regress object bounds
      timer = Timer()
      timer.tic()
      scores, boxes = im_detect(net, im)
      timer.toc()
  
      # Visualize detections for each class
      CONF_THRESH = 0.8
      NMS_THRESH = 0.3
  
      detection_out = np.reshape(np.array([None] * 7), [1, 7])
      for cls_ind, cls in enumerate(CLASSES[1:]):
          cls_ind += 1  # because we skipped background
          cls_boxes = boxes[:, 4:8]
          cls_scores = scores[:, cls_ind]
          dets = np.hstack((cls_boxes,
                            cls_scores[:, np.newaxis])).astype(np.float32)
          keep = nms(dets, NMS_THRESH)
          dets = dets[keep, :]
          dout = np.zeros([dets.shape[0], 7])
          dout[:, 1] = cls_ind
          dout[:, 2] = dets[:, 4]
          dout[:, 3] = dets[:, 0] / im.shape[1]
          dout[:, 4] = dets[:, 1] / im.shape[0]
          dout[:, 5] = dets[:, 2] / im.shape[1]
          dout[:, 6] = dets[:, 3] / im.shape[0]
          detection_out = np.concatenate((detection_out, dout), axis=0)
      detection_out = np.delete(detection_out, 0, axis=0)
      detection_out = np.reshape(detection_out, [1, 1, detection_out.shape[0], detection_out.shape[1]])
      return detection_out
function_tokens: def extract ( net , image_name ) : # Load the demo image im_file = os . path . join ( cfg . DATA_DIR , 'demo' , image_name ) im = cv2 . imread ( im_file ) # Detect all object classes and regress object bounds timer = Timer ( ) timer . tic ( ) scores , boxes = im_detect ( net , im ) timer . toc ( ) # Visualize detections for each class CONF_THRESH = 0.8 NMS_THRESH = 0.3 detection_out = np . reshape ( np . array ( [ None ] * 7 ) , [ 1 , 7 ] ) for cls_ind , cls in enumerate ( CLASSES [ 1 : ] ) : cls_ind += 1 # because we skipped background cls_boxes = boxes [ : , 4 : 8 ] cls_scores = scores [ : , cls_ind ] dets = np . hstack ( ( cls_boxes , cls_scores [ : , np . newaxis ] ) ) . astype ( np . float32 ) keep = nms ( dets , NMS_THRESH ) dets = dets [ keep , : ] dout = np . zeros ( [ dets . shape [ 0 ] , 7 ] ) dout [ : , 1 ] = cls_ind dout [ : , 2 ] = dets [ : , 4 ] dout [ : , 3 ] = dets [ : , 0 ] / im . shape [ 1 ] dout [ : , 4 ] = dets [ : , 1 ] / im . shape [ 0 ] dout [ : , 5 ] = dets [ : , 2 ] / im . shape [ 1 ] dout [ : , 6 ] = dets [ : , 3 ] / im . shape [ 0 ] detection_out = np . concatenate ( ( detection_out , dout ) , axis = 0 ) detection_out = np . delete ( detection_out , 0 , axis = 0 ) detection_out = np . reshape ( detection_out , [ 1 , 1 , detection_out . shape [ 0 ] , detection_out . shape [ 1 ] ] ) return detection_out