{
  "id": 314028,
  "title": "The Mask R-CNN Method. Is it supported by TensorFlow 2.0?",
  "url": "/competitions/hotel-id-to-combat-human-trafficking-2022-fgvc9/discussion/314028",
  "author_name": "",
  "post_date": "2022-03-20T14:20:47.001735100Z",
  "votes": 1,
  "comment_count": 2,
  "views": 0,
  "content": "<h1>Mask_RCNN project does not yet support TensorFlow 2.0.??</h1>\n<p>Since the  latest release Mask_RCNN 2.1 was on 2019, and all the GitHub sources have 3/4 years, I hope that anyone could make a Mask_RCNN on this Hotel/human trafficking 2022 Competition.</p>\n<p>Besides, I'm having some issues with AttributeError: module 'keras.engine' has no attribute 'Layer'  and couldn't proceed with \"My Mask_RCNN\"  project.</p>\n<h1>The Region-Based Convolutional Neural Network</h1>\n<p>\"How to Use Mask R-CNN in Keras for Object Detection in Photographs\"<br>\nby Jason Brownlee on May 24, 2019</p>\n<p>\"The Region-Based Convolutional Neural Network, or R-CNN, is a family of convolutional neural network models designed for object detection, developed by Ross Girshick, et al.\"</p>\n<p>\"There are perhaps four main variations of the approach, resulting in the current pinnacle called Mask R-CNN.\" </p>\n<p>\"R-CNN: Bounding boxes are proposed by the “selective search” algorithm, each of which is stretched and features are extracted via a deep convolutional neural network, such as AlexNet, before a final set of object classifications are made with linear SVMs.\"</p>\n<p>\"Fast R-CNN: Simplified design with a single model, bounding boxes are still specified as input, but a region-of-interest pooling layer is used after the deep CNN to consolidate regions and the model predicts both class labels and regions of interest directly.\"</p>\n<p>\"Faster R-CNN: Addition of a Region Proposal Network that interprets features extracted from the deep CNN and learns to propose regions-of-interest directly.\"</p>\n<p>\"Mask R-CNN: Extension of Faster R-CNN that adds an output model for predicting a mask for each detected object.\"</p>\n<p><a href=\"https://machinelearningmastery.com/how-to-perform-object-detection-in-photographs-with-mask-r-cnn-in-keras/\" target=\"_blank\">https://machinelearningmastery.com/how-to-perform-object-detection-in-photographs-with-mask-r-cnn-in-keras/</a></p>\n<h1>Mask R-CNN</h1>\n<p>Authors: Kaiming He, Georgia Gkioxari, Piotr Dollár, Ross Girshick</p>\n<p>\"The authors approach detects objects in an image while simultaneously generating a high-quality segmentation mask for each instance. The method, called Mask R-CNN, extends Faster R-CNN by adding a branch for predicting an object mask in parallel with the existing branch for bounding box recognition.\"</p>\n<p>\"Mask R-CNN is simple to train and adds only a small overhead to Faster R-CNN, running at 5 fps. Moreover, Mask R-CNN is easy to generalize to other tasks, e.g., allowing us to estimate human poses in the same framework. Top results in all three tracks of the COCO suite of challenges, including instance segmentation, bounding-box object detection, and person keypoint detection.\"</p>\n<p>\"Without bells and whistles, Mask R-CNN outperforms all existing, single-model entries on every task, including the COCO 2016 challenge winners.\"</p>\n<p><a href=\"https://arxiv.org/abs/1703.06870\" target=\"_blank\">https://arxiv.org/abs/1703.06870</a><br>\n<a href=\"https://github.com/facebookresearch/Detectron\" target=\"_blank\">https://github.com/facebookresearch/Detectron</a></p>\n<h1>Object Detection Using Mask R-CNN with TensorFlow 1.14 and Keras</h1>\n<p>By Ahmed Fawzy Gad - (no date) 2021</p>\n<p>\"The latest release (Mask_RCNN 2.1) was published on March 20th, 2019. Since this date, no new releases were published.\"</p>\n<p>Mask_RCNN project does not yet support TensorFlow 2.0.??</p>\n<p>\"The  example used a pre-trained Mask R-CNN to detect the objects in the COCO dataset.\"</p>\n<p>\"Before the model is trained, the train and validation datasets are prepared using a child class of the mrcnn.utils.Dataset class. After preparing the model configuration parameters, the model can be trained.\"</p>\n<p><a href=\"https://blog.paperspace.com/mask-r-cnn-in-tensorflow-2-0/\" target=\"_blank\">https://blog.paperspace.com/mask-r-cnn-in-tensorflow-2-0/</a></p>",
  "messages": [
    {
      "id": "1729786",
      "postDate": "03/20/2022 14:20:47",
      "content": "<h1>Mask_RCNN project does not yet support TensorFlow 2.0.??</h1>\n<p>Since the  latest release Mask_RCNN 2.1 was on 2019, and all the GitHub sources have 3/4 years, I hope that anyone could make a Mask_RCNN on this Hotel/human trafficking 2022 Competition.</p>\n<p>Besides, I'm having some issues with AttributeError: module 'keras.engine' has no attribute 'Layer'  and couldn't proceed with \"My Mask_RCNN\"  project.</p>\n<h1>The Region-Based Convolutional Neural Network</h1>\n<p>\"How to Use Mask R-CNN in Keras for Object Detection in Photographs\"<br>\nby Jason Brownlee on May 24, 2019</p>\n<p>\"The Region-Based Convolutional Neural Network, or R-CNN, is a family of convolutional neural network models designed for object detection, developed by Ross Girshick, et al.\"</p>\n<p>\"There are perhaps four main variations of the approach, resulting in the current pinnacle called Mask R-CNN.\" </p>\n<p>\"R-CNN: Bounding boxes are proposed by the “selective search” algorithm, each of which is stretched and features are extracted via a deep convolutional neural network, such as AlexNet, before a final set of object classifications are made with linear SVMs.\"</p>\n<p>\"Fast R-CNN: Simplified design with a single model, bounding boxes are still specified as input, but a region-of-interest pooling layer is used after the deep CNN to consolidate regions and the model predicts both class labels and regions of interest directly.\"</p>\n<p>\"Faster R-CNN: Addition of a Region Proposal Network that interprets features extracted from the deep CNN and learns to propose regions-of-interest directly.\"</p>\n<p>\"Mask R-CNN: Extension of Faster R-CNN that adds an output model for predicting a mask for each detected object.\"</p>\n<p><a href=\"https://machinelearningmastery.com/how-to-perform-object-detection-in-photographs-with-mask-r-cnn-in-keras/\" target=\"_blank\">https://machinelearningmastery.com/how-to-perform-object-detection-in-photographs-with-mask-r-cnn-in-keras/</a></p>\n<h1>Mask R-CNN</h1>\n<p>Authors: Kaiming He, Georgia Gkioxari, Piotr Dollár, Ross Girshick</p>\n<p>\"The authors approach detects objects in an image while simultaneously generating a high-quality segmentation mask for each instance. The method, called Mask R-CNN, extends Faster R-CNN by adding a branch for predicting an object mask in parallel with the existing branch for bounding box recognition.\"</p>\n<p>\"Mask R-CNN is simple to train and adds only a small overhead to Faster R-CNN, running at 5 fps. Moreover, Mask R-CNN is easy to generalize to other tasks, e.g., allowing us to estimate human poses in the same framework. Top results in all three tracks of the COCO suite of challenges, including instance segmentation, bounding-box object detection, and person keypoint detection.\"</p>\n<p>\"Without bells and whistles, Mask R-CNN outperforms all existing, single-model entries on every task, including the COCO 2016 challenge winners.\"</p>\n<p><a href=\"https://arxiv.org/abs/1703.06870\" target=\"_blank\">https://arxiv.org/abs/1703.06870</a><br>\n<a href=\"https://github.com/facebookresearch/Detectron\" target=\"_blank\">https://github.com/facebookresearch/Detectron</a></p>\n<h1>Object Detection Using Mask R-CNN with TensorFlow 1.14 and Keras</h1>\n<p>By Ahmed Fawzy Gad - (no date) 2021</p>\n<p>\"The latest release (Mask_RCNN 2.1) was published on March 20th, 2019. Since this date, no new releases were published.\"</p>\n<p>Mask_RCNN project does not yet support TensorFlow 2.0.??</p>\n<p>\"The  example used a pre-trained Mask R-CNN to detect the objects in the COCO dataset.\"</p>\n<p>\"Before the model is trained, the train and validation datasets are prepared using a child class of the mrcnn.utils.Dataset class. After preparing the model configuration parameters, the model can be trained.\"</p>\n<p><a href=\"https://blog.paperspace.com/mask-r-cnn-in-tensorflow-2-0/\" target=\"_blank\">https://blog.paperspace.com/mask-r-cnn-in-tensorflow-2-0/</a></p>",
      "rawMarkdown": "#Mask_RCNN project does not yet support TensorFlow 2.0.??\n\nSince the  latest release Mask_RCNN 2.1 was on 2019, and all the GitHub sources have 3/4 years, I hope that anyone could make a Mask_RCNN on this Hotel/human trafficking 2022 Competition.\n\nBesides, I'm having some issues with AttributeError: module 'keras.engine' has no attribute 'Layer'  and couldn't proceed with \"My Mask_RCNN\"  project.\n\n\n#The Region-Based Convolutional Neural Network\n\n\"How to Use Mask R-CNN in Keras for Object Detection in Photographs\"\nby Jason Brownlee on May 24, 2019\n\n\"The Region-Based Convolutional Neural Network, or R-CNN, is a family of convolutional neural network models designed for object detection, developed by Ross Girshick, et al.\"\n\n\"There are perhaps four main variations of the approach, resulting in the current pinnacle called Mask R-CNN.\" \n\n\"R-CNN: Bounding boxes are proposed by the “selective search” algorithm, each of which is stretched and features are extracted via a deep convolutional neural network, such as AlexNet, before a final set of object classifications are made with linear SVMs.\"\n\n\"Fast R-CNN: Simplified design with a single model, bounding boxes are still specified as input, but a region-of-interest pooling layer is used after the deep CNN to consolidate regions and the model predicts both class labels and regions of interest directly.\"\n\n\"Faster R-CNN: Addition of a Region Proposal Network that interprets features extracted from the deep CNN and learns to propose regions-of-interest directly.\"\n\n\"Mask R-CNN: Extension of Faster R-CNN that adds an output model for predicting a mask for each detected object.\"\n\nhttps://machinelearningmastery.com/how-to-perform-object-detection-in-photographs-with-mask-r-cnn-in-keras/\n\n#Mask R-CNN\n\nAuthors: Kaiming He, Georgia Gkioxari, Piotr Dollár, Ross Girshick\n\n\"The authors approach detects objects in an image while simultaneously generating a high-quality segmentation mask for each instance. The method, called Mask R-CNN, extends Faster R-CNN by adding a branch for predicting an object mask in parallel with the existing branch for bounding box recognition.\"\n\n\"Mask R-CNN is simple to train and adds only a small overhead to Faster R-CNN, running at 5 fps. Moreover, Mask R-CNN is easy to generalize to other tasks, e.g., allowing us to estimate human poses in the same framework. Top results in all three tracks of the COCO suite of challenges, including instance segmentation, bounding-box object detection, and person keypoint detection.\"\n\n\"Without bells and whistles, Mask R-CNN outperforms all existing, single-model entries on every task, including the COCO 2016 challenge winners.\"\n\nhttps://arxiv.org/abs/1703.06870\nhttps://github.com/facebookresearch/Detectron\n\n#Object Detection Using Mask R-CNN with TensorFlow 1.14 and Keras\nBy Ahmed Fawzy Gad - (no date) 2021\n\n\"The latest release (Mask_RCNN 2.1) was published on March 20th, 2019. Since this date, no new releases were published.\"\n\nMask_RCNN project does not yet support TensorFlow 2.0.??\n\n\"The  example used a pre-trained Mask R-CNN to detect the objects in the COCO dataset.\"\n\n\"Before the model is trained, the train and validation datasets are prepared using a child class of the mrcnn.utils.Dataset class. After preparing the model configuration parameters, the model can be trained.\"\n\nhttps://blog.paperspace.com/mask-r-cnn-in-tensorflow-2-0/",
      "votes": null
    },
    {
      "id": "1730845",
      "postDate": "03/21/2022 17:04:31",
      "content": "<p><a href=\"https://www.kaggle.com/mpwolke\" target=\"_blank\">@mpwolke</a> This post was very informative. I am exposed to certain new stuff that I was not aware of like Fast R-CNN. Though I have a question. In this problem statement as we see that there are masks provided in a square and rectangular fashion. How do we use these? Is there a specific way in which we can superimpose these to the objects that my RCNN detects? Like I am super confused.</p>",
      "rawMarkdown": "mpwolke This post was very informative. I am exposed to certain new stuff that I was not aware of like Fast R-CNN. Though I have a question. In this problem statement as we see that there are masks provided in a square and rectangular fashion. How do we use these? Is there a specific way in which we can superimpose these to the objects that my RCNN detects? Like I am super confused.",
      "votes": null
    },
    {
      "id": "1730879",
      "postDate": "03/21/2022 17:53:43",
      "content": "<p>Hi Shiv, I'm confused too :)</p>\n<p>As I wrote on my other \" All masks have Retangular/Square shape?\" topic: </p>\n<p>\" In image segmentation, we have Semantic Segmentation and Instance Segmentation, and different Segmentation models like U-Net, Mask R-CNN.\" </p>\n<p>Firstly, I tried to work with U-Net since I've already made some Notebooks before. However, I was not well succeeded. Though I'll take with U-Net another shot.</p>\n<p>I tried to run some codes with Mask R-CNN, though I get stucked with Keras  ('tensorflow.keras.engine' has no attribute 'Layer').  Then, I realized that all the Kaggle Notebooks with Mask R-CNN have 3 years</p>\n<p>Now, preparing mask_rcnn  requires some replacements: </p>\n<p>To make predictions using Mask R-CNN in TensorFlow 2.0, there are 4 changes to be made in the mrcnn.model script:</p>\n<p>Replace tf.log() by tf.math.log()</p>\n<p>Replace tf.sets.set_intersection() by tf.sets.intersection()</p>\n<p>Replace tf.sparse_tensor_to_dense() by tf.sparse.to_dense()</p>\n<p>Replace tf.to_float() by tf.cast([value], tf.float32)</p>\n<p>To train the Mask R-CNN model in TensorFlow 2.0, a total of 9 changes were applied: 4 to support making predictions, and 5 to enable training.</p>\n<p>According to:   Ahmed Fawzy Gad<br>\n<a href=\"https://blog.paperspace.com/mask-r-cnn-tensorflow-2-0-keras/\" target=\"_blank\">https://blog.paperspace.com/mask-r-cnn-tensorflow-2-0-keras/</a></p>\n<p>With my (very low) proficiency level, that will not happen very soon.</p>\n<p>I hope anyone like David and Lonnie on LB can make a Public Notebook, so that we'll be able to learn with them.  </p>",
      "rawMarkdown": "Hi Shiv, I'm confused too :)\n\nAs I wrote on my other \" All masks have Retangular/Square shape?\" topic: \n\n\" In image segmentation, we have Semantic Segmentation and Instance Segmentation, and different Segmentation models like U-Net, Mask R-CNN.\" \n\nFirstly, I tried to work with U-Net since I've already made some Notebooks before. However, I was not well succeeded. Though I'll take with U-Net another shot.\n\nI tried to run some codes with Mask R-CNN, though I get stucked with Keras  ('tensorflow.keras.engine' has no attribute 'Layer').  Then, I realized that all the Kaggle Notebooks with Mask R-CNN have 3 years\n\nNow, preparing mask_rcnn  requires some replacements: \n\nTo make predictions using Mask R-CNN in TensorFlow 2.0, there are 4 changes to be made in the mrcnn.model script:\n\nReplace tf.log() by tf.math.log()\n\nReplace tf.sets.set_intersection() by tf.sets.intersection()\n\nReplace tf.sparse_tensor_to_dense() by tf.sparse.to_dense()\n\nReplace tf.to_float() by tf.cast([value], tf.float32)\n\nTo train the Mask R-CNN model in TensorFlow 2.0, a total of 9 changes were applied: 4 to support making predictions, and 5 to enable training.\n\nAccording to:   Ahmed Fawzy Gad\nhttps://blog.paperspace.com/mask-r-cnn-tensorflow-2-0-keras/\n\nWith my (very low) proficiency level, that will not happen very soon.\n\nI hope anyone like David and Lonnie on LB can make a Public Notebook, so that we'll be able to learn with them.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1730845,
      "author_name": "shivkumarganesh",
      "author_url": "",
      "post_date": "03/21/2022 17:04:31",
      "content": "<p><a href=\"https://www.kaggle.com/mpwolke\" target=\"_blank\">@mpwolke</a> This post was very informative. I am exposed to certain new stuff that I was not aware of like Fast R-CNN. Though I have a question. In this problem statement as we see that there are masks provided in a square and rectangular fashion. How do we use these? Is there a specific way in which we can superimpose these to the objects that my RCNN detects? Like I am super confused.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1730879,
          "author_name": "mpwolke",
          "author_url": "",
          "post_date": "03/21/2022 17:53:43",
          "content": "<p>Hi Shiv, I'm confused too :)</p>\n<p>As I wrote on my other \" All masks have Retangular/Square shape?\" topic: </p>\n<p>\" In image segmentation, we have Semantic Segmentation and Instance Segmentation, and different Segmentation models like U-Net, Mask R-CNN.\" </p>\n<p>Firstly, I tried to work with U-Net since I've already made some Notebooks before. However, I was not well succeeded. Though I'll take with U-Net another shot.</p>\n<p>I tried to run some codes with Mask R-CNN, though I get stucked with Keras  ('tensorflow.keras.engine' has no attribute 'Layer').  Then, I realized that all the Kaggle Notebooks with Mask R-CNN have 3 years</p>\n<p>Now, preparing mask_rcnn  requires some replacements: </p>\n<p>To make predictions using Mask R-CNN in TensorFlow 2.0, there are 4 changes to be made in the mrcnn.model script:</p>\n<p>Replace tf.log() by tf.math.log()</p>\n<p>Replace tf.sets.set_intersection() by tf.sets.intersection()</p>\n<p>Replace tf.sparse_tensor_to_dense() by tf.sparse.to_dense()</p>\n<p>Replace tf.to_float() by tf.cast([value], tf.float32)</p>\n<p>To train the Mask R-CNN model in TensorFlow 2.0, a total of 9 changes were applied: 4 to support making predictions, and 5 to enable training.</p>\n<p>According to:   Ahmed Fawzy Gad<br>\n<a href=\"https://blog.paperspace.com/mask-r-cnn-tensorflow-2-0-keras/\" target=\"_blank\">https://blog.paperspace.com/mask-r-cnn-tensorflow-2-0-keras/</a></p>\n<p>With my (very low) proficiency level, that will not happen very soon.</p>\n<p>I hope anyone like David and Lonnie on LB can make a Public Notebook, so that we'll be able to learn with them.  </p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1729786": "#Mask_RCNN project does not yet support TensorFlow 2.0.??\n\nSince the  latest release Mask_RCNN 2.1 was on 2019, and all the GitHub sources have 3/4 years, I hope that anyone could make a Mask_RCNN on this Hotel/human trafficking 2022 Competition.\n\nBesides, I'm having some issues with AttributeError: module 'keras.engine' has no attribute 'Layer'  and couldn't proceed with \"My Mask_RCNN\"  project.\n\n\n#The Region-Based Convolutional Neural Network\n\n\"How to Use Mask R-CNN in Keras for Object Detection in Photographs\"\nby Jason Brownlee on May 24, 2019\n\n\"The Region-Based Convolutional Neural Network, or R-CNN, is a family of convolutional neural network models designed for object detection, developed by Ross Girshick, et al.\"\n\n\"There are perhaps four main variations of the approach, resulting in the current pinnacle called Mask R-CNN.\" \n\n\"R-CNN: Bounding boxes are proposed by the “selective search” algorithm, each of which is stretched and features are extracted via a deep convolutional neural network, such as AlexNet, before a final set of object classifications are made with linear SVMs.\"\n\n\"Fast R-CNN: Simplified design with a single model, bounding boxes are still specified as input, but a region-of-interest pooling layer is used after the deep CNN to consolidate regions and the model predicts both class labels and regions of interest directly.\"\n\n\"Faster R-CNN: Addition of a Region Proposal Network that interprets features extracted from the deep CNN and learns to propose regions-of-interest directly.\"\n\n\"Mask R-CNN: Extension of Faster R-CNN that adds an output model for predicting a mask for each detected object.\"\n\nhttps://machinelearningmastery.com/how-to-perform-object-detection-in-photographs-with-mask-r-cnn-in-keras/\n\n#Mask R-CNN\n\nAuthors: Kaiming He, Georgia Gkioxari, Piotr Dollár, Ross Girshick\n\n\"The authors approach detects objects in an image while simultaneously generating a high-quality segmentation mask for each instance. The method, called Mask R-CNN, extends Faster R-CNN by adding a branch for predicting an object mask in parallel with the existing branch for bounding box recognition.\"\n\n\"Mask R-CNN is simple to train and adds only a small overhead to Faster R-CNN, running at 5 fps. Moreover, Mask R-CNN is easy to generalize to other tasks, e.g., allowing us to estimate human poses in the same framework. Top results in all three tracks of the COCO suite of challenges, including instance segmentation, bounding-box object detection, and person keypoint detection.\"\n\n\"Without bells and whistles, Mask R-CNN outperforms all existing, single-model entries on every task, including the COCO 2016 challenge winners.\"\n\nhttps://arxiv.org/abs/1703.06870\nhttps://github.com/facebookresearch/Detectron\n\n#Object Detection Using Mask R-CNN with TensorFlow 1.14 and Keras\nBy Ahmed Fawzy Gad - (no date) 2021\n\n\"The latest release (Mask_RCNN 2.1) was published on March 20th, 2019. Since this date, no new releases were published.\"\n\nMask_RCNN project does not yet support TensorFlow 2.0.??\n\n\"The  example used a pre-trained Mask R-CNN to detect the objects in the COCO dataset.\"\n\n\"Before the model is trained, the train and validation datasets are prepared using a child class of the mrcnn.utils.Dataset class. After preparing the model configuration parameters, the model can be trained.\"\n\nhttps://blog.paperspace.com/mask-r-cnn-in-tensorflow-2-0/",
    "1730845": "mpwolke This post was very informative. I am exposed to certain new stuff that I was not aware of like Fast R-CNN. Though I have a question. In this problem statement as we see that there are masks provided in a square and rectangular fashion. How do we use these? Is there a specific way in which we can superimpose these to the objects that my RCNN detects? Like I am super confused.",
    "1730879": "Hi Shiv, I'm confused too :)\n\nAs I wrote on my other \" All masks have Retangular/Square shape?\" topic: \n\n\" In image segmentation, we have Semantic Segmentation and Instance Segmentation, and different Segmentation models like U-Net, Mask R-CNN.\" \n\nFirstly, I tried to work with U-Net since I've already made some Notebooks before. However, I was not well succeeded. Though I'll take with U-Net another shot.\n\nI tried to run some codes with Mask R-CNN, though I get stucked with Keras  ('tensorflow.keras.engine' has no attribute 'Layer').  Then, I realized that all the Kaggle Notebooks with Mask R-CNN have 3 years\n\nNow, preparing mask_rcnn  requires some replacements: \n\nTo make predictions using Mask R-CNN in TensorFlow 2.0, there are 4 changes to be made in the mrcnn.model script:\n\nReplace tf.log() by tf.math.log()\n\nReplace tf.sets.set_intersection() by tf.sets.intersection()\n\nReplace tf.sparse_tensor_to_dense() by tf.sparse.to_dense()\n\nReplace tf.to_float() by tf.cast([value], tf.float32)\n\nTo train the Mask R-CNN model in TensorFlow 2.0, a total of 9 changes were applied: 4 to support making predictions, and 5 to enable training.\n\nAccording to:   Ahmed Fawzy Gad\nhttps://blog.paperspace.com/mask-r-cnn-tensorflow-2-0-keras/\n\nWith my (very low) proficiency level, that will not happen very soon.\n\nI hope anyone like David and Lonnie on LB can make a Public Notebook, so that we'll be able to learn with them."
  },
  "source": "meta"
}