idmission-web-sdk 1.0.195 → 1.0.196

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,7 +48,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
48
48
  var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
49
49
  var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
50
50
 
51
- var webSdkVersion = '1.0.195';
51
+ var webSdkVersion = '1.0.196';
52
52
 
53
53
  function getPlatform() {
54
54
  if (typeof window === 'undefined') return;
@@ -1910,30 +1910,31 @@ var CameraProvider = function CameraProvider(_a) {
1910
1910
  var documentDetectionModel;
1911
1911
  function loadDocumentDetectionModel(url) {
1912
1912
  return tslib.__awaiter(this, void 0, void 0, function () {
1913
- var zeroes, tfInt32, tf4d_, tf4d, outputKeys;
1914
- return tslib.__generator(this, function (_a) {
1915
- switch (_a.label) {
1913
+ var zeroes, tfInt32, tf4d_, tf4d, _a, _b, outputKeys;
1914
+ return tslib.__generator(this, function (_c) {
1915
+ switch (_c.label) {
1916
1916
  case 0:
1917
1917
  if (documentDetectionModel) return [2 /*return*/, documentDetectionModel];
1918
1918
  return [4 /*yield*/, tf__namespace.loadGraphModel(url)];
1919
1919
  case 1:
1920
- documentDetectionModel = _a.sent();
1921
- return [4 /*yield*/, tf__namespace.ready()];
1920
+ documentDetectionModel = _c.sent();
1921
+ return [4 /*yield*/, tf__namespace.ready()
1922
+ // warm the model by predicting on an empty image
1923
+ ];
1922
1924
  case 2:
1923
- _a.sent();
1924
- _a.label = 3;
1925
- case 3:
1926
- _a.trys.push([3,, 5, 6]);
1927
- tf__namespace.engine().startScope();
1925
+ _c.sent();
1928
1926
  zeroes = tf__namespace.zeros([448, 448, 3]);
1929
1927
  tfInt32 = tf__namespace.cast(zeroes, 'int32');
1930
1928
  tf4d_ = tf__namespace.tensor4d(Array.from(tfInt32.dataSync()), [1, 448, 448, 3]);
1931
1929
  tf4d = tf__namespace.cast(tf4d_, 'int32');
1932
- return [4 /*yield*/, documentDetectionModel.executeAsync(tf4d)
1933
- // interrogate the model to determine the output positions
1934
- ];
1935
- case 4:
1936
- _a.sent();
1930
+ _b = (_a = tf__namespace).dispose;
1931
+ return [4 /*yield*/, documentDetectionModel.executeAsync(tf4d)];
1932
+ case 3:
1933
+ _b.apply(_a, [_c.sent()]);
1934
+ tfInt32.dispose();
1935
+ tf4d.dispose();
1936
+ tf4d_.dispose();
1937
+ tf__namespace.dispose(zeroes);
1937
1938
  outputKeys = documentDetectionModel.outputs.map(function (o) {
1938
1939
  return o.name;
1939
1940
  });
@@ -1942,11 +1943,6 @@ function loadDocumentDetectionModel(url) {
1942
1943
  scores: outputKeys.indexOf('Identity_4'),
1943
1944
  labels: outputKeys.indexOf('Identity_2')
1944
1945
  };
1945
- return [3 /*break*/, 6];
1946
- case 5:
1947
- tf__namespace.engine().endScope();
1948
- return [7 /*endfinally*/];
1949
- case 6:
1950
1946
  return [2 /*return*/, documentDetectionModel];
1951
1947
  }
1952
1948
  });
@@ -1989,31 +1985,30 @@ function loadFocusModel(url) {
1989
1985
  return [4 /*yield*/, tf__namespace.loadLayersModel(url)];
1990
1986
  case 1:
1991
1987
  focusModel = _e.sent();
1992
- return [4 /*yield*/, tf__namespace.ready()];
1988
+ return [4 /*yield*/, tf__namespace.ready()
1989
+ // warm the model by predicting on an empty image...
1990
+ ];
1993
1991
  case 2:
1994
1992
  _e.sent();
1995
- _e.label = 3;
1996
- case 3:
1997
- _e.trys.push([3,, 6, 7]);
1998
- tf__namespace.engine().startScope();
1999
1993
  zeroes = tf__namespace.zeros([448, 448, 3]);
2000
1994
  tfInt32 = tf__namespace.cast(zeroes, 'float32');
2001
1995
  _b = (_a = tf__namespace).tensor4d;
2002
1996
  _d = (_c = Array).from;
2003
1997
  return [4 /*yield*/, tfInt32.data()];
2004
- case 4:
1998
+ case 3:
2005
1999
  tf4d_ = _b.apply(_a, [_d.apply(_c, [_e.sent()]), [1, 448, 448, 3]]);
2006
2000
  tf4d = tf__namespace.cast(tf4d_, 'float32');
2007
- warmupResult = focusModel.predict(tf4d);
2001
+ return [4 /*yield*/, focusModel.predict(tf4d)];
2002
+ case 4:
2003
+ warmupResult = _e.sent();
2008
2004
  return [4 /*yield*/, warmupResult.data()];
2009
2005
  case 5:
2010
2006
  _e.sent();
2011
2007
  tf__namespace.dispose(warmupResult);
2012
- return [3 /*break*/, 7];
2013
- case 6:
2014
- tf__namespace.engine().endScope();
2015
- return [7 /*endfinally*/];
2016
- case 7:
2008
+ tfInt32.dispose();
2009
+ tf4d.dispose();
2010
+ tf4d_.dispose();
2011
+ tf__namespace.dispose(zeroes);
2017
2012
  return [2 /*return*/, focusModel];
2018
2013
  }
2019
2014
  });