Program Listing for File Zoo.hpp

Return to documentation for file (include/depthai/modelzoo/Zoo.hpp)

#pragma once

#include <filesystem>
#include <ostream>
#include <string>

namespace dai {

namespace fs = std::filesystem;

struct SlugComponents {
    std::string teamName;
    std::string modelSlug;
    std::string modelVariantSlug;
    std::string modelRef;

    // Merges the fields into a single string
    std::string merge() const;

    // Splits a slug string into components
    static SlugComponents split(const std::string& slug);
};

struct NNModelDescription {
    static NNModelDescription fromYamlFile(const fs::path& modelName, const fs::path& modelsPath = "");

    void saveToYamlFile(const fs::path& yamlPath) const;

    bool check() const;

    std::string toString() const;

    std::string model;

    std::string platform;

    std::string optimizationLevel;

    std::string compressionLevel;

    std::string snpeVersion;

    std::string modelPrecisionType;

    std::string globalMetadataEntryName;
};

fs::path getModelFromZoo(const NNModelDescription& modelDescription,
                         bool useCached = true,
                         const fs::path& cacheDirectory = "",
                         const std::string& apiKey = "",
                         const std::string& progressFormat = "none");

bool downloadModelsFromZoo(const fs::path& path,
                           const fs::path& cacheDirectory = "",
                           const std::string& apiKey = "",
                           const std::string& progressFormat = "none");

std::ostream& operator<<(std::ostream& os, const NNModelDescription& modelDescription);

namespace modelzoo {

void setHealthEndpoint(const std::string& endpoint);

void setDownloadEndpoint(const std::string& endpoint);

void setDefaultCachePath(const fs::path& path);

void setDefaultModelsPath(const fs::path& path);

std::string getHealthEndpoint();

std::string getDownloadEndpoint();

fs::path getDefaultCachePath();

fs::path getDefaultModelsPath();

}  // namespace modelzoo

}  // namespace dai