Open joeyklee opened 5 years ago
Replicate the directory and file structure: ${model}/${architecture}/${quant}/model-stride${stride}.json
like this:
bodypix/MobileNetV1/quant2/075/model-stride16.json
And write the local version of saved_models
to get the url.
const config = {
architecture: 'MobileNetV1',
outputStride: 16,
multiplier: 0.75,
quantBytes: 2
}
const modelUrl = getModelUrl(config);
const net = await bodyPix.load({modelUrl});
ref: https://github.com/tensorflow/tfjs-models/blob/master/body-pix/src/saved_models.ts
const MOBILENET_BASE_URL =
'https://storage.googleapis.com/tfjs-models/savedmodel/bodypix/mobilenet/';
// The BodyPix 2.0 MobileNetV1 models use the latest TensorFlow.js 1.0 model
// format.
export function mobileNetSavedModel(
stride: number, multiplier: number, quantBytes: number): string {
const toStr: {[key: number]: string} = {1.0: '100', 0.75: '075', 0.50: '050'};
const graphJson = `model-stride${stride}.json`;
// quantBytes=4 corresponding to the non-quantized full-precision SavedModel.
if (quantBytes === 4) {
return MOBILENET_BASE_URL + `float/${toStr[multiplier]}/` + graphJson;
} else {
return MOBILENET_BASE_URL + `quant${quantBytes}/${toStr[multiplier]}/` +
graphJson;
}
}
Question regarding how to best structure the directory structure for mobilenet.
Right now the mobilenet URL looks like this, for example:
Should we strive to recplicate the directory structure that googleapis has done (e.g.
/tfhub-tfjs-modules/.../.../
? but rather replacestorage.googleapis.com
withlocalhost:<PORT>
? or just do our own thing?