/** * Upload a TensorFlow Lite model to your project and publish it. * * @param {string} tflite Path to the tflite file you want to upload. * @param {string} displayName A name to identify the model in your Firebase * project. This is the name you use from your app to load the model. * @param {?Array<string>=} tags Optional tags to help with model management. */ const uploadModel = async (tflite, displayName, tags = null) => { console.log('Uploading model to Cloud Storage...'); const files = await storageBucket.upload(tflite); const bucket = files[0].metadata.bucket; const name = files[0].metadata.name; const gcsUri = `gs://${bucket}/${name}`; const modelSpec = { displayName: displayName, tfliteModel: { gcsTfliteUri: gcsUri }, }; if (tags != null) { modelSpec.tags = tags; } const model = await ml.createModel(modelSpec); await ml.publishModel(model.modelId); const tagList = model.tags == null ? '' : model.tags.join(", "); console.log('Model uploaded and published:'); console.log(`${model.displayName}\t\t${model.modelId}\t ${tagList}`); }
/** * Upload a TensorFlow Lite model to your project and publish it. * * @param {string} tflite Path to the tflite file you want to upload. * @param {string} displayName A name to identify the model in your Firebase * project. This is the name you use from your app to load the model. * @param {?Array<string>=} tags Optional tags to help with model management. */ const uploadModel = async (tflite, displayName, tags = null) => { console.log('Uploading model to Cloud Storage...'); const files = await storageBucket.upload(tflite); const bucket = files[0].metadata.bucket; const name = files[0].metadata.name; const gcsUri = `gs://${bucket}/${name}`; const modelSpec = { displayName: displayName, tfliteModel: { gcsTfliteUri: gcsUri }, }; if (tags != null) { modelSpec.tags = tags; } const model = await ml.createModel(modelSpec); await ml.publishModel(model.modelId); const tagList = model.tags == null ? '' : model.tags.join(", "); console.log('Model uploaded and published:'); console.log(`${model.displayName}\t\t${model.modelId}\t ${tagList}`); }