Tfjs: loadFrozenModel, Cannot read property 'io' of undefined

Created on 12 May 2018  路  13Comments  路  Source: tensorflow/tfjs

TensorFlow.js version

0.10.3

Browser version

Chrome 66

Describe the problem or feature request

I'm having problems loading a frozen model from mobilenet and tfjs convert. I get an error TypeError: Cannot read property 'io' of undefined.

Code to reproduce the bug / link to feature request

<!doctype html>
<html lang="en">
<head>
  <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"> </script>
  <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-converter"></script>
</head>
<body>
  <img style="display: none" id="cat" src="high-detail.jpg" width="224" height="224">

  <script>
    const MODEL_URL = 'https://storage-direct.y8.com/eddie/html5/canvas-friends/detail_js/tensorflowjs_model.pb';
    const WEIGHTS_URL = 'https://storage-direct.y8.com/eddie/html5/canvas-friends/detail_js/weights_manifest.json';

    async function loadModal() {
      const model = await tf_converter.loadFrozenModel(MODEL_URL, WEIGHTS_URL);
    }
    loadModal()
    //const cat = document.getElementById('cat');
    //model.execute({input: tf.fromPixels(cat)});
  </script>
</body>
</html>
core bug

All 13 comments

Having the exact same issue with the Mobilenet demo.

I'm pretty sure this is due to a package versioning problem. The current tfjs-converter release depends on tfjs-core 0.10.0, but the tfjs union package release (0.10.3) provides only tfjs-core 0.8.3.

The tf.io package was introduced in tfjs-core between those two versions, and tfjs-converter requires it (due to https://github.com/tensorflow/tfjs-converter/pull/99).

So I think the solution will be for us to release a new tfjs union package asap. And in the future, we'll need to make sure we always do that whenever there is a tfjs-converter release that requires it.

Working on a fix right now, but if you use an older version of the converter you won't have the issue:

<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]"></script>

or if you are only using converter you can replace the union package with

I'm also seeing this, but can't use an old version of tfjs-converter because I want to load a model that was converted by the most recent tfjs-converter. If I use the older version I get:

[email protected]:1 Uncaught (in promise) Error: Tensorflow Op is not supported: StridedSlice
    at e.mapNode ([email protected]:1)
    at [email protected]:1
    at Array.reduce (<anonymous>)
    at e.transformGraph ([email protected]:1)
    at e.<anonymous> ([email protected]:1)
    at n ([email protected]:1)
    at Object.next ([email protected]:1)
    at i ([email protected]:1)

It looks like the error is happening on this line:

return [4, tfc.io.loadWeights(this.weightManifest, this.pathPrefix, undefined, this.requestOption)];

If I inspect tf.io in the debugging console, it is defined (I'm using the latest build from GitHub of tfjs-core). But if I add this line above:

console.log('Trying to use tfc: ' + tfc);

I see: tf-converter.js:7406 Trying to use tfc: undefined

tfc is defined a few lines above:

var tfc = (typeof window !== "undefined" ? window['tfc'] : typeof global !== "undefined" ? global['tfc'] : null);

And indeed, window['tfc'] and global are undefined. From poking around the code it looks like window['tfc'] should probably be window['tf'].

So I crossed my fingers and replaced all instances of 'tfc' with 'tf' in tf-converter.min.js and it looks like it works?

Ah, I wish Google groups would show in Google search. 馃槥 0.2.0 is no good. Error: Tensor is disposed.

Yes, sorry for the trouble. Newer tfjs-converters should not have this problem. All new problems now ;)

Should I still wait or what is the solution? :)

<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]"> </script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]"></script>

No luck with the above code

@EddieOne Sorry for closing the issue prematurely. Please wait for some additional changes that need to go into tfjs-converter.

Ok I thought so. Sorry, I've been waiting since Tensor Fire. I'm pretty sure tfjs will be very important in the near future, so good to see a lot of interest now.

Apologies for the delay, once we release this will be fixed. I have a pending PR which we need to get in before releasing: https://github.com/tensorflow/tfjs-converter/pull/136

I hosted a temporary version of the tf-converter for you until we release a new version of the converter (which will happen on Monday). This link will not be around forever, but if you really want to use it today you can use this:

<script src="https://storage.googleapis.com/dljs-test/rollup/tf-converter.js"></script>

The difference here is there is no more "tf_converter", only "tf". You call "tf.loadFrozenModel" like you would any other tf op.

It works! Thank you brother. The first time you see TensorFlow in JS for yourself, it's magical.

Remember, don't rely on this link ;) We'll have a release tomorrow!

Was this page helpful?
0 / 5 - 0 ratings