From a5977e3f45ce8333b7b39540a6d4023f894b3103 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Mon, 20 Sep 2021 22:06:49 -0400 Subject: [PATCH] automated browser tests --- CHANGELOG.md | 7 ++++++- src/env.ts | 2 +- src/image/image.ts | 6 +++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6d3a256..fd65f61c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,13 @@ ## Changelog -### **HEAD -> main** 2021/09/19 mandic00@live.com +### **HEAD -> main** 2021/09/20 mandic00@live.com +- initial automated browser tests + +### **origin/main** 2021/09/20 mandic00@live.com + +- more automated tests - added configuration validation - prevent validation failed on some model combinations - webgl exception handling diff --git a/src/env.ts b/src/env.ts index effb677f..3b387caa 100644 --- a/src/env.ts +++ b/src/env.ts @@ -132,7 +132,7 @@ export async function get() { env.tfjs.version = tf.version_core; // offscreencanvas supported? - env.offscreen = typeof env.offscreen === 'undefined' ? typeof OffscreenCanvas !== undefined : env.offscreen; + env.offscreen = typeof env.offscreen === 'undefined' ? typeof OffscreenCanvas !== 'undefined' : env.offscreen; // get platform and agent if (typeof navigator !== 'undefined') { const raw = navigator.userAgent.match(/\(([^()]+)\)/g); diff --git a/src/image/image.ts b/src/image/image.ts index 9c0b9fa0..8478e192 100644 --- a/src/image/image.ts +++ b/src/image/image.ts @@ -63,9 +63,9 @@ export function process(input: Input, config: Config): { tensor: Tensor | null, } if (input instanceof tf.Tensor) { // if input is tensor, use as-is - if (input.isDisposed) throw new Error('input tensor is disposed'); - if ((input as unknown as Tensor).shape && (input as unknown as Tensor).shape.length === 4 && (input as unknown as Tensor).shape[0] === 1 && (input as unknown as Tensor).shape[3] === 3) tensor = tf.clone(input); - else throw new Error(`input tensor shape must be [1, height, width, 3] and instead was ${(input as unknown as Tensor).shape}`); + if ((input as Tensor)['isDisposedInternal']) throw new Error('input tensor is disposed'); + if ((input as Tensor).shape && (input as Tensor).shape.length === 4 && (input as unknown as Tensor).shape[0] === 1 && (input as unknown as Tensor).shape[3] === 3) tensor = tf.clone(input); + else throw new Error(`input tensor shape must be [1, height, width, 3] and instead was ${(input as Tensor).shape}`); } else { // check if resizing will be needed if (typeof input['readyState'] !== 'undefined' && input['readyState'] <= 2) {