{
  "id": 133534,
  "title": "Difference between training on jpg and png faces?",
  "url": "/competitions/deepfake-detection-challenge/discussion/133534",
  "author_name": "",
  "post_date": "2020-03-03T06:36:48.599471400Z",
  "votes": 2,
  "comment_count": 11,
  "views": 0,
  "content": "<p>I've been having trouble having my model predict faces reliably, and I was wondering if this could be the problem. I first extracted one frame from each video on a google cloud VM and saved them as jpgs in a zip file. I then downloaded the zip file and used them in colab for training. </p>\n\n<p>Although the face detection model seems to be converging and gives varied results during test time prediction, when I actually predict on a series of frames the mean result often adds up agglomerating at 0.5/0.6 with little difference between fakes/reals. I'm wondering if the problem could be a loss of quality due to jpeg compression, or if I just need more training data. </p>",
  "messages": [
    {
      "id": "762042",
      "postDate": "03/03/2020 06:36:48",
      "content": "<p>I've been having trouble having my model predict faces reliably, and I was wondering if this could be the problem. I first extracted one frame from each video on a google cloud VM and saved them as jpgs in a zip file. I then downloaded the zip file and used them in colab for training. </p>\n\n<p>Although the face detection model seems to be converging and gives varied results during test time prediction, when I actually predict on a series of frames the mean result often adds up agglomerating at 0.5/0.6 with little difference between fakes/reals. I'm wondering if the problem could be a loss of quality due to jpeg compression, or if I just need more training data. </p>",
      "rawMarkdown": "I've been having trouble having my model predict faces reliably, and I was wondering if this could be the problem. I first extracted one frame from each video on a google cloud VM and saved them as jpgs in a zip file. I then downloaded the zip file and used them in colab for training. \n\nAlthough the face detection model seems to be converging and gives varied results during test time prediction, when I actually predict on a series of frames the mean result often adds up agglomerating at 0.5/0.6 with little difference between fakes/reals. I'm wondering if the problem could be a loss of quality due to jpeg compression, or if I just need more training data.",
      "votes": null
    },
    {
      "id": "762212",
      "postDate": "03/03/2020 10:24:38",
      "content": "<p>I save my faces as PNG as I didn't want to add any additional JPEG compression artifacts. Not sure if it actually makes a difference.</p>",
      "rawMarkdown": "I save my faces as PNG as I didn't want to add any additional JPEG compression artifacts. Not sure if it actually makes a difference.",
      "votes": null
    },
    {
      "id": "762221",
      "postDate": "03/03/2020 10:37:03",
      "content": "<p>JPEG is a lossy compression algorithm</p>",
      "rawMarkdown": "JPEG is a lossy compression algorithm",
      "votes": null
    },
    {
      "id": "762826",
      "postDate": "03/03/2020 20:46:59",
      "content": "<p>Jpg is lossy but unless you choose really bad quality for saving... This looks like overfitting. To check, write a small program that extract from the video and directly calls your predictor,perhaps on only one set. </p>",
      "rawMarkdown": "Jpg is lossy but unless you choose really bad quality for saving... This looks like overfitting. To check, write a small program that extract from the video and directly calls your predictor,perhaps on only one set.",
      "votes": null
    },
    {
      "id": "762876",
      "postDate": "03/03/2020 22:15:39",
      "content": "<p>I am saving all my images as jpg, every single model from 0.68 to 0.34 were made on jpgs, I dont think it makes a difference.</p>",
      "rawMarkdown": "I am saving all my images as jpg, every single model from 0.68 to 0.34 were made on jpgs, I dont think it makes a difference.",
      "votes": null
    },
    {
      "id": "763310",
      "postDate": "03/04/2020 10:57:50",
      "content": "<p>PNG is my go-to option in image competitions since it is lossless but in this case, I went with JPEG due to space constraints on my machine. Since there are already artefacts from the video compression the JPEG artefacts shouldn't be too much of an issue if any.</p>",
      "rawMarkdown": "PNG is my go-to option in image competitions since it is lossless but in this case, I went with JPEG due to space constraints on my machine. Since there are already artefacts from the video compression the JPEG artefacts shouldn't be too much of an issue if any.",
      "votes": null
    },
    {
      "id": "763323",
      "postDate": "03/04/2020 11:20:01",
      "content": "<p>I saved all my images as npy. I don't think it matters in terms of model performance. But I believe(i might be mistaken) it makes data load faster(no decoding) during training.</p>",
      "rawMarkdown": "I saved all my images as npy. I don't think it matters in terms of model performance. But I believe(i might be mistaken) it makes data load faster(no decoding) during training.",
      "votes": null
    },
    {
      "id": "763357",
      "postDate": "03/04/2020 11:57:35",
      "content": "<blockquote>\n  <p>But I believe(i might be mistaken) it makes data load faster(no decoding) during training.</p>\n</blockquote>\n\n<p>It also depends on the difference in file size. The npy files don't need decoding but are larger, so how much time do you save by not having to decode vs. doing more I/O? </p>\n\n<p>I recall when I did this test myself a while ago (so I might be recalling it wrong haha), PNG files were faster than npy files. But it also depends on your hardware, etc.</p>",
      "rawMarkdown": "&gt; But I believe(i might be mistaken) it makes data load faster(no decoding) during training.\n\nIt also depends on the difference in file size. The npy files don't need decoding but are larger, so how much time do you save by not having to decode vs. doing more I/O? \n\nI recall when I did this test myself a while ago (so I might be recalling it wrong haha), PNG files were faster than npy files. But it also depends on your hardware, etc.",
      "votes": null
    },
    {
      "id": "763370",
      "postDate": "03/04/2020 12:13:38",
      "content": "<p>Definitely. \nMy disk is NVMe(quite fast); I assumed pytorch dataloader workers are using async implementation so IO doesnt block cpu/gpu vice versa but not sure about that. Maybe will look into it sometime.</p>",
      "rawMarkdown": "Definitely. \nMy disk is NVMe(quite fast); I assumed pytorch dataloader workers are using async implementation so IO doesnt block cpu/gpu vice versa but not sure about that. Maybe will look into it sometime.",
      "votes": null
    },
    {
      "id": "763374",
      "postDate": "03/04/2020 12:20:25",
      "content": "<p>my disk speed;\nsudo hdparm -Tt /dev/nvme0n1p2</p>\n\n<p>/dev/nvme0n1p2:\n Timing cached reads:   37230 MB in  2.00 seconds = 18646.62 MB/sec</p>",
      "rawMarkdown": "my disk speed;\nsudo hdparm -Tt /dev/nvme0n1p2\n\n/dev/nvme0n1p2:\n Timing cached reads:   37230 MB in  2.00 seconds = 18646.62 MB/sec",
      "votes": null
    },
    {
      "id": "763517",
      "postDate": "03/04/2020 15:08:50",
      "content": "<p>Same for me, reading jpeg images were much more efficient in speed and memory if compared to reading np arrays.</p>",
      "rawMarkdown": "Same for me, reading jpeg images were much more efficient in speed and memory if compared to reading np arrays.",
      "votes": null
    },
    {
      "id": "764083",
      "postDate": "03/05/2020 05:59:30",
      "content": "<p>Just my suggestion is to have jpg format images for experimenting. Once you find a model good enough then train it on png. Until now I was using mp4 to save cropped frames in video and yesterday I analized that if I read and save it 60 times then it is all black(grey boxes). But that's not the case with jpg. </p>",
      "rawMarkdown": "Just my suggestion is to have jpg format images for experimenting. Once you find a model good enough then train it on png. Until now I was using mp4 to save cropped frames in video and yesterday I analized that if I read and save it 60 times then it is all black(grey boxes). But that's not the case with jpg.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 762212,
      "author_name": "humananalog",
      "author_url": "",
      "post_date": "03/03/2020 10:24:38",
      "content": "<p>I save my faces as PNG as I didn't want to add any additional JPEG compression artifacts. Not sure if it actually makes a difference.</p>",
      "votes": null,
      "replies": [
        {
          "id": 764083,
          "author_name": "ankitsainiankit",
          "author_url": "",
          "post_date": "03/05/2020 05:59:30",
          "content": "<p>Just my suggestion is to have jpg format images for experimenting. Once you find a model good enough then train it on png. Until now I was using mp4 to save cropped frames in video and yesterday I analized that if I read and save it 60 times then it is all black(grey boxes). But that's not the case with jpg. </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 762221,
      "author_name": "caffeinism",
      "author_url": "",
      "post_date": "03/03/2020 10:37:03",
      "content": "<p>JPEG is a lossy compression algorithm</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 762826,
      "author_name": "moshel",
      "author_url": "",
      "post_date": "03/03/2020 20:46:59",
      "content": "<p>Jpg is lossy but unless you choose really bad quality for saving... This looks like overfitting. To check, write a small program that extract from the video and directly calls your predictor,perhaps on only one set. </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 762876,
      "author_name": "harshitsheoran",
      "author_url": "",
      "post_date": "03/03/2020 22:15:39",
      "content": "<p>I am saving all my images as jpg, every single model from 0.68 to 0.34 were made on jpgs, I dont think it makes a difference.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 763310,
      "author_name": "anjum48",
      "author_url": "",
      "post_date": "03/04/2020 10:57:50",
      "content": "<p>PNG is my go-to option in image competitions since it is lossless but in this case, I went with JPEG due to space constraints on my machine. Since there are already artefacts from the video compression the JPEG artefacts shouldn't be too much of an issue if any.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 763323,
      "author_name": "emrebayram",
      "author_url": "",
      "post_date": "03/04/2020 11:20:01",
      "content": "<p>I saved all my images as npy. I don't think it matters in terms of model performance. But I believe(i might be mistaken) it makes data load faster(no decoding) during training.</p>",
      "votes": null,
      "replies": [
        {
          "id": 763357,
          "author_name": "humananalog",
          "author_url": "",
          "post_date": "03/04/2020 11:57:35",
          "content": "<blockquote>\n  <p>But I believe(i might be mistaken) it makes data load faster(no decoding) during training.</p>\n</blockquote>\n\n<p>It also depends on the difference in file size. The npy files don't need decoding but are larger, so how much time do you save by not having to decode vs. doing more I/O? </p>\n\n<p>I recall when I did this test myself a while ago (so I might be recalling it wrong haha), PNG files were faster than npy files. But it also depends on your hardware, etc.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 763370,
          "author_name": "emrebayram",
          "author_url": "",
          "post_date": "03/04/2020 12:13:38",
          "content": "<p>Definitely. \nMy disk is NVMe(quite fast); I assumed pytorch dataloader workers are using async implementation so IO doesnt block cpu/gpu vice versa but not sure about that. Maybe will look into it sometime.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 763374,
          "author_name": "emrebayram",
          "author_url": "",
          "post_date": "03/04/2020 12:20:25",
          "content": "<p>my disk speed;\nsudo hdparm -Tt /dev/nvme0n1p2</p>\n\n<p>/dev/nvme0n1p2:\n Timing cached reads:   37230 MB in  2.00 seconds = 18646.62 MB/sec</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 763517,
          "author_name": "harshitsheoran",
          "author_url": "",
          "post_date": "03/04/2020 15:08:50",
          "content": "<p>Same for me, reading jpeg images were much more efficient in speed and memory if compared to reading np arrays.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "762042": "I've been having trouble having my model predict faces reliably, and I was wondering if this could be the problem. I first extracted one frame from each video on a google cloud VM and saved them as jpgs in a zip file. I then downloaded the zip file and used them in colab for training. \n\nAlthough the face detection model seems to be converging and gives varied results during test time prediction, when I actually predict on a series of frames the mean result often adds up agglomerating at 0.5/0.6 with little difference between fakes/reals. I'm wondering if the problem could be a loss of quality due to jpeg compression, or if I just need more training data.",
    "762212": "I save my faces as PNG as I didn't want to add any additional JPEG compression artifacts. Not sure if it actually makes a difference.",
    "762221": "JPEG is a lossy compression algorithm",
    "762826": "Jpg is lossy but unless you choose really bad quality for saving... This looks like overfitting. To check, write a small program that extract from the video and directly calls your predictor,perhaps on only one set.",
    "762876": "I am saving all my images as jpg, every single model from 0.68 to 0.34 were made on jpgs, I dont think it makes a difference.",
    "763310": "PNG is my go-to option in image competitions since it is lossless but in this case, I went with JPEG due to space constraints on my machine. Since there are already artefacts from the video compression the JPEG artefacts shouldn't be too much of an issue if any.",
    "763323": "I saved all my images as npy. I don't think it matters in terms of model performance. But I believe(i might be mistaken) it makes data load faster(no decoding) during training.",
    "763357": "&gt; But I believe(i might be mistaken) it makes data load faster(no decoding) during training.\n\nIt also depends on the difference in file size. The npy files don't need decoding but are larger, so how much time do you save by not having to decode vs. doing more I/O? \n\nI recall when I did this test myself a while ago (so I might be recalling it wrong haha), PNG files were faster than npy files. But it also depends on your hardware, etc.",
    "763370": "Definitely. \nMy disk is NVMe(quite fast); I assumed pytorch dataloader workers are using async implementation so IO doesnt block cpu/gpu vice versa but not sure about that. Maybe will look into it sometime.",
    "763374": "my disk speed;\nsudo hdparm -Tt /dev/nvme0n1p2\n\n/dev/nvme0n1p2:\n Timing cached reads:   37230 MB in  2.00 seconds = 18646.62 MB/sec",
    "763517": "Same for me, reading jpeg images were much more efficient in speed and memory if compared to reading np arrays.",
    "764083": "Just my suggestion is to have jpg format images for experimenting. Once you find a model good enough then train it on png. Until now I was using mp4 to save cropped frames in video and yesterday I analized that if I read and save it 60 times then it is all black(grey boxes). But that's not the case with jpg."
  },
  "source": "meta"
}