{
  "id": 215772,
  "title": "Could anyone explain me the logic behind PredictionString for Submission.",
  "url": "/competitions/hpa-single-cell-image-classification/discussion/215772",
  "author_name": "Victor Basu",
  "post_date": "2021-01-31T05:55:38.884000",
  "votes": 1,
  "comment_count": 1,
  "views": 0,
  "content": "<p>In the final Submission.csv file, the final prediction is the prediction string which is the predicted cell level labels in the image through segmentation. But how is the prediction string generated or based on what logic or formula is the predicted string generated? </p>\n<blockquote>\n  <p>prediction String  -&gt;  0 1 eNqcvOeW20CyrflKCUdbqpJURQvCEx4gvCeA9/<br>\n  83O8CSWn3umblrTffqZu4vIw3SRpRAsvrOeTtzzfAfTnv9P/33/67x/3J4mEq12hkhFx3mUi13OqX0Cqk54OKDQamJUmal5rsx4JKDVa<br>\n  nZ7hlw6eFOqZ5SDqVayvUqtdiVxKJKTXdJwFWHrFKjXRxw9aGo1GAXBlx<br>\n  7aCrV2bkB9zz0lWrt7gE3H56Vqu+sgDOPY6VOWyPgHEp1WzPgAkpVlIqOM3q1nX<br>\n  0uPlq1mm8Hn0uPdq2m287nsqNXq49tS6mgVpNtSakHpTKyS2s12yY+9zgWVDb0ueR<br>\n  YU1mf7Ppajbd3nyuOU61GW9PnyuNcq+HW8LnqaDRqsJ08rj5alHpSyqZUTym3Uf1t53HN<br>\n  0W9Ud9t4XHcMG9XZlh7XH+NGtbeFxw3HR6Pet7nHPY8JpVJKZZR6UConu5jsSmIRsa5R9a3jcfppbNRp<br>\n  Y3qceZoppVPKaJGaXKTurfrcDC7nnOxW7Tc9pdxW7Tady7knr1XbTeNywclv1XpTuVx0Clu13BQu9zjFrZpvckolr<br>\n  ZptMpdLTmmrppvU5TJKJZuEUnmr…</p>\n</blockquote>\n<p>what does this signify?</p>",
  "messages": [
    {
      "id": 1179296,
      "postDate": "2021-01-31T13:42:22.047Z",
      "content": "<p>From the <a href=\"https://www.kaggle.com/c/hpa-single-cell-image-classification/overview/evaluation\" target=\"_blank\">official description</a>:</p>\n<blockquote>\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>An example python function to encode an instance segmentation mask would be:</p>\n</blockquote>\n<pre><code>import 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) -&gt; 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</code></pre>",
      "rawMarkdown": "From the [official description](https://www.kaggle.com/c/hpa-single-cell-image-classification/overview/evaluation):\n\n> 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.\n\n> An example python function to encode an instance segmentation mask would be:\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```",
      "votes": 3
    },
    {
      "id": 1178796,
      "postDate": "2021-01-31T05:55:38.883Z",
      "content": "<p>In the final Submission.csv file, the final prediction is the prediction string which is the predicted cell level labels in the image through segmentation. But how is the prediction string generated or based on what logic or formula is the predicted string generated? </p>\n<blockquote>\n  <p>prediction String  -&gt;  0 1 eNqcvOeW20CyrflKCUdbqpJURQvCEx4gvCeA9/<br>\n  83O8CSWn3umblrTffqZu4vIw3SRpRAsvrOeTtzzfAfTnv9P/33/67x/3J4mEq12hkhFx3mUi13OqX0Cqk54OKDQamJUmal5rsx4JKDVa<br>\n  nZ7hlw6eFOqZ5SDqVayvUqtdiVxKJKTXdJwFWHrFKjXRxw9aGo1GAXBlx<br>\n  7aCrV2bkB9zz0lWrt7gE3H56Vqu+sgDOPY6VOWyPgHEp1WzPgAkpVlIqOM3q1nX<br>\n  0uPlq1mm8Hn0uPdq2m287nsqNXq49tS6mgVpNtSakHpTKyS2s12yY+9zgWVDb0ueR<br>\n  YU1mf7Ppajbd3nyuOU61GW9PnyuNcq+HW8LnqaDRqsJ08rj5alHpSyqZUTym3Uf1t53HN<br>\n  0W9Ud9t4XHcMG9XZlh7XH+NGtbeFxw3HR6Pet7nHPY8JpVJKZZR6UConu5jsSmIRsa5R9a3jcfppbNRp<br>\n  Y3qceZoppVPKaJGaXKTurfrcDC7nnOxW7Tc9pdxW7Tady7knr1XbTeNywclv1XpTuVx0Clu13BQu9zjFrZpvckolr<br>\n  ZptMpdLTmmrppvU5TJKJZuEUnmr…</p>\n</blockquote>\n<p>what does this signify?</p>",
      "rawMarkdown": "In the final Submission.csv file, the final prediction is the prediction string which is the predicted cell level labels in the image through segmentation. But how is the prediction string generated or based on what logic or formula is the predicted string generated? \n\n> prediction String  ->  0 1 eNqcvOeW20CyrflKCUdbqpJURQvCEx4gvCeA9/\n83O8CSWn3umblrTffqZu4vIw3SRpRAsvrOeTtzzfAfTnv9P/33/67x/3J4mEq12hkhFx3mUi13OqX0Cqk54OKDQamJUmal5rsx4JKDVa\nnZ7hlw6eFOqZ5SDqVayvUqtdiVxKJKTXdJwFWHrFKjXRxw9aGo1GAXBlx\n7aCrV2bkB9zz0lWrt7gE3H56Vqu+sgDOPY6VOWyPgHEp1WzPgAkpVlIqOM3q1nX\n0uPlq1mm8Hn0uPdq2m287nsqNXq49tS6mgVpNtSakHpTKyS2s12yY+9zgWVDb0ueR\nYU1mf7Ppajbd3nyuOU61GW9PnyuNcq+HW8LnqaDRqsJ08rj5alHpSyqZUTym3Uf1t53HN\n0W9Ud9t4XHcMG9XZlh7XH+NGtbeFxw3HR6Pet7nHPY8JpVJKZZR6UConu5jsSmIRsa5R9a3jcfppbNRp\nY3qceZoppVPKaJGaXKTurfrcDC7nnOxW7Tc9pdxW7Tady7knr1XbTeNywclv1XpTuVx0Clu13BQu9zjFrZpvckolr\nZptMpdLTmmrppvU5TJKJZuEUnmr...\n\nwhat does this signify?",
      "votes": 1
    }
  ],
  "comments": [
    {
      "id": 1179296,
      "author_name": "Christoffer Karlsson",
      "author_url": "",
      "post_date": "2021-01-31T13:42:22.047000",
      "content": "<p>From the <a href=\"https://www.kaggle.com/c/hpa-single-cell-image-classification/overview/evaluation\" target=\"_blank\">official description</a>:</p>\n<blockquote>\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>An example python function to encode an instance segmentation mask would be:</p>\n</blockquote>\n<pre><code>import 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) -&gt; 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</code></pre>",
      "votes": 3,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1179296": "From the [official description](https://www.kaggle.com/c/hpa-single-cell-image-classification/overview/evaluation):\n\n> 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.\n\n> An example python function to encode an instance segmentation mask would be:\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```",
    "1178796": "In the final Submission.csv file, the final prediction is the prediction string which is the predicted cell level labels in the image through segmentation. But how is the prediction string generated or based on what logic or formula is the predicted string generated? \n\n> prediction String  ->  0 1 eNqcvOeW20CyrflKCUdbqpJURQvCEx4gvCeA9/\n83O8CSWn3umblrTffqZu4vIw3SRpRAsvrOeTtzzfAfTnv9P/33/67x/3J4mEq12hkhFx3mUi13OqX0Cqk54OKDQamJUmal5rsx4JKDVa\nnZ7hlw6eFOqZ5SDqVayvUqtdiVxKJKTXdJwFWHrFKjXRxw9aGo1GAXBlx\n7aCrV2bkB9zz0lWrt7gE3H56Vqu+sgDOPY6VOWyPgHEp1WzPgAkpVlIqOM3q1nX\n0uPlq1mm8Hn0uPdq2m287nsqNXq49tS6mgVpNtSakHpTKyS2s12yY+9zgWVDb0ueR\nYU1mf7Ppajbd3nyuOU61GW9PnyuNcq+HW8LnqaDRqsJ08rj5alHpSyqZUTym3Uf1t53HN\n0W9Ud9t4XHcMG9XZlh7XH+NGtbeFxw3HR6Pet7nHPY8JpVJKZZR6UConu5jsSmIRsa5R9a3jcfppbNRp\nY3qceZoppVPKaJGaXKTurfrcDC7nnOxW7Tc9pdxW7Tady7knr1XbTeNywclv1XpTuVx0Clu13BQu9zjFrZpvckolr\nZptMpdLTmmrppvU5TJKJZuEUnmr...\n\nwhat does this signify?"
  }
}