{
  "id": 169824,
  "title": "Simple trick/solution for Submission CSV Not Found issue",
  "url": "/competitions/global-wheat-detection/discussion/169824",
  "author_name": "Mithilesh Kumar Singh",
  "post_date": "2020-07-25T11:19:59.247000",
  "votes": 5,
  "comment_count": 0,
  "views": 0,
  "content": "<p>I was facing this issue for a couple of days, tried so many things, the suggestion provided in the other discussion.</p>\n\n<p>finally, it worked for me, whoo!!, thought let's share this.</p>\n\n<p><strong>Easy hack, try appending your prediction code with try/ catch for easy debugging.</strong></p>\n\n<h2>Before ## &lt;- this was giving the error</h2>\n\n<p><code>\nfor image_path in glob.glob('/kaggle/input/global-wheat-detection/test/*.jpg'):\n    image_name = image_path.split('/')[-1]\n    ....\n    boxes, scores, labels = prediction_model.predict_on_batch([np.expand_dims(image, axis=0)])\n   ....\n   row = [image_name.replace('.jpg','')]\n   r_boxes = \"\"\n    if(len(boxes) &gt; 0):\n            for s,b in zip(scores, boxes):\n                if r_boxes != \"\":\n                    r_boxes += \" \"\n                r_boxes += f\"{round(float(s),2)} {int(b[0])} {int(b[1])} {int(b[2]-b[0])} {int(b[3]-b[1])}\"\n     row.append(\"\")\n     result_data.append(row)\ntestDf = pd.DataFrame(result_data, columns=['image_id','PredictionString'])\ntestDf.to_csv(\"submission.csv\",index=False)\n</code></p>\n\n<h2>After ## &lt;- this is working perfectly fine</h2>\n\n<p><code>\nfor image_path in glob.glob('/kaggle/input/global-wheat-detection/test/*.jpg'):\n   **try:**\n      image_name = image_path.split('/')[-1]\n      ....\n      boxes, scores, labels = prediction_model.predict_on_batch([np.expand_dims(image, axis=0)])\n      ....\n      row = [image_name.replace('.jpg','')]\n      r_boxes = \"\"\n      if(len(boxes) &gt; 0):\n            for s,b in zip(scores, boxes):\n                if r_boxes != \"\":\n                    r_boxes += \" \"\n                r_boxes += f\"{round(float(s),2)} {int(b[0])} {int(b[1])} {int(b[2]-b[0])} {int(b[3]-b[1])}\"\n     row.append(\"\")\n     result_data.append(row)\n  **except:**\n      result_data.append([image_name.replace('.jpg',''),\"\"])\ntestDf = pd.DataFrame(result_data, columns=['image_id','PredictionString'])\ntestDf.to_csv(\"submission.csv\",index=False)\n</code></p>\n\n<p>Working notebook <a href=\"https://www.kaggle.com/savanmorya/efficientdet-keras-train-and-test-offline?scriptVersionId=39485952\">here </a></p>",
  "messages": [
    {
      "id": 944807,
      "postDate": "2020-07-25T11:19:59.247Z",
      "content": "<p>I was facing this issue for a couple of days, tried so many things, the suggestion provided in the other discussion.</p>\n\n<p>finally, it worked for me, whoo!!, thought let's share this.</p>\n\n<p><strong>Easy hack, try appending your prediction code with try/ catch for easy debugging.</strong></p>\n\n<h2>Before ## &lt;- this was giving the error</h2>\n\n<p><code>\nfor image_path in glob.glob('/kaggle/input/global-wheat-detection/test/*.jpg'):\n    image_name = image_path.split('/')[-1]\n    ....\n    boxes, scores, labels = prediction_model.predict_on_batch([np.expand_dims(image, axis=0)])\n   ....\n   row = [image_name.replace('.jpg','')]\n   r_boxes = \"\"\n    if(len(boxes) &gt; 0):\n            for s,b in zip(scores, boxes):\n                if r_boxes != \"\":\n                    r_boxes += \" \"\n                r_boxes += f\"{round(float(s),2)} {int(b[0])} {int(b[1])} {int(b[2]-b[0])} {int(b[3]-b[1])}\"\n     row.append(\"\")\n     result_data.append(row)\ntestDf = pd.DataFrame(result_data, columns=['image_id','PredictionString'])\ntestDf.to_csv(\"submission.csv\",index=False)\n</code></p>\n\n<h2>After ## &lt;- this is working perfectly fine</h2>\n\n<p><code>\nfor image_path in glob.glob('/kaggle/input/global-wheat-detection/test/*.jpg'):\n   **try:**\n      image_name = image_path.split('/')[-1]\n      ....\n      boxes, scores, labels = prediction_model.predict_on_batch([np.expand_dims(image, axis=0)])\n      ....\n      row = [image_name.replace('.jpg','')]\n      r_boxes = \"\"\n      if(len(boxes) &gt; 0):\n            for s,b in zip(scores, boxes):\n                if r_boxes != \"\":\n                    r_boxes += \" \"\n                r_boxes += f\"{round(float(s),2)} {int(b[0])} {int(b[1])} {int(b[2]-b[0])} {int(b[3]-b[1])}\"\n     row.append(\"\")\n     result_data.append(row)\n  **except:**\n      result_data.append([image_name.replace('.jpg',''),\"\"])\ntestDf = pd.DataFrame(result_data, columns=['image_id','PredictionString'])\ntestDf.to_csv(\"submission.csv\",index=False)\n</code></p>\n\n<p>Working notebook <a href=\"https://www.kaggle.com/savanmorya/efficientdet-keras-train-and-test-offline?scriptVersionId=39485952\">here </a></p>",
      "rawMarkdown": "I was facing this issue for a couple of days, tried so many things, the suggestion provided in the other discussion.\n\nfinally, it worked for me, whoo!!, thought let's share this.\n\n**Easy hack, try appending your prediction code with try/ catch for easy debugging.**\n\n## Before ## &lt;- this was giving the error\n```\nfor image_path in glob.glob('/kaggle/input/global-wheat-detection/test/*.jpg'):\n    image_name = image_path.split('/')[-1]\n    ....\n    boxes, scores, labels = prediction_model.predict_on_batch([np.expand_dims(image, axis=0)])\n   ....\n   row = [image_name.replace('.jpg','')]\n   r_boxes = \"\"\n    if(len(boxes) &gt; 0):\n            for s,b in zip(scores, boxes):\n                if r_boxes != \"\":\n                    r_boxes += \" \"\n                r_boxes += f\"{round(float(s),2)} {int(b[0])} {int(b[1])} {int(b[2]-b[0])} {int(b[3]-b[1])}\"\n     row.append(\"\")\n     result_data.append(row)\ntestDf = pd.DataFrame(result_data, columns=['image_id','PredictionString'])\ntestDf.to_csv(\"submission.csv\",index=False)\n```\n\n## After ## &lt;- this is working perfectly fine\n\n```\nfor image_path in glob.glob('/kaggle/input/global-wheat-detection/test/*.jpg'):\n   **try:**\n      image_name = image_path.split('/')[-1]\n      ....\n      boxes, scores, labels = prediction_model.predict_on_batch([np.expand_dims(image, axis=0)])\n      ....\n      row = [image_name.replace('.jpg','')]\n      r_boxes = \"\"\n      if(len(boxes) &gt; 0):\n            for s,b in zip(scores, boxes):\n                if r_boxes != \"\":\n                    r_boxes += \" \"\n                r_boxes += f\"{round(float(s),2)} {int(b[0])} {int(b[1])} {int(b[2]-b[0])} {int(b[3]-b[1])}\"\n     row.append(\"\")\n     result_data.append(row)\n  **except:**\n      result_data.append([image_name.replace('.jpg',''),\"\"])\ntestDf = pd.DataFrame(result_data, columns=['image_id','PredictionString'])\ntestDf.to_csv(\"submission.csv\",index=False)\n```\n\nWorking notebook [here ](https://www.kaggle.com/savanmorya/efficientdet-keras-train-and-test-offline?scriptVersionId=39485952)",
      "votes": 5
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "944807": "I was facing this issue for a couple of days, tried so many things, the suggestion provided in the other discussion.\n\nfinally, it worked for me, whoo!!, thought let's share this.\n\n**Easy hack, try appending your prediction code with try/ catch for easy debugging.**\n\n## Before ## &lt;- this was giving the error\n```\nfor image_path in glob.glob('/kaggle/input/global-wheat-detection/test/*.jpg'):\n    image_name = image_path.split('/')[-1]\n    ....\n    boxes, scores, labels = prediction_model.predict_on_batch([np.expand_dims(image, axis=0)])\n   ....\n   row = [image_name.replace('.jpg','')]\n   r_boxes = \"\"\n    if(len(boxes) &gt; 0):\n            for s,b in zip(scores, boxes):\n                if r_boxes != \"\":\n                    r_boxes += \" \"\n                r_boxes += f\"{round(float(s),2)} {int(b[0])} {int(b[1])} {int(b[2]-b[0])} {int(b[3]-b[1])}\"\n     row.append(\"\")\n     result_data.append(row)\ntestDf = pd.DataFrame(result_data, columns=['image_id','PredictionString'])\ntestDf.to_csv(\"submission.csv\",index=False)\n```\n\n## After ## &lt;- this is working perfectly fine\n\n```\nfor image_path in glob.glob('/kaggle/input/global-wheat-detection/test/*.jpg'):\n   **try:**\n      image_name = image_path.split('/')[-1]\n      ....\n      boxes, scores, labels = prediction_model.predict_on_batch([np.expand_dims(image, axis=0)])\n      ....\n      row = [image_name.replace('.jpg','')]\n      r_boxes = \"\"\n      if(len(boxes) &gt; 0):\n            for s,b in zip(scores, boxes):\n                if r_boxes != \"\":\n                    r_boxes += \" \"\n                r_boxes += f\"{round(float(s),2)} {int(b[0])} {int(b[1])} {int(b[2]-b[0])} {int(b[3]-b[1])}\"\n     row.append(\"\")\n     result_data.append(row)\n  **except:**\n      result_data.append([image_name.replace('.jpg',''),\"\"])\ntestDf = pd.DataFrame(result_data, columns=['image_id','PredictionString'])\ntestDf.to_csv(\"submission.csv\",index=False)\n```\n\nWorking notebook [here ](https://www.kaggle.com/savanmorya/efficientdet-keras-train-and-test-offline?scriptVersionId=39485952)"
  }
}