{
  "id": 412817,
  "title": "Clarity on what exactly is required by participants to submit as the result or output.",
  "url": "/competitions/hubmap-hacking-the-human-vasculature/discussion/412817",
  "author_name": "Tanush Mahajan",
  "post_date": "2023-05-25T11:38:58.833000",
  "votes": 8,
  "comment_count": 3,
  "views": 0,
  "content": "<p>Hi Everyone, <br>\nI understand the problem statement requires us to create a model to detect vasculatures in Human Tissue. <br>\nNeeded some help to understand what do we need to submit as a result, It is my understanding the output should contain some data in some specific format and I need someone's help to understand that.</p>\n<p>PS: Relatively new to ML, AI stuff. </p>\n<p>Thanks. </p>",
  "messages": [
    {
      "id": 2273766,
      "postDate": "2023-05-25T11:52:53.843Z",
      "content": "<p>Basically you need to construct a model that is able to segment (highlight or produce a binary mask where 1 is the microvascular instance in the tissue and 0 is the rest).<br>\nThen you need to transform this mask to polygons (since each region can be en-globed into some sort of polygon)<br>\nThe coordinates of these polygons for each mask must be encoded in a certain way defined here:  <a href=\"https://www.kaggle.com/competitions/hubmap-hacking-the-human-vasculature/overview/evaluation\" target=\"_blank\">Evaluation</a><br>\nTo explain it further, the submission file should be of the format:</p>\n<pre><code>,height,width,prediction_string\n72e40acccadf,,,  eNoLTDAwyrM3yI/PMwcAE94DZA==\n</code></pre>\n<p>where <code>prediction_string</code> has the format <code>0 {confidence} {EncodedPolygon}</code></p>\n<p>In case your mask has multiple polygons i.e multiple instances are detected in one image then the <code>prediction_string</code> would be:</p>\n<p><code>0 {confidence_1} {EncodedPolygon_1} 0 {confidence_2} {EncodedPolygon_2} 0 {confidence_3} {EncodedPolygon_3}</code></p>\n<p>each one starts with 0 and they are seperated by a space ' '</p>\n<p>The <code>EncodedPolygon</code> is obtained using the following steps:</p>\n<p>The binary segmentation masks are run-length encoded (RLE), zlib compressed, and base64 encoded to be used in text format as EncodedMask. Specifically, we use the Coco masks RLE encoding/decoding (see the encode method of COCO’s mask API), the zlib compression/decompression (RFC1950), and vanilla base64 encoding.</p>\n<p>This is an example function that they gave also here : <a href=\"https://www.kaggle.com/competitions/hubmap-hacking-the-human-vasculature/overview/evaluation\" target=\"_blank\">Evaluation</a></p>\n<pre><code> base64\n numpy  np\n pycocotools  _mask  coco_mask\n typing  t\n zlib\n\n\n () -&gt; t.Text:\n  \n\n  \n   mask.dtype != np.:\n     ValueError(\n         %\n        mask.dtype)\n\n  mask = np.squeeze(mask)\n   (mask.shape) != :\n     ValueError(\n         %\n        mask.shape)\n\n  \n  mask_to_encode = mask.reshape(mask.shape[], mask.shape[], )\n  mask_to_encode = mask_to_encode.astype(np.uint8)\n  mask_to_encode = np.asfortranarray(mask_to_encode)\n\n  \n  encoded_mask = coco_mask.encode(mask_to_encode)[][]\n\n  \n  binary_str = zlib.compress(encoded_mask, zlib.Z_BEST_COMPRESSION)\n  base64_str = base64.b64encode(binary_str)\n   base64_str\n</code></pre>",
      "rawMarkdown": "Basically you need to construct a model that is able to segment (highlight or produce a binary mask where 1 is the microvascular instance in the tissue and 0 is the rest).\nThen you need to transform this mask to polygons (since each region can be en-globed into some sort of polygon)\nThe coordinates of these polygons for each mask must be encoded in a certain way defined here:  [Evaluation](https://www.kaggle.com/competitions/hubmap-hacking-the-human-vasculature/overview/evaluation)\nTo explain it further, the submission file should be of the format:\n```python\nid,height,width,prediction_string\n72e40acccadf,512,512,0 1.0 eNoLTDAwyrM3yI/PMwcAE94DZA==\n```\nwhere `prediction_string` has the format `0 {confidence} {EncodedPolygon}`\n\nIn case your mask has multiple polygons i.e multiple instances are detected in one image then the `prediction_string` would be:\n\n`0 {confidence_1} {EncodedPolygon_1} 0 {confidence_2} {EncodedPolygon_2} 0 {confidence_3} {EncodedPolygon_3}`\n\neach one starts with 0 and they are seperated by a space ' '\n\nThe `EncodedPolygon` is obtained using the following steps:\n\nThe binary segmentation masks are run-length encoded (RLE), zlib compressed, and base64 encoded to be used in text format as EncodedMask. Specifically, we use the Coco masks RLE encoding/decoding (see the encode method of COCO’s mask API), the zlib compression/decompression (RFC1950), and vanilla base64 encoding.\n\nThis is an example function that they gave also here : [Evaluation](https://www.kaggle.com/competitions/hubmap-hacking-the-human-vasculature/overview/evaluation)\n\n```python\nimport base64\nimport numpy as np\nfrom pycocotools import _mask as coco_mask\nimport typing as t\nimport zlib\n\n\ndef encode_binary_mask(mask: np.ndarray) -> t.Text:\n  \"\"\"Converts a binary mask into OID challenge encoding ascii text.\"\"\"\n\n  # check input mask --\n  if mask.dtype != np.bool:\n    raise ValueError(\n        \"encode_binary_mask expects a binary mask, received dtype == %s\" %\n        mask.dtype)\n\n  mask = np.squeeze(mask)\n  if len(mask.shape) != 2:\n    raise ValueError(\n        \"encode_binary_mask expects a 2d mask, received shape == %s\" %\n        mask.shape)\n\n  # convert input mask to expected COCO API input --\n  mask_to_encode = mask.reshape(mask.shape[0], mask.shape[1], 1)\n  mask_to_encode = mask_to_encode.astype(np.uint8)\n  mask_to_encode = np.asfortranarray(mask_to_encode)\n\n  # RLE encode mask --\n  encoded_mask = coco_mask.encode(mask_to_encode)[0][\"counts\"]\n\n  # compress and base64 encoding --\n  binary_str = zlib.compress(encoded_mask, zlib.Z_BEST_COMPRESSION)\n  base64_str = base64.b64encode(binary_str)\n  return base64_str\n\n```",
      "votes": 14,
      "replies": [
        {
          "id": 2277045,
          "postDate": "2023-05-27T11:49:32Z",
          "content": "<p>This explanation is great. Appreciate you taking the time to post this thanks :)</p>",
          "rawMarkdown": "This explanation is great. Appreciate you taking the time to post this thanks :)\n",
          "votes": 1
        },
        {
          "id": 2285994,
          "postDate": "2023-06-03T06:37:06.977Z",
          "rawMarkdown": "",
          "isDeleted": true
        }
      ]
    },
    {
      "id": 2273751,
      "postDate": "2023-05-25T11:38:58.833Z",
      "content": "<p>Hi Everyone, <br>\nI understand the problem statement requires us to create a model to detect vasculatures in Human Tissue. <br>\nNeeded some help to understand what do we need to submit as a result, It is my understanding the output should contain some data in some specific format and I need someone's help to understand that.</p>\n<p>PS: Relatively new to ML, AI stuff. </p>\n<p>Thanks. </p>",
      "rawMarkdown": "Hi Everyone, \nI understand the problem statement requires us to create a model to detect vasculatures in Human Tissue. \nNeeded some help to understand what do we need to submit as a result, It is my understanding the output should contain some data in some specific format and I need someone's help to understand that.\n\nPS: Relatively new to ML, AI stuff. \n\nThanks. \n",
      "votes": 8
    }
  ],
  "comments": [
    {
      "id": 2273766,
      "author_name": "Mohamed Amine DHIAB",
      "author_url": "",
      "post_date": "2023-05-25T11:52:53.843000",
      "content": "<p>Basically you need to construct a model that is able to segment (highlight or produce a binary mask where 1 is the microvascular instance in the tissue and 0 is the rest).<br>\nThen you need to transform this mask to polygons (since each region can be en-globed into some sort of polygon)<br>\nThe coordinates of these polygons for each mask must be encoded in a certain way defined here:  <a href=\"https://www.kaggle.com/competitions/hubmap-hacking-the-human-vasculature/overview/evaluation\" target=\"_blank\">Evaluation</a><br>\nTo explain it further, the submission file should be of the format:</p>\n<pre><code>,height,width,prediction_string\n72e40acccadf,,,  eNoLTDAwyrM3yI/PMwcAE94DZA==\n</code></pre>\n<p>where <code>prediction_string</code> has the format <code>0 {confidence} {EncodedPolygon}</code></p>\n<p>In case your mask has multiple polygons i.e multiple instances are detected in one image then the <code>prediction_string</code> would be:</p>\n<p><code>0 {confidence_1} {EncodedPolygon_1} 0 {confidence_2} {EncodedPolygon_2} 0 {confidence_3} {EncodedPolygon_3}</code></p>\n<p>each one starts with 0 and they are seperated by a space ' '</p>\n<p>The <code>EncodedPolygon</code> is obtained using the following steps:</p>\n<p>The binary segmentation masks are run-length encoded (RLE), zlib compressed, and base64 encoded to be used in text format as EncodedMask. Specifically, we use the Coco masks RLE encoding/decoding (see the encode method of COCO’s mask API), the zlib compression/decompression (RFC1950), and vanilla base64 encoding.</p>\n<p>This is an example function that they gave also here : <a href=\"https://www.kaggle.com/competitions/hubmap-hacking-the-human-vasculature/overview/evaluation\" target=\"_blank\">Evaluation</a></p>\n<pre><code> base64\n numpy  np\n pycocotools  _mask  coco_mask\n typing  t\n zlib\n\n\n () -&gt; t.Text:\n  \n\n  \n   mask.dtype != np.:\n     ValueError(\n         %\n        mask.dtype)\n\n  mask = np.squeeze(mask)\n   (mask.shape) != :\n     ValueError(\n         %\n        mask.shape)\n\n  \n  mask_to_encode = mask.reshape(mask.shape[], mask.shape[], )\n  mask_to_encode = mask_to_encode.astype(np.uint8)\n  mask_to_encode = np.asfortranarray(mask_to_encode)\n\n  \n  encoded_mask = coco_mask.encode(mask_to_encode)[][]\n\n  \n  binary_str = zlib.compress(encoded_mask, zlib.Z_BEST_COMPRESSION)\n  base64_str = base64.b64encode(binary_str)\n   base64_str\n</code></pre>",
      "votes": 14,
      "replies": [
        {
          "id": 2277045,
          "author_name": "Tanush Mahajan",
          "author_url": "",
          "post_date": "2023-05-27T11:49:32",
          "content": "<p>This explanation is great. Appreciate you taking the time to post this thanks :)</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 2285994,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-06-03T06:37:06.977000",
          "content": "",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2273766": "Basically you need to construct a model that is able to segment (highlight or produce a binary mask where 1 is the microvascular instance in the tissue and 0 is the rest).\nThen you need to transform this mask to polygons (since each region can be en-globed into some sort of polygon)\nThe coordinates of these polygons for each mask must be encoded in a certain way defined here:  [Evaluation](https://www.kaggle.com/competitions/hubmap-hacking-the-human-vasculature/overview/evaluation)\nTo explain it further, the submission file should be of the format:\n```python\nid,height,width,prediction_string\n72e40acccadf,512,512,0 1.0 eNoLTDAwyrM3yI/PMwcAE94DZA==\n```\nwhere `prediction_string` has the format `0 {confidence} {EncodedPolygon}`\n\nIn case your mask has multiple polygons i.e multiple instances are detected in one image then the `prediction_string` would be:\n\n`0 {confidence_1} {EncodedPolygon_1} 0 {confidence_2} {EncodedPolygon_2} 0 {confidence_3} {EncodedPolygon_3}`\n\neach one starts with 0 and they are seperated by a space ' '\n\nThe `EncodedPolygon` is obtained using the following steps:\n\nThe binary segmentation masks are run-length encoded (RLE), zlib compressed, and base64 encoded to be used in text format as EncodedMask. Specifically, we use the Coco masks RLE encoding/decoding (see the encode method of COCO’s mask API), the zlib compression/decompression (RFC1950), and vanilla base64 encoding.\n\nThis is an example function that they gave also here : [Evaluation](https://www.kaggle.com/competitions/hubmap-hacking-the-human-vasculature/overview/evaluation)\n\n```python\nimport base64\nimport numpy as np\nfrom pycocotools import _mask as coco_mask\nimport typing as t\nimport zlib\n\n\ndef encode_binary_mask(mask: np.ndarray) -> t.Text:\n  \"\"\"Converts a binary mask into OID challenge encoding ascii text.\"\"\"\n\n  # check input mask --\n  if mask.dtype != np.bool:\n    raise ValueError(\n        \"encode_binary_mask expects a binary mask, received dtype == %s\" %\n        mask.dtype)\n\n  mask = np.squeeze(mask)\n  if len(mask.shape) != 2:\n    raise ValueError(\n        \"encode_binary_mask expects a 2d mask, received shape == %s\" %\n        mask.shape)\n\n  # convert input mask to expected COCO API input --\n  mask_to_encode = mask.reshape(mask.shape[0], mask.shape[1], 1)\n  mask_to_encode = mask_to_encode.astype(np.uint8)\n  mask_to_encode = np.asfortranarray(mask_to_encode)\n\n  # RLE encode mask --\n  encoded_mask = coco_mask.encode(mask_to_encode)[0][\"counts\"]\n\n  # compress and base64 encoding --\n  binary_str = zlib.compress(encoded_mask, zlib.Z_BEST_COMPRESSION)\n  base64_str = base64.b64encode(binary_str)\n  return base64_str\n\n```",
    "2273751": "Hi Everyone, \nI understand the problem statement requires us to create a model to detect vasculatures in Human Tissue. \nNeeded some help to understand what do we need to submit as a result, It is my understanding the output should contain some data in some specific format and I need someone's help to understand that.\n\nPS: Relatively new to ML, AI stuff. \n\nThanks. \n"
  }
}