Skip to content

Instantly share code, notes, and snippets.

@Nithanaroy
Last active August 28, 2021 17:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nithanaroy/7b89309d06b1321776cc92574239e103 to your computer and use it in GitHub Desktop.
Save Nithanaroy/7b89309d06b1321776cc92574239e103 to your computer and use it in GitHub Desktop.
Load Tensorflow JS model from Google Drive
async function loadModel() {
google.script.run.withSuccessHandler(async modelFiles => {
const modelJson = new File([modelFiles[0]], "model.json", { type: "application/json" })
const modelWeights = new File([Uint8Array.from(modelFiles[1])], "group1-shard1of1.bin")
model = await tf.loadLayersModel(tf.io.browserFiles([modelJson, modelWeights]))
model.summary();
}).withFailureHandler(onFailure).loadModelFromDrive();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment