automated browser tests

pull/356/head
Vladimir Mandic 2021-09-20 22:06:49 -04:00
parent ded141a161
commit a5977e3f45
3 changed files with 10 additions and 5 deletions

View File

@ -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

View File

@ -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);

View File

@ -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) {