• DepthAI
  • Request for assistance with OAK-D POE CM4 and Jetson TX2 integration

Hi erik

I've trained my model and deployed it on Roboflow. Following the tutorial, I modified the main.py code:

import cv2
from depthai_sdk import OakCamera
from depthai_sdk.classes.packets import TwoStagePacket
from depthai_sdk.visualize.configs import TextPosition
from deep_sort_realtime.deepsort_tracker import DeepSort

tracker = DeepSort(max_age=1000, nn_budget=None, embedder=None, nms_max_overlap=1.0, max_cosine_distance=0.2)

def cb(packet: TwoStagePacket):
    detections = packet.img_detections.detections
    vis = packet.visualizer
    # Update the tracker
    object_tracks = tracker.iter(detections, packet.nnData, (640, 640))

    for track in object_tracks:
        if not track.is_confirmed() or \
            track.time_since_update > 1 or \
            track.detection_id >= len(detections) or \
            track.detection_id < 0:
            continue

        det = packet.detections[track.detection_id]
        vis.add_text(f'ID: {track.track_id}',
                        bbox=(*det.top_left, *det.bottom_right),
                        position=TextPosition.MID)
    frame = vis.draw(packet.frame)
    cv2.imshow('DeepSort tracker', frame)


with OakCamera() as oak:
    color = oak.create_camera('color')
    model_config = {
            'source': 'roboflow', 
            'model':'usv-7kkhf/4',
            'key':'zzzzzzzzzzzzzzz' # FAKE Private API key
    }
    yolo = oak.create_nn(model_config,color)
    embedder = oak.create_nn('mobilenetv2_imagenet_embedder_224x224', input=yolo)

    oak.visualize(embedder, fps=True, callback=cb)
    # oak.show_graph()
    oak.start(blocking=True)

However, I'm encountering an error stating that it can't find my trained model:

Exception: {'message': 'No trained model was found.', 'type': 'GraphMethodException', 'hint': 'You must train a model on this version with Roboflow Train before you can use inference.', 'e': ['Model not found, looking for filename 4JiY9CSQUUctWZgCzw210yo9qcw2/heRJlafm8KwTDQrTn8dI/4/roboflow.zip']}

Sentry is attempting to send 2 pending error messages

So, I saved my file as best.py and then used the model converter. I'd like to know how to implement it into the code:

Thanks for your assistance.

    Hi Babacar
    The roboflow api should work as expected it think. I am also getting the same errors though, so I asked the roboflow team what the correct procedure for using the models is.

    Ill get back to you on that.
    In the meanwhile, use the downloaded blob path to when creating your neural network.

    Thanks,
    Jaka

      Hi jakaskerl

      Do you have any idea how to use it with this code: https://github.com/luxonis/depthai-experiments/blob/master/gen2-deepsort-tracking/main.py?

      I tried replacing the yolov6 model with my blob file, but I received this error:

      File "/home/pi/Tracking/gen3-deepsort-tracking/main.py", line 43, in <module>
      oak.start(blocking=True)
      File "/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/oak_camera.py", line 347, in start
      self.build()
      File "/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/oak_camera.py", line 465, in build
      xouts = out.setup(self.pipeline, self.oak.device, names)
      File "/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/classes/output_config.py", line 54, in setup
      xoutbase: XoutBase = self.output(pipeline, device)
      File "/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/components/nn_component.py", line 629, in main
      out = XoutTwoStage(det_nn=self.
      comp.input,
      File "/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/oak_outputs/xout/xout_nn.py", line 289, in init
      self.whitelist_labels: Optional[List[int]] = second_nn.
      multi_stage_nn.whitelist_labels
      AttributeError: 'NoneType' object has no attribute 'whitelist_labels'
      Sentry is attempting to send 2 pending error messages
      Waiting up to 2 seconds
      Press Ctrl-C to quit~

      I appreciate your help.

        Hi Babacar
        I think you need to edit the callback function to correctly parse the results from your model. Try removing all the logic inside the callback to see if it still causes the same error. I'm not sure whether it stems from the parsing or whether it's a visualizer problem.

        Thanks,
        Jaka