Every model supported by the demo script includes a JSON file. For example, here is the one for Mobilenet SSD:

{
    "nn_config":
    {
        "output_format" : "detection",
        "NN_family" : "mobilenet",
        "confidence_threshold" : 0.5,
        "input_size": "300x300"
    },
    "mappings":
    {
        "labels":
        [
            "background",
            "aeroplane",
            "bicycle",
            "bird",
            "boat",
            "bottle",
            "bus",
            "car",
            "cat",
            "chair",
            "cow",
            "diningtable",
            "dog",
            "horse",
            "motorbike",
            "person",
            "pottedplant",
            "sheep",
            "sofa",
            "train",
            "tvmonitor"
        ]
    }
}

I wonder what's the purpose of these files. Like, is the JSON file read by the host or the DepthAI device? Why do we need to specify the output_format, NN_family, and input_size when the complete architecture of the deployed model is already encoded in <model>.blob?

To make things more complicated, @PINTO on Discord pointed me to an example without any JSON file: https://github.com/luxonis/depthai-experiments/tree/d34fbf3664b788088e26012c5aa973dc864520ed/gen2-mobile-object-localizer. So is it optional?

In addition, this tutorial by Roboflow refers to the creation of such a JSON file as a "major hack", but hacks are unreliable! Is there a non-hacky way to create one for my own custom model (if I need it)?

  • erik replied to this.

    Hello nalzok , great question, it's used by the depthai_demo (host side) to construct the pipeline correctly. Eg. there's input size to the model, so depthai_demo has to set camRgb.setPreviewSize(300,300). There's NN_family so depthai_demo knows that it has to create MobileNetDetectionNetwork. There's labels so it knows that class 3 means bicycle. It's just so that the result of the NN is displayed/presented to the user in a nice way (instead of printing byte arrays๐Ÿ™‚). If you would like to use your own model with depthai_demo, you would need to create this json file (or refactor depthai_demo in a way that it doesn't use json.... but uses some other way to specify all the configurations currently in the json๐Ÿ™‚).
    Thanks, Erik