Tfjs: Not able to run model on HTMLImageElement

Created on 14 Feb 2019  路  4Comments  路  Source: tensorflow/tfjs

TensorFlow.js version

0.15.1

Browser version

Chrome 71.0.3578.98

Describe the problem or feature request

when I try to run model.detect on a remote image. It says,

Could not write to TensorArray index 0,
          because the value dtype is int32, but TensorArray dtype is float32.

However, if I serve the image from a localhost server, it works.

Code to reproduce the bug / link to feature request

async function init(){
      const model = await cocoSsd.load('mobilenet_v2');
      let img1 = new Image()
      // to bypass cross origin issue
      img1.src = `https://i.imgur.com/xFWR5e4.jpg?${Date.now()}`
      img1.crossOrigin = ""
      img1.onload = async function(){
        img1 = tf.image.resizeBilinear(tf.fromPixels(img1), [400, 400]);
                const result = await model.detect(img1);
      }
}

https://jsfiddle.net/rszv6a70/28/

models bug

Most helpful comment

I can confirm that I can reproduce the bug and it seems to be a regression between 0.14.1 and 0.14.2

@ritikrishu You can change the script tag that loads tfjs in your program to <script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"> as a workaround in the meantime.

cc @pyu10055

All 4 comments

Also does not works with local file system images, unless I serve them via localhost as well.

I can confirm that I can reproduce the bug and it seems to be a regression between 0.14.1 and 0.14.2

@ritikrishu You can change the script tag that loads tfjs in your program to <script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"> as a workaround in the meantime.

cc @pyu10055

@tafsiri thanks, bro! you saved my day 鉂わ笍

This is fixed in https://github.com/tensorflow/tfjs-core/pull/1577 as part of 1.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

weiji14 picture weiji14  路  3Comments

Josef-Haupt picture Josef-Haupt  路  3Comments

RELNO picture RELNO  路  3Comments

pranayaryal picture pranayaryal  路  4Comments

dhrumil83 picture dhrumil83  路  3Comments