{
  "id": 55488,
  "title": "Train Label Issue",
  "url": "/competitions/cvpr-2018-autonomous-driving/discussion/55488",
  "author_name": "",
  "post_date": "2018-04-27T05:52:24.712083600Z",
  "votes": null,
  "comment_count": 2,
  "views": 0,
  "content": "<p>Hello, as described, the train label pixel value should be equal to instanceID plussing 1000*classID, however, the train_label.zip file just concludes .png file which pixel value is maximum to 255, how can I get the instanceID?</p>",
  "messages": [
    {
      "id": "319928",
      "postDate": "04/27/2018 05:52:24",
      "content": "<p>Hello, as described, the train label pixel value should be equal to instanceID plussing 1000*classID, however, the train_label.zip file just concludes .png file which pixel value is maximum to 255, how can I get the instanceID?</p>",
      "rawMarkdown": "Hello, as described, the train label pixel value should be equal to instanceID plussing 1000*classID, however, the train_label.zip file just concludes .png file which pixel value is maximum to 255, how can I get the instanceID?",
      "votes": null
    },
    {
      "id": "319955",
      "postDate": "04/27/2018 07:01:40",
      "content": "<p>You should perhaps provide an example code on how you are loading your images? \nIt works fine on my end:</p>\n\n<pre><code>import numpy as np\nfrom PIL import Image\n\nCLASSES = [33, 34, 35, 36, 38, 39, 40]\nIGNORE_CLASS = [65]\ndef load_label(lbl_path):\n    img = np.array(Image.open(lbl_path))\n    class_numbers = np.unique(img)\n    class_based = np.zeros(img.shape)\n    instance_based = np.zeros(img.shape)\n    ignore_area = np.zeros(img.shape)\n    for i in class_numbers:\n        this_class = int(float(i) / 1000)\n        if this_class in CLASSES:\n            loc = img == i\n            set_class_nr = (CLASSES.index(this_class) + 1)\n            class_based[loc] = set_class_nr\n            instance_based[loc] = set_class_nr*1000 + i\n        if this_class in IGNORE_CLASS:\n            ignore_area[img == i] = 1\n\n    return class_based, instance_based, ignore_area\n</code></pre>",
      "rawMarkdown": "You should perhaps provide an example code on how you are loading your images? \nIt works fine on my end:\n\n    import numpy as np\n    from PIL import Image\n    \n    CLASSES = [33, 34, 35, 36, 38, 39, 40]\n    IGNORE_CLASS = [65]\n    def load_label(lbl_path):\n        img = np.array(Image.open(lbl_path))\n        class_numbers = np.unique(img)\n        class_based = np.zeros(img.shape)\n        instance_based = np.zeros(img.shape)\n        ignore_area = np.zeros(img.shape)\n        for i in class_numbers:\n            this_class = int(float(i) / 1000)\n            if this_class in CLASSES:\n                loc = img == i\n                set_class_nr = (CLASSES.index(this_class) + 1)\n                class_based[loc] = set_class_nr\n                instance_based[loc] = set_class_nr*1000 + i\n            if this_class in IGNORE_CLASS:\n                ignore_area[img == i] = 1\n    \n        return class_based, instance_based, ignore_area",
      "votes": null
    },
    {
      "id": "320172",
      "postDate": "04/27/2018 18:41:27",
      "content": "<p>It's 16-bit PNG.  Data is OK.</p>",
      "rawMarkdown": "It's 16-bit PNG.  Data is OK.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 319955,
      "author_name": "adamhart",
      "author_url": "",
      "post_date": "04/27/2018 07:01:40",
      "content": "<p>You should perhaps provide an example code on how you are loading your images? \nIt works fine on my end:</p>\n\n<pre><code>import numpy as np\nfrom PIL import Image\n\nCLASSES = [33, 34, 35, 36, 38, 39, 40]\nIGNORE_CLASS = [65]\ndef load_label(lbl_path):\n    img = np.array(Image.open(lbl_path))\n    class_numbers = np.unique(img)\n    class_based = np.zeros(img.shape)\n    instance_based = np.zeros(img.shape)\n    ignore_area = np.zeros(img.shape)\n    for i in class_numbers:\n        this_class = int(float(i) / 1000)\n        if this_class in CLASSES:\n            loc = img == i\n            set_class_nr = (CLASSES.index(this_class) + 1)\n            class_based[loc] = set_class_nr\n            instance_based[loc] = set_class_nr*1000 + i\n        if this_class in IGNORE_CLASS:\n            ignore_area[img == i] = 1\n\n    return class_based, instance_based, ignore_area\n</code></pre>",
      "votes": null,
      "replies": []
    },
    {
      "id": 320172,
      "author_name": "aaalgo",
      "author_url": "",
      "post_date": "04/27/2018 18:41:27",
      "content": "<p>It's 16-bit PNG.  Data is OK.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "319928": "Hello, as described, the train label pixel value should be equal to instanceID plussing 1000*classID, however, the train_label.zip file just concludes .png file which pixel value is maximum to 255, how can I get the instanceID?",
    "319955": "You should perhaps provide an example code on how you are loading your images? \nIt works fine on my end:\n\n    import numpy as np\n    from PIL import Image\n    \n    CLASSES = [33, 34, 35, 36, 38, 39, 40]\n    IGNORE_CLASS = [65]\n    def load_label(lbl_path):\n        img = np.array(Image.open(lbl_path))\n        class_numbers = np.unique(img)\n        class_based = np.zeros(img.shape)\n        instance_based = np.zeros(img.shape)\n        ignore_area = np.zeros(img.shape)\n        for i in class_numbers:\n            this_class = int(float(i) / 1000)\n            if this_class in CLASSES:\n                loc = img == i\n                set_class_nr = (CLASSES.index(this_class) + 1)\n                class_based[loc] = set_class_nr\n                instance_based[loc] = set_class_nr*1000 + i\n            if this_class in IGNORE_CLASS:\n                ignore_area[img == i] = 1\n    \n        return class_based, instance_based, ignore_area",
    "320172": "It's 16-bit PNG.  Data is OK."
  },
  "source": "meta"
}