{
  "id": 583962,
  "title": "I need help with inference code",
  "url": "/competitions/cmi-detect-behavior-with-sensor-data/discussion/583962",
  "author_name": "",
  "post_date": "2025-06-10T16:43:20.384089200Z",
  "votes": null,
  "comment_count": 5,
  "views": 0,
  "content": "<p>My code fails in inference again and again. Here error:     GatewayRuntimeError: (, '')</p>",
  "messages": [
    {
      "id": "3221258",
      "postDate": "06/10/2025 16:43:20",
      "content": "<p>My code fails in inference again and again. Here error:     GatewayRuntimeError: (, '')</p>",
      "rawMarkdown": "My code fails in inference again and again. Here error: \tGatewayRuntimeError: (<GatewayRuntimeErrorType.SERVER_RAISED_EXCEPTION: 3>, '')",
      "votes": null
    },
    {
      "id": "3222176",
      "postDate": "06/12/2025 00:48:31",
      "content": "<p>You probably trained models in Inference Notebook, which will cause a timeout error. Upload your trained model to the inference notebook instead.</p>",
      "rawMarkdown": "You probably trained models in Inference Notebook, which will cause a timeout error. Upload your trained model to the inference notebook instead.",
      "votes": null
    },
    {
      "id": "3222229",
      "postDate": "06/12/2025 03:37:03",
      "content": "<p>No, separately.</p>",
      "rawMarkdown": "No, separately.",
      "votes": null
    },
    {
      "id": "3223613",
      "postDate": "06/13/2025 15:01:45",
      "content": "<p>can i see the code</p>",
      "rawMarkdown": "can i see the code",
      "votes": null
    },
    {
      "id": "3224674",
      "postDate": "06/15/2025 09:55:18",
      "content": "<p>I encountered a similar issue, and it was resolved by explicitly returning the prediction result as a string. I haven't seen your code, so I'm not sure if this applies, but if it's worth trying, give it a shot.</p>\n<pre><code> (gesture)\n</code></pre>",
      "rawMarkdown": "I encountered a similar issue, and it was resolved by explicitly returning the prediction result as a string. I haven't seen your code, so I'm not sure if this applies, but if it's worth trying, give it a shot.\n\n```python\nreturn str(gesture)\n```",
      "votes": null
    },
    {
      "id": "3225822",
      "postDate": "06/16/2025 22:23:23",
      "content": "<p>I had the same issue as <a href=\"https://www.kaggle.com/Isao\" target=\"_blank\">@Isao</a>. The API error message(s) are not very helpful.</p>\n<p>My predict code was returning type <code>np._str</code> rather than <code>str</code>, which looks the same but causes problems with the API code. I have a cell in my notebook that makes sure the predict function is returning a <code>str</code>:</p>\n<pre><code> sequence_id  (test[]):\n\n    =predict(test.filter(test[] == sequence_id),\n              test_demographics)\n    (sequence_id,,p)\n\n    # Should be &lt;class &gt;:\n    (type(p))\n</code></pre>",
      "rawMarkdown": "I had the same issue as @Isao. The API error message(s) are not very helpful.\n\nMy predict code was returning type `np._str` rather than `str`, which looks the same but causes problems with the API code. I have a cell in my notebook that makes sure the predict function is returning a `str`:\n\n```\nfor sequence_id in set(test['sequence_id']):\n    \n    p=predict(test.filter(test['sequence_id'] == sequence_id),\n              test_demographics)\n    print(sequence_id,':',p)\n    \n    # Should be <class 'str'>:\n    print(type(p))\n```",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 3222176,
      "author_name": "shanzhong8",
      "author_url": "",
      "post_date": "06/12/2025 00:48:31",
      "content": "<p>You probably trained models in Inference Notebook, which will cause a timeout error. Upload your trained model to the inference notebook instead.</p>",
      "votes": null,
      "replies": [
        {
          "id": 3222229,
          "author_name": "rustambazarbayev",
          "author_url": "",
          "post_date": "06/12/2025 03:37:03",
          "content": "<p>No, separately.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 3223613,
      "author_name": "ramanofthesky",
      "author_url": "",
      "post_date": "06/13/2025 15:01:45",
      "content": "<p>can i see the code</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 3224674,
      "author_name": "utm529fg",
      "author_url": "",
      "post_date": "06/15/2025 09:55:18",
      "content": "<p>I encountered a similar issue, and it was resolved by explicitly returning the prediction result as a string. I haven't seen your code, so I'm not sure if this applies, but if it's worth trying, give it a shot.</p>\n<pre><code> (gesture)\n</code></pre>",
      "votes": null,
      "replies": [
        {
          "id": 3225822,
          "author_name": "nnjjpp",
          "author_url": "",
          "post_date": "06/16/2025 22:23:23",
          "content": "<p>I had the same issue as <a href=\"https://www.kaggle.com/Isao\" target=\"_blank\">@Isao</a>. The API error message(s) are not very helpful.</p>\n<p>My predict code was returning type <code>np._str</code> rather than <code>str</code>, which looks the same but causes problems with the API code. I have a cell in my notebook that makes sure the predict function is returning a <code>str</code>:</p>\n<pre><code> sequence_id  (test[]):\n\n    =predict(test.filter(test[] == sequence_id),\n              test_demographics)\n    (sequence_id,,p)\n\n    # Should be &lt;class &gt;:\n    (type(p))\n</code></pre>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "3221258": "My code fails in inference again and again. Here error: \tGatewayRuntimeError: (<GatewayRuntimeErrorType.SERVER_RAISED_EXCEPTION: 3>, '')",
    "3222176": "You probably trained models in Inference Notebook, which will cause a timeout error. Upload your trained model to the inference notebook instead.",
    "3222229": "No, separately.",
    "3223613": "can i see the code",
    "3224674": "I encountered a similar issue, and it was resolved by explicitly returning the prediction result as a string. I haven't seen your code, so I'm not sure if this applies, but if it's worth trying, give it a shot.\n\n```python\nreturn str(gesture)\n```",
    "3225822": "I had the same issue as @Isao. The API error message(s) are not very helpful.\n\nMy predict code was returning type `np._str` rather than `str`, which looks the same but causes problems with the API code. I have a cell in my notebook that makes sure the predict function is returning a `str`:\n\n```\nfor sequence_id in set(test['sequence_id']):\n    \n    p=predict(test.filter(test['sequence_id'] == sequence_id),\n              test_demographics)\n    print(sequence_id,':',p)\n    \n    # Should be <class 'str'>:\n    print(type(p))\n```"
  },
  "source": "meta"
}