{
  "id": 124717,
  "title": "Submission Scoring Error",
  "url": "/competitions/deepfake-detection-challenge/discussion/124717",
  "author_name": "",
  "post_date": "2020-01-06T05:41:30.595398300Z",
  "votes": 1,
  "comment_count": 5,
  "views": 0,
  "content": "<p>Kaggle Throws Submission Scoring Error, This is My Code:</p>\n\n<p>`import cv2\nimport os\nimport csv</p>\n\n<p>testPath = '/kaggle/input/deepfake-detection-challenge/test_videos'</p>\n\n<p>net.eval()</p>\n\n<p>softmax = nn.Softmax()</p>\n\n<p>with open('submission.csv', 'w', newline='') as file:\n    writer = csv.writer(file)\n    writer.writerow([\"filename\", \"label\"])</p>\n\n<pre><code>for videoFile in os.listdir(testPath):\n\n    medianProbability = 0\n    counter = 0 \n\n    frames = grab_frames_from_video(os.path.join(testPath, videoFile), [0])\n\n    for image in frames:\n\n        image = torch.tensor(image)\n        image.transpose_(0, 2)\n        image = norm(toImg(image))\n        image = image.cuda()\n\n        with torch.no_grad():\n            x = softmax(net(image[None]))\n\n        fakeProbability = x[0][1].item() #/ (3*x[0][0] + 1)\n\n        medianProbability += fakeProbability\n\n    medianProbability = float(medianProbability / len(frames))\n\n    writer.writerow([videoFile, medianProbability])`\n</code></pre>",
  "messages": [
    {
      "id": "711449",
      "postDate": "01/06/2020 05:41:30",
      "content": "<p>Kaggle Throws Submission Scoring Error, This is My Code:</p>\n\n<p>`import cv2\nimport os\nimport csv</p>\n\n<p>testPath = '/kaggle/input/deepfake-detection-challenge/test_videos'</p>\n\n<p>net.eval()</p>\n\n<p>softmax = nn.Softmax()</p>\n\n<p>with open('submission.csv', 'w', newline='') as file:\n    writer = csv.writer(file)\n    writer.writerow([\"filename\", \"label\"])</p>\n\n<pre><code>for videoFile in os.listdir(testPath):\n\n    medianProbability = 0\n    counter = 0 \n\n    frames = grab_frames_from_video(os.path.join(testPath, videoFile), [0])\n\n    for image in frames:\n\n        image = torch.tensor(image)\n        image.transpose_(0, 2)\n        image = norm(toImg(image))\n        image = image.cuda()\n\n        with torch.no_grad():\n            x = softmax(net(image[None]))\n\n        fakeProbability = x[0][1].item() #/ (3*x[0][0] + 1)\n\n        medianProbability += fakeProbability\n\n    medianProbability = float(medianProbability / len(frames))\n\n    writer.writerow([videoFile, medianProbability])`\n</code></pre>",
      "rawMarkdown": "Kaggle Throws Submission Scoring Error, This is My Code:\n\n`import cv2\nimport os\nimport csv\n\ntestPath = '/kaggle/input/deepfake-detection-challenge/test_videos'\n\nnet.eval()\n\nsoftmax = nn.Softmax()\n\nwith open('submission.csv', 'w', newline='') as file:\n    writer = csv.writer(file)\n    writer.writerow([\"filename\", \"label\"])\n\n    for videoFile in os.listdir(testPath):\n\n        medianProbability = 0\n        counter = 0 \n            \n        frames = grab_frames_from_video(os.path.join(testPath, videoFile), [0])\n\n        for image in frames:\n\n            image = torch.tensor(image)\n            image.transpose_(0, 2)\n            image = norm(toImg(image))\n            image = image.cuda()\n\n            with torch.no_grad():\n                x = softmax(net(image[None]))\n\n            fakeProbability = x[0][1].item() #/ (3*x[0][0] + 1)\n\n            medianProbability += fakeProbability\n\n        medianProbability = float(medianProbability / len(frames))\n\n        writer.writerow([videoFile, medianProbability])`",
      "votes": null
    },
    {
      "id": "711580",
      "postDate": "01/06/2020 09:22:10",
      "content": "<p>I have the same error, and my script can successfully submit a few days ago.</p>",
      "rawMarkdown": "I have the same error, and my script can successfully submit a few days ago.",
      "votes": null
    },
    {
      "id": "712212",
      "postDate": "01/07/2020 00:21:18",
      "content": "<p>Try cliping your submission. Log error will be infinite if your model output a 1 and the answer is 0 which would lead to submission error. And if your model output a negative number, it would probably lead to submission error too.\nIf you can make your kernel public and/or provide your submission file, it would be helpful. Thanks</p>",
      "rawMarkdown": "Try cliping your submission. Log error will be infinite if your model output a 1 and the answer is 0 which would lead to submission error. And if your model output a negative number, it would probably lead to submission error too.\nIf you can make your kernel public and/or provide your submission file, it would be helpful. Thanks",
      "votes": null
    },
    {
      "id": "712374",
      "postDate": "01/07/2020 06:47:01",
      "content": "<p>Would take it for test drive if you had linked a kernel.</p>\n\n<p>Do you see the post where an error was occurring because more files had been created than were permitted - apparently there is a limit to the number of files along with limit on total bytes saved.  Does not look like that's your issue - but how many frames are in the longest video?   I have looked for the file count limit but not found it yet. </p>",
      "rawMarkdown": "Would take it for test drive if you had linked a kernel.\n\nDo you see the post where an error was occurring because more files had been created than were permitted - apparently there is a limit to the number of files along with limit on total bytes saved.  Does not look like that's your issue - but how many frames are in the longest video?   I have looked for the file count limit but not found it yet.",
      "votes": null
    },
    {
      "id": "712510",
      "postDate": "01/07/2020 10:09:35",
      "content": "<p>Thanks Guys\nI have made some minor modifications to my Code and now it works:</p>\n\n<p>This is my new code</p>\n\n<p>`import cv2\nimport os\nimport csv</p>\n\n<p>softmax = nn.Softmax()</p>\n\n<p>testPath = '/kaggle/input/deepfake-detection-challenge/test_videos'</p>\n\n<p>net.eval()</p>\n\n<p>if(not os.path.exists(testPath)):\n    exit(0);</p>\n\n<p>paths = []\npreds = []</p>\n\n<p>for videoFile in os.listdir(testPath):</p>\n\n<pre><code>medianProbability = 0\ncounter = 0 \n\nframes = grab_frames_from_video(os.path.join(testPath, videoFile), [0])\n\nfor image in frames:\n\n    image = torch.tensor(image)\n    image.transpose_(0, 2)\n    image = norm(toImg(image))\n    image = image.to(device)\n\n    with torch.no_grad():\n        x = softmax(net(image[None]))\n\n    fakeProbability = x[0][1].item() #/ (3*x[0][0] + 1)\n\n    medianProbability += fakeProbability\n\nmedianProbability = float(medianProbability / len(frames))\n\npaths.append(videoFile)\npreds.append(medianProbability)\n</code></pre>\n\n<p>res = pd.DataFrame({\n    'filename': paths,\n    'label': preds,\n})</p>\n\n<p>res.sort_values(by='filename', ascending=True, inplace=True)</p>\n\n<p>res.to_csv('submission.csv', index=False)\nprint('video: ' + videoFile + ' probability: ' + str(medianProbability))`</p>",
      "rawMarkdown": "Thanks Guys\nI have made some minor modifications to my Code and now it works:\n\nThis is my new code\n\n`import cv2\nimport os\nimport csv\n\nsoftmax = nn.Softmax()\n\ntestPath = '/kaggle/input/deepfake-detection-challenge/test_videos'\n\nnet.eval()\n\nif(not os.path.exists(testPath)):\n    exit(0);\n    \npaths = []\npreds = []\n\nfor videoFile in os.listdir(testPath):\n\n    medianProbability = 0\n    counter = 0 \n\n    frames = grab_frames_from_video(os.path.join(testPath, videoFile), [0])\n\n    for image in frames:\n\n        image = torch.tensor(image)\n        image.transpose_(0, 2)\n        image = norm(toImg(image))\n        image = image.to(device)\n\n        with torch.no_grad():\n            x = softmax(net(image[None]))\n\n        fakeProbability = x[0][1].item() #/ (3*x[0][0] + 1)\n\n        medianProbability += fakeProbability\n\n    medianProbability = float(medianProbability / len(frames))\n\n    paths.append(videoFile)\n    preds.append(medianProbability)\n    \n    \nres = pd.DataFrame({\n    'filename': paths,\n    'label': preds,\n})\n\nres.sort_values(by='filename', ascending=True, inplace=True)\n\nres.to_csv('submission.csv', index=False)\nprint('video: ' + videoFile + ' probability: ' + str(medianProbability))`",
      "votes": null
    },
    {
      "id": "712546",
      "postDate": "01/07/2020 11:08:13",
      "content": "<p>Thanks, good Idea</p>",
      "rawMarkdown": "Thanks, good Idea",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 711580,
      "author_name": "wenjuhuang",
      "author_url": "",
      "post_date": "01/06/2020 09:22:10",
      "content": "<p>I have the same error, and my script can successfully submit a few days ago.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 712212,
      "author_name": "unkownhihi",
      "author_url": "",
      "post_date": "01/07/2020 00:21:18",
      "content": "<p>Try cliping your submission. Log error will be infinite if your model output a 1 and the answer is 0 which would lead to submission error. And if your model output a negative number, it would probably lead to submission error too.\nIf you can make your kernel public and/or provide your submission file, it would be helpful. Thanks</p>",
      "votes": null,
      "replies": [
        {
          "id": 712546,
          "author_name": "dito1988",
          "author_url": "",
          "post_date": "01/07/2020 11:08:13",
          "content": "<p>Thanks, good Idea</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 712374,
      "author_name": "pcjimmmy",
      "author_url": "",
      "post_date": "01/07/2020 06:47:01",
      "content": "<p>Would take it for test drive if you had linked a kernel.</p>\n\n<p>Do you see the post where an error was occurring because more files had been created than were permitted - apparently there is a limit to the number of files along with limit on total bytes saved.  Does not look like that's your issue - but how many frames are in the longest video?   I have looked for the file count limit but not found it yet. </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 712510,
      "author_name": "dito1988",
      "author_url": "",
      "post_date": "01/07/2020 10:09:35",
      "content": "<p>Thanks Guys\nI have made some minor modifications to my Code and now it works:</p>\n\n<p>This is my new code</p>\n\n<p>`import cv2\nimport os\nimport csv</p>\n\n<p>softmax = nn.Softmax()</p>\n\n<p>testPath = '/kaggle/input/deepfake-detection-challenge/test_videos'</p>\n\n<p>net.eval()</p>\n\n<p>if(not os.path.exists(testPath)):\n    exit(0);</p>\n\n<p>paths = []\npreds = []</p>\n\n<p>for videoFile in os.listdir(testPath):</p>\n\n<pre><code>medianProbability = 0\ncounter = 0 \n\nframes = grab_frames_from_video(os.path.join(testPath, videoFile), [0])\n\nfor image in frames:\n\n    image = torch.tensor(image)\n    image.transpose_(0, 2)\n    image = norm(toImg(image))\n    image = image.to(device)\n\n    with torch.no_grad():\n        x = softmax(net(image[None]))\n\n    fakeProbability = x[0][1].item() #/ (3*x[0][0] + 1)\n\n    medianProbability += fakeProbability\n\nmedianProbability = float(medianProbability / len(frames))\n\npaths.append(videoFile)\npreds.append(medianProbability)\n</code></pre>\n\n<p>res = pd.DataFrame({\n    'filename': paths,\n    'label': preds,\n})</p>\n\n<p>res.sort_values(by='filename', ascending=True, inplace=True)</p>\n\n<p>res.to_csv('submission.csv', index=False)\nprint('video: ' + videoFile + ' probability: ' + str(medianProbability))`</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "711449": "Kaggle Throws Submission Scoring Error, This is My Code:\n\n`import cv2\nimport os\nimport csv\n\ntestPath = '/kaggle/input/deepfake-detection-challenge/test_videos'\n\nnet.eval()\n\nsoftmax = nn.Softmax()\n\nwith open('submission.csv', 'w', newline='') as file:\n    writer = csv.writer(file)\n    writer.writerow([\"filename\", \"label\"])\n\n    for videoFile in os.listdir(testPath):\n\n        medianProbability = 0\n        counter = 0 \n            \n        frames = grab_frames_from_video(os.path.join(testPath, videoFile), [0])\n\n        for image in frames:\n\n            image = torch.tensor(image)\n            image.transpose_(0, 2)\n            image = norm(toImg(image))\n            image = image.cuda()\n\n            with torch.no_grad():\n                x = softmax(net(image[None]))\n\n            fakeProbability = x[0][1].item() #/ (3*x[0][0] + 1)\n\n            medianProbability += fakeProbability\n\n        medianProbability = float(medianProbability / len(frames))\n\n        writer.writerow([videoFile, medianProbability])`",
    "711580": "I have the same error, and my script can successfully submit a few days ago.",
    "712212": "Try cliping your submission. Log error will be infinite if your model output a 1 and the answer is 0 which would lead to submission error. And if your model output a negative number, it would probably lead to submission error too.\nIf you can make your kernel public and/or provide your submission file, it would be helpful. Thanks",
    "712374": "Would take it for test drive if you had linked a kernel.\n\nDo you see the post where an error was occurring because more files had been created than were permitted - apparently there is a limit to the number of files along with limit on total bytes saved.  Does not look like that's your issue - but how many frames are in the longest video?   I have looked for the file count limit but not found it yet.",
    "712510": "Thanks Guys\nI have made some minor modifications to my Code and now it works:\n\nThis is my new code\n\n`import cv2\nimport os\nimport csv\n\nsoftmax = nn.Softmax()\n\ntestPath = '/kaggle/input/deepfake-detection-challenge/test_videos'\n\nnet.eval()\n\nif(not os.path.exists(testPath)):\n    exit(0);\n    \npaths = []\npreds = []\n\nfor videoFile in os.listdir(testPath):\n\n    medianProbability = 0\n    counter = 0 \n\n    frames = grab_frames_from_video(os.path.join(testPath, videoFile), [0])\n\n    for image in frames:\n\n        image = torch.tensor(image)\n        image.transpose_(0, 2)\n        image = norm(toImg(image))\n        image = image.to(device)\n\n        with torch.no_grad():\n            x = softmax(net(image[None]))\n\n        fakeProbability = x[0][1].item() #/ (3*x[0][0] + 1)\n\n        medianProbability += fakeProbability\n\n    medianProbability = float(medianProbability / len(frames))\n\n    paths.append(videoFile)\n    preds.append(medianProbability)\n    \n    \nres = pd.DataFrame({\n    'filename': paths,\n    'label': preds,\n})\n\nres.sort_values(by='filename', ascending=True, inplace=True)\n\nres.to_csv('submission.csv', index=False)\nprint('video: ' + videoFile + ' probability: ' + str(medianProbability))`",
    "712546": "Thanks, good Idea"
  },
  "source": "meta"
}