Skip to content

Commit a048884

Browse files
committed
change mobilenet url
1 parent 25a773f commit a048884

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

imageml.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,15 @@ let Camera = (function () {
241241
headElement.appendChild(newScriptElement);
242242
}
243243

244+
async function getMobileNet() {
245+
try {
246+
return await tf.loadModel('https://storage.googleapis.com/tfjs-models/tfjs/mobilenet_v1_0.25_224/model.json');
247+
} catch (e) {
248+
console.warn(`Load ${HOST_URL} MobileNet...`);
249+
return await tf.loadModel(HOST_URL + '/mobilenet/v1_0.25_224/model.json');
250+
}
251+
}
252+
244253
async function start(modelName, camSource, userId, _rotate) {
245254
console.log("tfjs 0.13.4");
246255
var rotate = _rotate;
@@ -249,7 +258,7 @@ let Camera = (function () {
249258
loadJS('https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]');
250259
// load models
251260
try {
252-
const _mobilenet = await tf.loadModel(HOST_URL + '/mobilenet/v1_0.25_224/model.json');
261+
const _mobilenet = await getMobileNet()
253262
const layer = _mobilenet.getLayer('conv_pw_13_relu');
254263
mobilenet = tf.model({ inputs: _mobilenet.inputs, outputs: layer.output });
255264
if (modelName.indexOf('https://') === 0) {

0 commit comments

Comments
 (0)