Software Stack
DepthAI
  • DepthAI Components
    • AprilTags
    • Benchmark
    • Camera
    • DetectionNetwork
    • EdgeDetector
    • Events
    • FeatureTracker
    • HostNodes
    • ImageAlign
    • ImageManip
    • IMU
    • Misc
    • Modelzoo
    • NeuralNetwork
    • RecordReplay
    • RGBD
    • Script
    • SpatialDetectionNetwork
    • SpatialLocationCalculator
    • StereoDepth
    • Sync
    • SystemLogger
    • VideoEncoder
    • Visualizer
    • Warp
    • RVC2-specific
  • Advanced Tutorials
  • API Reference
  • Tools

ON THIS PAGE

  • Model Zoo
  • Setup
  • Source code

Model Zoo

The example illustrates loading and managing a YOLOv6-Nano neural network model using DepthAI, either programmatically or via a YAML file, downloading the model from the model zoo and getting the model's path on the filesystem. Moreover, it shows how to extract the model's input size and metadata.

Setup

This example requires the DepthAI v3 API, see installation instructions.

Source code

Python
C++

Python

Python
GitHub
1#!/usr/bin/env python3
2
3import time
4import depthai as dai
5
6# Describe the model I want to download - two options: in program or from yaml file
7
8# Option 1: In program
9# modelDescription = dai.NNModelDescription(model="yolov6-nano", platform="RVC2", ...)
10
11# Option 2: From yaml file
12modelDescription = dai.NNModelDescription.fromYamlFile("./mymodel.yaml")
13
14# If you want, you can store the model description in a yaml file
15modelDescription.saveToYamlFile("./mymodel.yaml")
16
17# Return path to downloaded model - yolov6-nano-r2-288x512.tar.xz for this example
18modelPath = dai.getModelFromZoo(modelDescription, useCached=False)
19print(f"Model path: {modelPath}")
20
21# Load the model (most of the time it's a NNArchive)
22archive = dai.NNArchive(modelPath)
23
24print(f"Input size of the model {archive.getInputSize()}, name is {archive.getConfig().model.metadata.name}")
25# The arhive can then be used with any of the neural network nodes (NeuralNetwork, DetectionNetwork, SpatialDetectionNetwork)

Need assistance?

Head over to Discussion Forum for technical support or any other questions you might have.