SHARE
TWEET

Untitled

a guest Jun 18th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 31   net.setInput(blob)
  2.      32   start = time.time()
  3. ---> 33   (boxes, masks) = net.forward(["detection_out_final", "detection_masks"])
  4.      34   end = time.time()
  5.      35
  6.  
  7. error: OpenCV(3.4.3) /io/opencv/modules/core/src/matrix.cpp:540: error: (-215:Assertion failed) r == Range::all() || (0 <= r.start && r.start < r.end && r.end <= m.size[i]) in function 'Mat'
  8.      
  9. images=[]
  10. labelsPath = "CODE/mask-rcnn/mask-rcnn-coco/object_detection_classes_coco.txt"
  11. LABELS = open(labelsPath).read().strip().split("n")
  12.  
  13. # load the set of colors that will be used when visualizing a given
  14. # instance segmentation
  15. colorsPath = "CODE/mask-rcnn/mask-rcnn-coco/colors.txt"
  16. COLORS = open(colorsPath).read().strip().split("n")
  17. COLORS = [np.array(c.split(",")).astype("int") for c in COLORS]
  18. COLORS = np.array(COLORS, dtype="uint8")
  19.  
  20. # derive the paths to the Mask R-CNN weights and model configuration
  21. weightsPath = "CODE/mask-rcnn/mask-rcnn-coco/frozen_inference_graph.pb"
  22. configPath = "CODE/mask-rcnn/mask-rcnn-coco/mask_rcnn_inception_v2_coco_2018_01_28.pbtxt"
  23.  
  24. # load our Mask R-CNN trained on the COCO dataset (90 classes)
  25. # from disk
  26. print("[INFO] loading Mask R-CNN from disk...")
  27. net = cv2.dnn.readNetFromTensorflow(weightsPath, configPath)
  28.  
  29. # load our input image and grab its spatial dimensions
  30. for i in range(len(int_l)):
  31.   img_name = "roi"+str(i+1)+".png"
  32.   image = cv2.imread(img_name)
  33.  
  34.   # construct a blob from the input image and then perform a forward
  35.   # pass of the Mask R-CNN, giving us (1) the bounding box  coordinates
  36.   # of the objects in the image along with (2) the pixel-wise segmentation
  37.   # for each specific object
  38.   blob = cv2.dnn.blobFromImage(image, swapRB=True, crop=False)
  39.   net.setInput(blob)
  40.   start = time.time()
  41.   (boxes, masks) = net.forward(["detection_out_final", "detection_masks"])
  42.   end = time.time()
  43.  
  44.   # show timing information and volume information on Mask R-CNN
  45.   print("[INFO] Mask R-CNN took {:.6f} seconds".format(end - start))
  46.   print("[INFO] boxes shape: {}".format(boxes.shape))
  47.   print("[INFO] masks shape: {}".format(masks.shape))
  48.  
  49.   for i in range(0, boxes.shape[2]):
  50.     classID = int(boxes[0, 0, i, 1])
  51.     confidence = boxes[0, 0, i, 2]
  52.     print(LABELS[classID]," ",confidence)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top