Single Image Inference with Raspberry Pi Using Docker -> a.map issue

Hello! I’ve been following this tutorial ( Raspberry Pi (Legacy) | Roboflow Docs ) on how to perform inference on a single image on Raspberry Pi using Docker, but I keep getting this error when working with my custom model:

You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
TypeError: a.map is not a function
    at t.<anonymous> (/inference-server/server/node_modules/roboflow-node/roboflow.js:2:81064)
    at /inference-server/server/node_modules/roboflow-node/roboflow.js:2:79693
    at Object.next (/inference-server/server/node_modules/roboflow-node/roboflow.js:2:79798)
    at u (/inference-server/server/node_modules/roboflow-node/roboflow.js:2:78512)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

However, the whole system seems to work when I use the public construction site safety model by Roboflow (https://universe.roboflow.com/roboflow-universe-projects/construction-site-safety). I’m not sure if this is an issue with my specific model, especially because it seems that Docker is able to download the weights without an issue. Has anyone run into this before?

VSCode file:

from roboflow import Roboflow
rf = Roboflow(api_key="")
project = rf.workspace("science-research-ys1ki").project("large-dataset-drowning-detection")

model = project.version(2, local="http://localhost:9001/").model
#rf = Roboflow(api_key="")
#project = rf.workspace("roboflow-universe-projects").project("construction-site-safety")

#model = project.version(25, local="http://localhost:9001/").model
prediction = model.predict(
    "drowningkidfromabovewater.jpg",
    confidence=20,
    overlap=30)
## get predictions on hosted images
#prediction = model.predict("YOUR_IMAGE.jpg", hosted=True)
data = prediction.json()
predictions = data.get("predictions") or []
print(predictions)

The code I use to start Docker:

sudo docker run --net=host roboflow/inference-server:cpu 

Thanks!

Hey! A couple thoughts while you wait for an expert to jump in here:

  • you’re working off some outdated documentation. You might want to check out some of the newer docs: https://inference.roboflow.com/install/raspberry-pi/
  • And then when you say the Roboflow model works but not yours, it makes me wonder if you need the API Key in your code (currently commented out)

Just a couple things to try if you want! Happy Building!

2 Likes

Thanks for your help! I’m currently reading through the website right now, it looks like starting a virtual environment using Pyenv can help download the Roboflow SDK package beforehand (for anyone else struggling with the same issue).

I tried a different model using the same pipeline as before, and it did work! I think the model I had before was too large (~2000 images), and it kept getting stuck somewhere along the way. However, I’m still receiving no predictions (empty bracket) when on another model.

Glad you’re making progress! I see you’ve got confidence at 20% in your code above so that’s probably not the issue with no predictions. Certainly be sure to try an image from the training data as that will have higher likelihood of success and remove the “new image not working” variable. (No predictions can be SO many things!)

It turns out that the model was having trouble returning its predictions! I used this code instead and it seemed to work fine:

from inference_sdk import InferenceHTTPClient
import json

client = InferenceHTTPClient(
    api_url="https://detect.roboflow.com",
    api_key="<API_KEY>"
)


result = client.infer(
    inference_input="assets/kiddrowning.jpg",
    model_id="small-dataset-ddepb/3"
)

print("DROWNING DETECTION RESULTS")
print("="*50)

if result and 'predictions' in result:
    predictions = result['predictions']
    
    if len(predictions) > 0:
        for i, pred in enumerate(predictions):
            class_name = pred.get('class', 'unknown')
            confidence = pred.get('confidence', 0)
            print(f"\nDetection {i+1}:")
            print(f"  Class: {class_name}")
            print(f"  Confidence: {confidence:.1%}")
            print(f"  Location: x={pred.get('x', 0):.1f}, y={pred.get('y', 0):.1f}")
            print(f"  Size: {pred.get('width', 0):.1f} x {pred.get('height', 0):.1f}")
        
        print(f"\n>>> DROWNING DETECTED with {predictions[0]['confidence']:.1%} confidence")
    else:
        print("\nNo drowning detected in the image")
else:
    print("No predictions returned")

Thanks for your help!

1 Like

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