{
  "id": 62318,
  "title": "How to match maskid with trainids?",
  "url": "/competitions/airbus-ship-detection/discussion/62318",
  "author_name": "",
  "post_date": "2018-07-31T07:36:21.564078400Z",
  "votes": 6,
  "comment_count": 1,
  "views": 0,
  "content": "<p>I have tried this code but not working:</p>\n\n<pre><code>c = 0\nimage_list_ids = []\n\nfor i in train_ids:\n    for j in mask_ids:\n        if i == j:\n            print(i)\n            image_list_ids.append(i)\n        else:\n            pass\n</code></pre>",
  "messages": [
    {
      "id": "364280",
      "postDate": "07/31/2018 07:36:21",
      "content": "<p>I have tried this code but not working:</p>\n\n<pre><code>c = 0\nimage_list_ids = []\n\nfor i in train_ids:\n    for j in mask_ids:\n        if i == j:\n            print(i)\n            image_list_ids.append(i)\n        else:\n            pass\n</code></pre>",
      "rawMarkdown": "I have tried this code but not working:\n\n    c = 0\n    image_list_ids = []\n    \n    for i in train_ids:\n        for j in mask_ids:\n            if i == j:\n                print(i)\n                image_list_ids.append(i)\n            else:\n                pass",
      "votes": null
    },
    {
      "id": "364540",
      "postDate": "07/31/2018 18:09:00",
      "content": "<p>You need to keep in mind that some images have multiple masks because they have more than 1 ship on them and some images have no masks, because, no ships.</p>\n\n<p>By FAR the easiest way to get the IDs and masks together is by using pandas like so (assuming you're running on a kernel here):</p>\n\n<pre><code>import pandas as pd\ntrain = pd.read_csv('../input/train_ship_segmentations.csv')\ntrain.head()\n</code></pre>\n\n<p>Then, if you need to find images with ships:</p>\n\n<pre><code>with_ships = train[~train.EncodedPixels.isna()]\nwith_ships.head()\n</code></pre>\n\n<p>See if that works for you.</p>",
      "rawMarkdown": "You need to keep in mind that some images have multiple masks because they have more than 1 ship on them and some images have no masks, because, no ships.\n\nBy FAR the easiest way to get the IDs and masks together is by using pandas like so (assuming you're running on a kernel here):\n\n    import pandas as pd\n    train = pd.read_csv('../input/train_ship_segmentations.csv')\n    train.head()\n\nThen, if you need to find images with ships:\n\n    with_ships = train[~train.EncodedPixels.isna()]\n    with_ships.head()\n\nSee if that works for you.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 364540,
      "author_name": "ezietsman",
      "author_url": "",
      "post_date": "07/31/2018 18:09:00",
      "content": "<p>You need to keep in mind that some images have multiple masks because they have more than 1 ship on them and some images have no masks, because, no ships.</p>\n\n<p>By FAR the easiest way to get the IDs and masks together is by using pandas like so (assuming you're running on a kernel here):</p>\n\n<pre><code>import pandas as pd\ntrain = pd.read_csv('../input/train_ship_segmentations.csv')\ntrain.head()\n</code></pre>\n\n<p>Then, if you need to find images with ships:</p>\n\n<pre><code>with_ships = train[~train.EncodedPixels.isna()]\nwith_ships.head()\n</code></pre>\n\n<p>See if that works for you.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "364280": "I have tried this code but not working:\n\n    c = 0\n    image_list_ids = []\n    \n    for i in train_ids:\n        for j in mask_ids:\n            if i == j:\n                print(i)\n                image_list_ids.append(i)\n            else:\n                pass",
    "364540": "You need to keep in mind that some images have multiple masks because they have more than 1 ship on them and some images have no masks, because, no ships.\n\nBy FAR the easiest way to get the IDs and masks together is by using pandas like so (assuming you're running on a kernel here):\n\n    import pandas as pd\n    train = pd.read_csv('../input/train_ship_segmentations.csv')\n    train.head()\n\nThen, if you need to find images with ships:\n\n    with_ships = train[~train.EncodedPixels.isna()]\n    with_ships.head()\n\nSee if that works for you."
  },
  "source": "meta"
}