# 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.

This example requires the DepthAI v3 API, see [installation instructions](https://docs.luxonis.com/software-v3/depthai.md).

## Source code

#### Python

```python
#!/usr/bin/env python3

import time
import depthai as dai

# Describe the model I want to download - two options: in program or from yaml file

# Option 1: In program
# modelDescription = dai.NNModelDescription(model="yolov6-nano", platform="RVC2", ...)

# Option 2: From yaml file
modelDescription = dai.NNModelDescription.fromYamlFile("./mymodel.yaml")

# If you want, you can store the model description in a yaml file
modelDescription.saveToYamlFile("./mymodel.yaml")

# Return path to downloaded model - yolov6-nano-r2-288x512.tar.xz for this example
modelPath = dai.getModelFromZoo(modelDescription, useCached=False, progressFormat="pretty")
print(f"Model path: {modelPath}")

# Load the model (most of the time it's a NNArchive)
archive = dai.NNArchive(modelPath)

print(f"Input size of the model {archive.getInputSize()}, name is {archive.getConfig().model.metadata.name}")
# The arhive can then be used with any of the neural network nodes (NeuralNetwork, DetectionNetwork, SpatialDetectionNetwork)
```

#### C++

```cpp
#include <iostream>

#include "depthai/depthai.hpp"

int main() {
    // Option 1: In program
    // dai::NNModelDescription modelDescription;
    // modelDescription.model = "yolov6-nano";
    // modelDescription.platform = "RVC2";

    // Option 2: From yaml file
    auto modelDescription = dai::NNModelDescription::fromYamlFile("./mymodel.yaml");
    std::cout << "Model description: " << modelDescription << std::endl;

    // If you want, you can store the model description in a yaml file
    modelDescription.saveToYamlFile("./mymodel.yaml");

    // Return path to downloaded model - yolov6-nano-r2-288x512.tar.xz for this example
    auto modelPath = dai::getModelFromZoo(modelDescription, false);  // false means don't use cached model
    std::cout << "Model path: " << modelPath << std::endl;

    // Load the model (most of the time it's a NNArchive)
    dai::NNArchive archive(modelPath);

    // Get input size and name of the model
    auto inputSize = archive.getInputSize();
    if(inputSize) {
        std::cout << "Input size of the model: " << inputSize->first << "x" << inputSize->second << std::endl;
    }
    std::cout << "Model name is: " << archive.getConfig<dai::nn_archive::v1::Config>().model.metadata.name << std::endl;

    return 0;
}
```

### Need assistance?

Head over to [Discussion Forum](https://discuss.luxonis.com/) for technical support or any other questions you might have.
