JSPM

tfjs-azure-io-handler

0.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q36491F
  • License MIT

A package to save/load to/from azure when working with `@tensorflow/tfjs`

Package Exports

  • tfjs-azure-io-handler

Readme

Tfjs azure IO handler

tfjs-azure-io-handler provides a handler to save and load models from TensorFlow.js to an Azure storage account

Usage

Using an Azure container SAS token:

import createAzureIoHandler from "tfjs-azure-io-handler";

const handler = createAzureIoHandler(
  "location/within/azure/container",
  {
    containerName: "<container name>",
    storageAccount: "<storage account name>",
    storageSasToken: "<storage account sas token>",
  },
);

const model = await tf.loadLayersModel(handler);

await model.save(handler);

Using an Azure storage access key:

import { StorageSharedKeyCredential } from "@azure/storage-blob";
import createAzureIoHandler from "tfjs-azure-io-handler";

const handler = createAzureIoHandler(
  "location/within/azure/container",
  {
    containerName: "<container name>",
    storageAccount: "<storage account name>",
    credential: new StorageSharedKeyCredential(
      "<storage account name>",
      "<storage account key>"
    ),
  },
);

const model = await tf.loadLayersModel(handler);

await model.save(handler);

Using an anonymous connection:

import { AnonymousCredential } from "@azure/storage-blob";
import createAzureIoHandler from "tfjs-azure-io-handler";

const handler = createAzureIoHandler(
  "location/within/azure/container",
  {
    containerName: "<container name>",
    storageAccount: "<storage account name>",
    credential: new AnonymousCredential(),
  },
);

const model = await tf.loadLayersModel(handler);

// 🚫 Saving is not permitted by Azure when using `AnonymousCredential`