tfjs-converter produces error at prediction time
See original GitHub issueTensorFlow.js Version: 0.3.1 TensorFlow Version: 1.7.0 Chrome 66.0.3359.181
I downloaded the smallest/fastest MobileNetV2 from here and used the tfjs-converter to convert the model.
I cloned the tfjs-converter repo and changed a few variables in the mobilenet example:
const GOOGLE_CLOUD_STORAGE_DIR =
'web_model/';
const MODEL_FILE_URL = 'tensorflowjs_model.pb';
const WEIGHT_MANIFEST_FILE_URL = 'weights_manifest.json';
const INPUT_NODE_NAME = 'input';
const OUTPUT_NODE_NAME = 'MobilenetV2/Predictions/Reshape_1';
I made these changes while running yarn mobilenet
, but it produces an error:
> yarn mobilenet
yarn run v1.6.0
$ NODE_ENV=development parcel --no-hmr --open mobilenet/index.html
Server running at http://localhost:1234
🚨 /Users/kyle/Documents/Learning/tfjs-converter/demo/mobilenet/index.js: Cannot read property '__esModule' of null
at Function.normalisePlugin (/Users/kyle/Documents/Learning/tfjs-converter/demo/node_modules/babel-core/lib/transformation/file/options/option-manager.js:142:21)
at /Users/kyle/Documents/Learning/tfjs-converter/demo/node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30
at Array.map (<anonymous>)
at Function.normalisePlugins (/Users/kyle/Documents/Learning/tfjs-converter/demo/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
🚨 /Users/kyle/Documents/Learning/tfjs-converter/demo/mobilenet/mobilenet.js: Cannot read property '__esModule' of null
at Function.normalisePlugin (/Users/kyle/Documents/Learning/tfjs-converter/demo/node_modules/babel-core/lib/transformation/file/options/option-manager.js:142:21)
at /Users/kyle/Documents/Learning/tfjs-converter/demo/node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30
at Array.map (<anonymous>)
🚨 /Users/kyle/Documents/Learning/tfjs-converter/demo/mobilenet/index.js: Cannot read property '__esModule' of null
at Function.normalisePlugin (/Users/kyle/Documents/Learning/tfjs-converter/demo/node_modules/babel-core/lib/transformation/file/options/option-manager.js:142:21)
at /Users/kyle/Documents/Learning/tfjs-converter/demo/node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30
at Array.map (<anonymous>)
🚨 /Users/kyle/Documents/Learning/tfjs-converter/demo/mobilenet/mobilenet.js: Cannot read property '__esModule' of null
at Function.normalisePlugin (/Users/kyle/Documents/Learning/tfjs-converter/demo/node_modules/babel-core/lib/transformation/file/options/option-manager.js:142:21)
at /Users/kyle/Documents/Learning/tfjs-converter/demo/node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30
at Array.map (<anonymous>)
at Function.normalisePlugins (/Users/kyle/Documents/Learning/tfjs-converter/demo/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
at OptionManager.mergeOptions (/Users/kyle/Documents/Learning/tfjs-converter/demo/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
at OptionManager.init (/Users/kyle/Documents/Learning/tfjs-converter/demo/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (/Users/kyle/Documents/Learning/tfjs-converter/demo/node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (/Users/kyle/Documents/Learning/tfjs-converter/demo/node_modules/babel-core/lib/transformation/file/index.js:135:24)
at JSAsset.getParserOptions (/Users/kyle/Documents/Learning/tfjs-converter/demo/node_modules/parcel-bundler/src/assets/JSAsset.js:69:20)
at <anonymous>
Unhandled promise rejection: TypeError: this.reject is not a function
at PromiseQueue._runJob (/Users/kyle/Documents/Learning/tfjs-converter/demo/node_modules/parcel-bundler/src/utils/PromiseQueue.js:50:12)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Could this be related to the fact that I installed the modules using npm install
instead of yarn
? I initially tried with yarn
but it was giving me this error:
> yarn
yarn install v1.6.0
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
warning There appears to be trouble with our server. Retrying...
error An unexpected error occurred: "http://registry.npmjs.org/@types/node/-/node-8.9.5.tgz: Request failed \"503 Service Unavailable\"".
info If you think this is a bug, please open a bug report with the information provided in "/Users/kyle/Documents/Learning/tfjs-converter/demo/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Anyway, I exited yarn mobilenet
, deleted dist
and ran yarn mobilenet
command again, and it successfully generated the new files in dist
. However, it didn’t copy the web_model
folder so I copied it manually. But it wouldn’t serve the folder, so I started an instance of http-server in the root directory and it successfully loaded the model.
Unfortunately, at prediction time it seems to fail:
Loading of model: 335.180908203125ms
es6.promise.js:110 Unhandled promise rejection Error: Can't squeeze axis 1 since its dim '6' is not 1
at Object.squeezeShape (util.js:225)
at Object.ArrayOps.squeeze (array_ops.js:378)
at Object.exports.executeOp (transformation_executor.js:14)
at executeOp (operation_executor.js:41)
at graph_executor.js:116
at Array.reduce (<anonymous>)
at graph_executor.js:115
at Tracking.tidy (tracking.js:34)
at GraphExecutor.execute (graph_executor.js:113)
at FrozenModel.execute (frozen_model.js:136)
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
@pyu10055 for serving local files i would suggest starting a local http server like http-serve (python based). parcel won’t really do that for you unless the asset is included in the bundle (in which case it may try to pre-load everything).
@kylemcdonald I tried tf-hub mobilenetv2 https://www.tensorflow.org/hub/modules/google/imagenet/mobilenet_v2_100_224/classification/1
using the converter
Initially I have the same issue as the squeeze failed, I notice it require strictly the input image size to be 224x224, after I resize the image the model works.
Also, you need to make sure the input and output matches to the model, in my case they are: