Custom Model Upload not working

I’m trying to upload a model but I everytime I try to run the code I encounter this error:

Traceback (most recent call last):
File “/home/juliocesar/.local/lib/python3.9/site-packages/requests/models.py”, line 910, in json
return complexjson.loads(self.text, **kwargs)
File “/usr/lib/python3.9/json/init.py”, line 346, in loads
return _default_decoder.decode(s)
File “/usr/lib/python3.9/json/decoder.py”, line 340, in decode
raise JSONDecodeError(“Extra data”, s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 5 (char 4)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/juliocesar/prueba1.py”, line 5, in
response = requests.post(“http://localhost:80/v1/vision/custom/blip_model",files={"image”:image_data}).json()
File “/home/juliocesar/.local/lib/python3.9/site-packages/requests/models.py”, line 917, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: [Errno Extra data] 404 page not found: 4

I’m following this procedure:
My model it’s called blip_model.pt and the way I’m uploading it to docker with the following command:
sudo docker run -v /home/juliocesar/my-models/ -p 80:5000 deepquestai/deepstack

my-models is the folder where I located the model.

Next step I try to run the following code:

import requests

image_data = open(“test.jpg”,“rb”).read()

response = requests.post(“http://localhost:80/v1/vision/custom/blip_model",files={"image”:image_data}).json()

for object in response[“predictions”]:
print(object[“label”])

print(response)

When I run the code, the error on the begging pops up.

Is there something wrong with my code or my procedure? I appreciate the help.

The docker command to setup your custom model folder is wrong, there should be a colon there because its supposed to map a local dir to a dir inside the container.

/path-to/custom-models-folder:/modelstore/detection

/home/juliocesar/my-models:/modelstore/detection

and test.jpg needs to be in that mapped folder too.

@dbinott2 No, the test.jpg image doesn’t need to be in the custom models folder.