InitOption
backendOptions: object
[webdnn.ts:150]
Backend-specific options. Currently (v1.3), this option has no effect.
backendOrder: BackendName
| Array
[webdnn.ts:145]
The order of backend names to be initialized.
cacheStrategy: "latest"
| "networkFirst"
| "cacheFirst"
| "networkOnly"
| "cacheOnly"
[webdnn.ts:244]
WebDNN cache strategy. One of follows is available.
latest
(default)Fetch
descriptor.json
at first and check whether assets in server is same as cached assets. If it's same, use cached assets, otherwise, fetch all assets and replace cached assets.networkFirst
Fetch all asset files. If it succeeds, use fetched assets. If failed, use cached assets if exist, otherwise, an error is thrown.
cacheFirst
If cache is exist, use cache, otherwise, fetch assets. If it failed, an error is thrown.
networkOnly
Fetch all asset files. If failed, an error is thrown.
cacheOnly
If cache is exist, use cache, otherwise, an error is thrown.
progressCallback: function
[webdnn.ts:166]
Callback function which is called to notice the progress status of loading binary data.
Currently Streaming fetch feature is not perfectly supported in browsers. Therefore, this option will be ignored in some web browsers.
Examples
let runner = await WebDNN.load('./model', {
progressCallback: (loaded, total) => console.log(`${ (loaded/total*100).toFixed(1) }% Loaded`);
});
saveCache: boolean
[webdnn.ts:249]
If true, WebDNN save fetched parameter data cache in available WebStorage
. As default, it's true
.
transformUrlDelegate: function
[webdnn.ts:217]
Delegate function which will be called with original url, and must return converted url strings. This function is called before WebDNN fetch any data (descriptor json file, and binary data) You can modified url to fetch data from other domain, for example.
If both
InitOption.weightDirectory
and
InitOption.transformUrlDelegate
are specified,
At first, all urls of binary weights' are replaced by InitOption.weightDirectory
, and then
InitOption.transformUrlDelegate
are applied.
Examples
Fetch binary data from other domain
// Graph descriptor JSON file will be loaded from 'original.host.com/model', and
// model binary data will be loaded from 'custom.host.com/model'.
WebDNN.load('https://original.host.com/model', {
transformUrlDelegate: (url) => {
if ((/\.bin/).test(url)) {
url = url.replace('original.host.com', 'custom.host.com');
}
return url;
}
});
weightDirectory: string
[webdnn.ts:187]
URL of directory that contains weight binary files.
If both
InitOption.weightDirectory
and
InitOption.transformUrlDelegate
are specified,
At first, all urls of binary weights' are replaced by InitOption.weightDirectory
, and then
InitOption.transformUrlDelegate
are applied.
Examples
// Graph descriptor JSON file will be loaded from 'original.host.com/model', and
// model binary data will be loaded from 'custom.host.com/model'.
WebDNN.load('https://original.host.com/model', {
weightDirectory: 'https://custom.host.com/model'
});
Option structure of
WebDNN.load