tensorflow.jstfjs-node

How to load bodypix model from local disk?


My app can't connect Internet all the time, and how to load trained bodypix from local disk? The nodejs code snippet

    const net = await bodyPix.load({
        architecture: 'MobileNetV1',
        outputStride: 16,
        multiplier: 0.75,
        quantBytes: 2,
    });

In README.md I found

modelUrl - An optional string that specifies custom url of the model. This is useful for local development or countries that don't have access > to the models hosted on GCP.

Could you please give me an example what the url is of the local model? and what's the content of the dest model (BTW: how can I download the trained model?). Thanks very much!


Solution

  • To load a bodypix model locally you need to download, and host the model's json, and .bin files then access them using the modelUrl option.

    Eg:

    const net = await bodyPix.load({
        architecture: 'MobileNetV1',
        outputStride: 16,
        multiplier: 0.75,
        quantBytes: 2,
        modelUrl: "/public/model-stride16.json"
    });
    

    The url passed to modelUrl must be a valid url.