Dear reader, I want to build a SpatialDetectionNetwork using the pipe below. This works well for a standard yolo_v6_nano network. However, using a custom "blob" file does not work for me.
Network code:
def _build_and_start_pipeline(self):
cfg = self.pipeline_config
self.pipeline = dai.Pipeline()
# Define sources and outputs
self.platform = self.pipeline.getDefaultDevice().getPlatform()
# Define sources and outputs
size = (640, 400)
camRgb = self.pipeline.create(dai.node.Camera).build(
dai.CameraBoardSocket.CAM_A,
sensorFps=cfg['fps'],
)
monoLeft = self.pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B, sensorFps=cfg['fps'])
monoRight = self.pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C, sensorFps=cfg['fps'])
if cfg['depth_source'] == 'stereo':
depthSource = self.pipeline.create(dai.node.StereoDepth)
depthSource.setExtendedDisparity(cfg['stereo_extended_disparity'])
monoLeft.requestOutput(size).link(depthSource.left)
monoRight.requestOutput(size).link(depthSource.right)
elif cfg['depth_source'] == "neural":
depthSource = self.pipeline.create(dai.node.NeuralDepth).build(
monoLeft.requestFullResolutionOutput(),
monoRight.requestFullResolutionOutput(),
dai.DeviceModelZoo.NEURAL_DEPTH_LARGE,
)
else:
self.get_logger().fatal(f"Unknown depth_source: {cfg['depth_source']!r}")
raise ValueError(f"Invalid depth_source: {cfg['depth_source']}")
test_w_yolo_v6_nano = False
if test_w_yolo_v6_nano:
modelDescription = dai.NNModelDescription("yolov6-nano")
spatial_det_net = self.pipeline.create(dai.node.SpatialDetectionNetwork).build(
camRgb, depthSource, modelDescription)
spatial_det_net.spatialLocationCalculator.initialConfig.setSegmentationPassthrough(False)
spatial_det_net.input.setBlocking(False)
spatial_det_net.setDepthLowerThreshold(100)
spatial_det_net.setDepthUpperThreshold(5000)
else:
spatial_det_net = self.pipeline.create(dai.node.SpatialDetectionNetwork)
nn_size = (cfg['nn_width'], cfg['nn_height']) # 416X416
camRgb.requestOutput(nn_size).link(spatial_det_net.input)
depthSource.depth.link(spatial_det_net.inputDepth)
spatial_det_net.setBlobPath(cfg['blob_path'])
spatial_det_net.input.setBlocking(False)
spatial_det_net.setConfidenceThreshold(
float(cfg['metadata']['confidence_threshold'])
)
spatial_det_net.setBoundingBoxScaleFactor(0.5)
spatial_det_net.setDepthLowerThreshold(100)
spatial_det_net.setDepthUpperThreshold(5000)
spatial_det_net.detectionParser.setNumClasses(int(cfg['metadata']['classes']))
spatial_det_net.detectionParser.setCoordinateSize(
int(cfg['metadata']['coordinates'])
)
spatial_det_net.detectionParser.setAnchors(
[float(anchor) for anchor in cfg['metadata'].get('anchors', [])]
)
spatial_det_net.detectionParser.setAnchorMasks(
{
name: [int(index) for index in indices]
for name, indices in cfg['metadata'].get('anchor_masks', {}).items()
}
)
spatial_det_net.detectionParser.setIouThreshold(
float(cfg['metadata']['iou_threshold'])
)
if cfg['labels']:
spatial_det_net.detectionParser.setClasses(cfg['labels'])
spatial_det_net.spatialLocationCalculator.initialConfig.setSegmentationPassthrough(
False
)
spatial_det_net.setSpatialCalculationAlgorithm(dai.SpatialLocationCalculatorAlgorithm.MIN)
self.publisher = self.pipeline.create(Publisher)
self.publisher.build(
spatial_det_net.passthroughDepth,
spatial_det_net.out,
spatial_det_net.passthrough,
The output is:
[spatial_detector-2] [INFO] [1779821047.244518266] [spatial_detector]: SpatialDetector started - mode='v3' blob='SimpleFruitsYoloV5.blob' config='SimpleFruitsYoloV5.json' depth='stereo' extended_disparity=False rgb_size=416x416 fps=8.0 publish_images=True degraded_mode=False stall_timeout=5.0s image->'camera/rgb' depth->'stereo/depth' detections->'spatial_detections'
[spatial_detector-2] [INFO] [1779821047.245690628] [spatial_detector]: Pipeline thread started, calling pipeline.run()
[spatial_detector-2] [19443010611ADE1200] [1.3] [2.218] [NeuralNetwork(5)] [error] Input tensor 'images' (0) exceeds available data range. Data size (259584B), tensor offset (0), size (519168B) - skipping inference
Who can help me solving this issue. Kind regards, Gerard