{
  "id": 413949,
  "title": "For those guys who scored > 0.2",
  "url": "/competitions/vesuvius-challenge-ink-detection/discussion/413949",
  "author_name": "TB Dukale",
  "post_date": "2023-05-30T19:35:05.432000",
  "votes": 5,
  "comment_count": 9,
  "views": 0,
  "content": "<p>is the given 'rle' function right? <br>\nif u notice it at the begining of the function it says 'flat_img = img.flatten()' which is actually flattening the given image <strong>in row-major (C-style) order</strong><br>\nwasnt it correct if we use <strong>column-major style</strong> like… … 'flat_img = img.flatten('F')'?<br>\nand i have good prediction on the test images but have difficulty on the LB score (0.01-0.08). anyone faced this problem? how did u solved it?<br>\nthanks.</p>",
  "messages": [
    {
      "id": 2281346,
      "postDate": "2023-05-30T19:35:05.433Z",
      "content": "<p>is the given 'rle' function right? <br>\nif u notice it at the begining of the function it says 'flat_img = img.flatten()' which is actually flattening the given image <strong>in row-major (C-style) order</strong><br>\nwasnt it correct if we use <strong>column-major style</strong> like… … 'flat_img = img.flatten('F')'?<br>\nand i have good prediction on the test images but have difficulty on the LB score (0.01-0.08). anyone faced this problem? how did u solved it?<br>\nthanks.</p>",
      "rawMarkdown": "is the given 'rle' function right? \nif u notice it at the begining of the function it says 'flat_img = img.flatten()' which is actually flattening the given image **in row-major (C-style) order**\nwasnt it correct if we use **column-major style** like... ... 'flat_img = img.flatten('F')'?\nand i have good prediction on the test images but have difficulty on the LB score (0.01-0.08). anyone faced this problem? how did u solved it?\nthanks.",
      "votes": 5
    },
    {
      "id": 2290579,
      "postDate": "2023-06-07T00:45:46.273Z",
      "content": "<p>The tutorial notebook just uses the standard Numpy flatten command with no arguments.</p>",
      "rawMarkdown": "The tutorial notebook just uses the standard Numpy flatten command with no arguments.",
      "votes": 1,
      "replies": [
        {
          "id": 2293005,
          "postDate": "2023-06-08T21:35:28.067Z",
          "content": "<p>yeah, i checked it and we just have to use the 'rle' function as it is. <br>\nthank u.</p>",
          "rawMarkdown": "yeah, i checked it and we just have to use the 'rle' function as it is. \nthank u."
        }
      ]
    },
    {
      "id": 2282972,
      "postDate": "2023-06-01T01:27:13.110Z",
      "content": "<p>I've been using that function to check what my encoded rle looks like</p>\n<pre><code>def decode_rle(rle, shape):\n    ar = np.zeros(shape[0]*shape[1], dtype=int)\n    pairs = rle.split()\n    for i in range(0,math.floor(len(pairs)/2)):\n        start = int(pairs[i*2])\n        count = int(pairs[i*2+1])\n        ar[start:start+count] = 255\n    new_img = np.array(ar)\n    new_img = np.reshape(new_img , shape)\n    new_img = new_img.astype('uint8')\n    new_img = PIL.Image.fromarray(new_img, mode='P')\n    plt.figure(figsize=(7, 7))\n    plt.imshow(new_img)\n    plt.axis('off')\n    plt.show()\n</code></pre>\n<p>For example, you can look at one of the provided csv this way:</p>\n<pre><code>file=io.open('/kaggle/input/vesuvius-challenge-ink-detection/train/1/inklabels_rle.csv', mode='r', encoding=\"utf-8\")\ncsv = file.read()\ndata = csv[15:]\ndecode_rle(data, (8181, 6330))\n</code></pre>\n<p>Then you can pass your own rle after generating it, to see what you get</p>\n<p>I hope this helps some</p>",
      "rawMarkdown": "I've been using that function to check what my encoded rle looks like\n```\ndef decode_rle(rle, shape):\n    ar = np.zeros(shape[0]*shape[1], dtype=int)\n    pairs = rle.split()\n    for i in range(0,math.floor(len(pairs)/2)):\n        start = int(pairs[i*2])\n        count = int(pairs[i*2+1])\n        ar[start:start+count] = 255\n    new_img = np.array(ar)\n    new_img = np.reshape(new_img , shape)\n    new_img = new_img.astype('uint8')\n    new_img = PIL.Image.fromarray(new_img, mode='P')\n    plt.figure(figsize=(7, 7))\n    plt.imshow(new_img)\n    plt.axis('off')\n    plt.show()\n```\n\nFor example, you can look at one of the provided csv this way:\n```\nfile=io.open('/kaggle/input/vesuvius-challenge-ink-detection/train/1/inklabels_rle.csv', mode='r', encoding=\"utf-8\")\ncsv = file.read()\ndata = csv[15:]\ndecode_rle(data, (8181, 6330))\n```\n\nThen you can pass your own rle after generating it, to see what you get\n\nI hope this helps some",
      "votes": 2,
      "replies": [
        {
          "id": 2283581,
          "postDate": "2023-06-01T11:13:32.293Z",
          "content": "<p>let me check it.<br>\nand Thank u!</p>",
          "rawMarkdown": "let me check it.\nand Thank u!"
        }
      ]
    },
    {
      "id": 2281622,
      "postDate": "2023-05-31T03:21:19.510Z",
      "content": "<p>Many have this problem, check other discussions, I have not seen anyone posting that they had this issue and resolved it. But usually it is suggested to check overall dimensions of an image before flattening and to try to transpose an image before flattening. Also it is a good idea to take a look at high scoring notebooks or notebook that submits mask as a prediction for rle function that is known to work. Submitting mask in your notebook instead of actual prediction and not getting an 0.11 score is a good indicator that there is an issue in how you load or transform data or in rle function itself.</p>\n<p>I believe \"row-major (C-style) order\" is an expected order for submission in this competition which can be justified by the fact that this is how png, tiff formats store the data.</p>",
      "rawMarkdown": "Many have this problem, check other discussions, I have not seen anyone posting that they had this issue and resolved it. But usually it is suggested to check overall dimensions of an image before flattening and to try to transpose an image before flattening. Also it is a good idea to take a look at high scoring notebooks or notebook that submits mask as a prediction for rle function that is known to work. Submitting mask in your notebook instead of actual prediction and not getting an 0.11 score is a good indicator that there is an issue in how you load or transform data or in rle function itself.\n\nI believe \"row-major (C-style) order\" is an expected order for submission in this competition which can be justified by the fact that this is how png, tiff formats store the data.",
      "votes": 2,
      "replies": [
        {
          "id": 2281742,
          "postDate": "2023-05-31T05:24:44.490Z",
          "content": "<p>Thank u sir! I will go back check my data preparation and training and try to resolve the scoring issue. <br>\nBut abt the 'rle': when u say <strong>Transpose</strong> before flattening, r we not <strong>changing the C-style to F-style?</strong><br>\nThank u for the tip of submitting the mask and checking the score!</p>",
          "rawMarkdown": "Thank u sir! I will go back check my data preparation and training and try to resolve the scoring issue. \nBut abt the 'rle': when u say **Transpose** before flattening, r we not **changing the C-style to F-style?**\nThank u for the tip of submitting the mask and checking the score!",
          "replies": [
            {
              "id": 2282721,
              "postDate": "2023-05-31T19:22:38.747Z",
              "content": "<p>First thing I would double check exact dimensions of image passed to rle and that it matches source data</p>",
              "rawMarkdown": "First thing I would double check exact dimensions of image passed to rle and that it matches source data"
            },
            {
              "id": 2283580,
              "postDate": "2023-06-01T11:12:41.977Z",
              "content": "<p>i checked the shapes and it was correct. Thank u for ur advice.</p>",
              "rawMarkdown": "i checked the shapes and it was correct. Thank u for ur advice."
            }
          ]
        },
        {
          "id": 2290576,
          "postDate": "2023-06-07T00:43:09.013Z",
          "rawMarkdown": "",
          "isDeleted": true
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 2290579,
      "author_name": "Matthew DeHaven",
      "author_url": "",
      "post_date": "2023-06-07T00:45:46.273000",
      "content": "<p>The tutorial notebook just uses the standard Numpy flatten command with no arguments.</p>",
      "votes": 1,
      "replies": [
        {
          "id": 2293005,
          "author_name": "TB Dukale",
          "author_url": "",
          "post_date": "2023-06-08T21:35:28.067000",
          "content": "<p>yeah, i checked it and we just have to use the 'rle' function as it is. <br>\nthank u.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 2282972,
      "author_name": "Jean-Fabien Barrois",
      "author_url": "",
      "post_date": "2023-06-01T01:27:13.110000",
      "content": "<p>I've been using that function to check what my encoded rle looks like</p>\n<pre><code>def decode_rle(rle, shape):\n    ar = np.zeros(shape[0]*shape[1], dtype=int)\n    pairs = rle.split()\n    for i in range(0,math.floor(len(pairs)/2)):\n        start = int(pairs[i*2])\n        count = int(pairs[i*2+1])\n        ar[start:start+count] = 255\n    new_img = np.array(ar)\n    new_img = np.reshape(new_img , shape)\n    new_img = new_img.astype('uint8')\n    new_img = PIL.Image.fromarray(new_img, mode='P')\n    plt.figure(figsize=(7, 7))\n    plt.imshow(new_img)\n    plt.axis('off')\n    plt.show()\n</code></pre>\n<p>For example, you can look at one of the provided csv this way:</p>\n<pre><code>file=io.open('/kaggle/input/vesuvius-challenge-ink-detection/train/1/inklabels_rle.csv', mode='r', encoding=\"utf-8\")\ncsv = file.read()\ndata = csv[15:]\ndecode_rle(data, (8181, 6330))\n</code></pre>\n<p>Then you can pass your own rle after generating it, to see what you get</p>\n<p>I hope this helps some</p>",
      "votes": 2,
      "replies": [
        {
          "id": 2283581,
          "author_name": "TB Dukale",
          "author_url": "",
          "post_date": "2023-06-01T11:13:32.293000",
          "content": "<p>let me check it.<br>\nand Thank u!</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 2281622,
      "author_name": "Serhii Hrynko",
      "author_url": "",
      "post_date": "2023-05-31T03:21:19.510000",
      "content": "<p>Many have this problem, check other discussions, I have not seen anyone posting that they had this issue and resolved it. But usually it is suggested to check overall dimensions of an image before flattening and to try to transpose an image before flattening. Also it is a good idea to take a look at high scoring notebooks or notebook that submits mask as a prediction for rle function that is known to work. Submitting mask in your notebook instead of actual prediction and not getting an 0.11 score is a good indicator that there is an issue in how you load or transform data or in rle function itself.</p>\n<p>I believe \"row-major (C-style) order\" is an expected order for submission in this competition which can be justified by the fact that this is how png, tiff formats store the data.</p>",
      "votes": 2,
      "replies": [
        {
          "id": 2281742,
          "author_name": "TB Dukale",
          "author_url": "",
          "post_date": "2023-05-31T05:24:44.490000",
          "content": "<p>Thank u sir! I will go back check my data preparation and training and try to resolve the scoring issue. <br>\nBut abt the 'rle': when u say <strong>Transpose</strong> before flattening, r we not <strong>changing the C-style to F-style?</strong><br>\nThank u for the tip of submitting the mask and checking the score!</p>",
          "votes": 0,
          "replies": [
            {
              "id": 2282721,
              "author_name": "Serhii Hrynko",
              "author_url": "",
              "post_date": "2023-05-31T19:22:38.747000",
              "content": "<p>First thing I would double check exact dimensions of image passed to rle and that it matches source data</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2283580,
              "author_name": "TB Dukale",
              "author_url": "",
              "post_date": "2023-06-01T11:12:41.977000",
              "content": "<p>i checked the shapes and it was correct. Thank u for ur advice.</p>",
              "votes": 0,
              "replies": []
            }
          ]
        },
        {
          "id": 2290576,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-06-07T00:43:09.013000",
          "content": "",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2281346": "is the given 'rle' function right? \nif u notice it at the begining of the function it says 'flat_img = img.flatten()' which is actually flattening the given image **in row-major (C-style) order**\nwasnt it correct if we use **column-major style** like... ... 'flat_img = img.flatten('F')'?\nand i have good prediction on the test images but have difficulty on the LB score (0.01-0.08). anyone faced this problem? how did u solved it?\nthanks.",
    "2290579": "The tutorial notebook just uses the standard Numpy flatten command with no arguments.",
    "2282972": "I've been using that function to check what my encoded rle looks like\n```\ndef decode_rle(rle, shape):\n    ar = np.zeros(shape[0]*shape[1], dtype=int)\n    pairs = rle.split()\n    for i in range(0,math.floor(len(pairs)/2)):\n        start = int(pairs[i*2])\n        count = int(pairs[i*2+1])\n        ar[start:start+count] = 255\n    new_img = np.array(ar)\n    new_img = np.reshape(new_img , shape)\n    new_img = new_img.astype('uint8')\n    new_img = PIL.Image.fromarray(new_img, mode='P')\n    plt.figure(figsize=(7, 7))\n    plt.imshow(new_img)\n    plt.axis('off')\n    plt.show()\n```\n\nFor example, you can look at one of the provided csv this way:\n```\nfile=io.open('/kaggle/input/vesuvius-challenge-ink-detection/train/1/inklabels_rle.csv', mode='r', encoding=\"utf-8\")\ncsv = file.read()\ndata = csv[15:]\ndecode_rle(data, (8181, 6330))\n```\n\nThen you can pass your own rle after generating it, to see what you get\n\nI hope this helps some",
    "2281622": "Many have this problem, check other discussions, I have not seen anyone posting that they had this issue and resolved it. But usually it is suggested to check overall dimensions of an image before flattening and to try to transpose an image before flattening. Also it is a good idea to take a look at high scoring notebooks or notebook that submits mask as a prediction for rle function that is known to work. Submitting mask in your notebook instead of actual prediction and not getting an 0.11 score is a good indicator that there is an issue in how you load or transform data or in rle function itself.\n\nI believe \"row-major (C-style) order\" is an expected order for submission in this competition which can be justified by the fact that this is how png, tiff formats store the data."
  }
}