{
  "id": 237214,
  "title": "Corrupt JPEG data: premature end of data segment",
  "url": "/competitions/iwildcam2021-fgvc8/discussion/237214",
  "author_name": "",
  "post_date": "2021-05-07T15:59:42.997183200Z",
  "votes": null,
  "comment_count": 5,
  "views": 0,
  "content": "<p>While reading images using cv2.imread() I sometimes get this message \"Catching error: Corrupt JPEG data: premature end of data segment\" on terminal. Sometimes I also get assertion failed error.</p>\n<p>I figured out, reading image using PIL and then converting it to Numpy (to use cv2 operations) solves the problem.</p>\n<pre><code>img = Image.open(file_path)\nimg = np.array(img, dtype=np.uint8)\n</code></pre>\n<p>But is anyone else facing the same issue? Am I missing here something?</p>",
  "messages": [
    {
      "id": "1296973",
      "postDate": "05/07/2021 15:59:42",
      "content": "<p>While reading images using cv2.imread() I sometimes get this message \"Catching error: Corrupt JPEG data: premature end of data segment\" on terminal. Sometimes I also get assertion failed error.</p>\n<p>I figured out, reading image using PIL and then converting it to Numpy (to use cv2 operations) solves the problem.</p>\n<pre><code>img = Image.open(file_path)\nimg = np.array(img, dtype=np.uint8)\n</code></pre>\n<p>But is anyone else facing the same issue? Am I missing here something?</p>",
      "rawMarkdown": "While reading images using cv2.imread() I sometimes get this message \"Catching error: Corrupt JPEG data: premature end of data segment\" on terminal. Sometimes I also get assertion failed error.\n\nI figured out, reading image using PIL and then converting it to Numpy (to use cv2 operations) solves the problem.\n\n```\nimg = Image.open(file_path)\nimg = np.array(img, dtype=np.uint8)\n```\n\nBut is anyone else facing the same issue? Am I missing here something?",
      "votes": null
    },
    {
      "id": "1297495",
      "postDate": "05/08/2021 04:50:34",
      "content": "<p>try this the way..</p>",
      "rawMarkdown": "try this the way..",
      "votes": null
    },
    {
      "id": "1297497",
      "postDate": "05/08/2021 04:50:44",
      "content": "<p>try this the way.</p>",
      "rawMarkdown": "try this the way.",
      "votes": null
    },
    {
      "id": "1297606",
      "postDate": "05/08/2021 07:08:56",
      "content": "<p>Hi <a href=\"https://www.kaggle.com/sriwastvaadarsh\" target=\"_blank\">@sriwastvaadarsh</a>, sorry but no link is visible if you are referring to any.  </p>",
      "rawMarkdown": "Hi @sriwastvaadarsh, sorry but no link is visible if you are referring to any.",
      "votes": null
    },
    {
      "id": "1542400",
      "postDate": "10/12/2021 13:28:02",
      "content": "<p>Hi <a href=\"https://www.kaggle.com/devashishprasad\" target=\"_blank\">@devashishprasad</a>  Did you finally get the solution?</p>",
      "rawMarkdown": "Hi @devashishprasad  Did you finally get the solution?",
      "votes": null
    },
    {
      "id": "1545271",
      "postDate": "10/15/2021 03:22:57",
      "content": "<p>I don't remember the exact solution but I remember I used PIL or PIL SIMD based solution. I didn't use cv2 at all.</p>\n<p>You can also refer to my notebook<br>\n<a href=\"https://www.kaggle.com/devashishprasad/fastest-way-to-read-and-process-images\" target=\"_blank\">https://www.kaggle.com/devashishprasad/fastest-way-to-read-and-process-images</a></p>",
      "rawMarkdown": "I don't remember the exact solution but I remember I used PIL or PIL SIMD based solution. I didn't use cv2 at all.\n\nYou can also refer to my notebook\nhttps://www.kaggle.com/devashishprasad/fastest-way-to-read-and-process-images",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1297495,
      "author_name": "sriwastvaadarsh",
      "author_url": "",
      "post_date": "05/08/2021 04:50:34",
      "content": "<p>try this the way..</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1297497,
      "author_name": "sriwastvaadarsh",
      "author_url": "",
      "post_date": "05/08/2021 04:50:44",
      "content": "<p>try this the way.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1297606,
          "author_name": "devashishprasad",
          "author_url": "",
          "post_date": "05/08/2021 07:08:56",
          "content": "<p>Hi <a href=\"https://www.kaggle.com/sriwastvaadarsh\" target=\"_blank\">@sriwastvaadarsh</a>, sorry but no link is visible if you are referring to any.  </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1542400,
      "author_name": "sanskaromar7",
      "author_url": "",
      "post_date": "10/12/2021 13:28:02",
      "content": "<p>Hi <a href=\"https://www.kaggle.com/devashishprasad\" target=\"_blank\">@devashishprasad</a>  Did you finally get the solution?</p>",
      "votes": null,
      "replies": [
        {
          "id": 1545271,
          "author_name": "devashishprasad",
          "author_url": "",
          "post_date": "10/15/2021 03:22:57",
          "content": "<p>I don't remember the exact solution but I remember I used PIL or PIL SIMD based solution. I didn't use cv2 at all.</p>\n<p>You can also refer to my notebook<br>\n<a href=\"https://www.kaggle.com/devashishprasad/fastest-way-to-read-and-process-images\" target=\"_blank\">https://www.kaggle.com/devashishprasad/fastest-way-to-read-and-process-images</a></p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1296973": "While reading images using cv2.imread() I sometimes get this message \"Catching error: Corrupt JPEG data: premature end of data segment\" on terminal. Sometimes I also get assertion failed error.\n\nI figured out, reading image using PIL and then converting it to Numpy (to use cv2 operations) solves the problem.\n\n```\nimg = Image.open(file_path)\nimg = np.array(img, dtype=np.uint8)\n```\n\nBut is anyone else facing the same issue? Am I missing here something?",
    "1297495": "try this the way..",
    "1297497": "try this the way.",
    "1297606": "Hi @sriwastvaadarsh, sorry but no link is visible if you are referring to any.",
    "1542400": "Hi @devashishprasad  Did you finally get the solution?",
    "1545271": "I don't remember the exact solution but I remember I used PIL or PIL SIMD based solution. I didn't use cv2 at all.\n\nYou can also refer to my notebook\nhttps://www.kaggle.com/devashishprasad/fastest-way-to-read-and-process-images"
  },
  "source": "meta"
}