JSONDecodeError when trying to use Roboflow Model with Webcam

Hello! I have a small problem here, if anyone could help. I have been trying to use a Roboflow Model for live Object Detection using a webcam and some python code, and it is my first time working on such a project, so it is taking some time to understand everything.

I trained my dataset using the Google Colab for yolov8 (Model Type: yolov8s Model Upload). However, when infering the frames, I need to extract the position of the bounding box and its confidence, at best using JSON, however I keep getting JSONDecodeError (raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0))

From this I take that my response is not decodable to JSON, but why? It seems to work for other people, as I have seen online. I have not found an answer to this problem online.

I have found the most common method to infer the frames is using the upload link to the Roboflow Inference API, so I found this code and copied it. I have seen that on the website, theres an Option to have the result as an image or as JSON, is there a way to specify this in python maybe?

What I find weird, is that the response status is 200, but the raw response would be something like this: <urllib3.response.HTTPResponse object at 0x0000019865274D60>. What does this mean?

Hopefully I have described the situation well enough, if there is any necessary info needed please ask.

Hey @Mila_Castillo

Our hosted inference API has two return formats, specified in the format query parameter: image and json, where JSON is the default.

In your query URL, you specify an image return format that returns an image (not readable JSON) with annotated predictions as a binary blob. If you’re looking for JSON, you should either remove the “&format=image” from your URL, which will make it default to JSON, or specify format=json.

Hope this helps

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.