Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load InceptionV3 model (npm [email protected], [email protected], [email protected], [email protected]) #117

Open
rychuelektryk opened this issue Mar 11, 2018 · 3 comments

Comments

@rychuelektryk
Copy link

Hi,

When I try to load inceptionV3 model in keras-js I get following error:

Error: cwise: Arrays do not all have the same shape!
at assign_cwise_thunk (eval at createThunk (backgroundscript.js:113190), <anonymous>:8:71)
at Object.assign_ndarrayops [as assign] (eval at makeOp (backgroundscript.js:2705), <anonymous>:3:43)
at Conv2D._padInput (backgroundscript.js:31435)
at Conv2D._callCPU (backgroundscript.js:31502)
at Conv2D.call (backgroundscript.js:31393)
at Model._traverseDAG (backgroundscript.js:102501)
at Model._traverseDAG (backgroundscript.js:102515)
at <anonymous>

The model is prepared in a following manner:

1: The model is loaded and then exported in keras using following code:

keras.applications import InceptionV3
inceptionModel = InceptionV3(weights="imagenet", include_top=False)
model.save(myPath)

2: The model is than encoded using latest(see the commit below) keras-js encoder.py

commit df999159284abc5de0b92bc0f801375c08bf9008 (HEAD -> master, origin/master, origin/HEAD)
Author: Leon Chen <[email protected]>
Date:   Fri Feb 9 10:15:28 2018 -0500
update demos build

The aforementioned error is generated when the model is loaded by keras-js using following code:

var KerasJS = require('keras-js');
let model = new KerasJS.Model({
    filepath: modelPath,
    gpu: false
})

What I find peculiar is that the inceptionv3 model loaded in keras-js example differs than the one that I generate.

small part of configuration part of model generated by me:

$b7dfac6a-dd00-4849-bb31-769a6397f93d��model��2.1.2"
tensorflow*˙ö�{"class_name": "Model", "config": {"layers": [{"class_name": "InputLayer", "config": {"sparse": false, "dtype": "float32", "batch_input_shape": [null, null, null, 3], "name": "input_1"}

full model configuration here -> https://www.dropbox.com/s/o42oc243huqqlbk/myModel.txt?dl=0

small part of configuration part of model used in example:

$7db1fe5f-c96e-4804-b1bc-f399146eaa0c�inception_v3��2.0.9"
tensorflow*ýö�{"class_name": "Model", "config": {"name": "inception_v3", "layers": [{"name": "input_1", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 299, 299, 3], "dtype": "float32", "sparse": false, "name": "input_1"}

full model configuration here -> https://www.dropbox.com/s/7ld1pmbjsj5g8fo/exampleModel.txt?dl=0

Issue happens in following environment
npm [email protected], [email protected], [email protected], [email protected]

I've spent whole day on this issue and couldnt find the solution. Any help would by greatly appreciated.

@MingwangLin
Copy link

Maybe you should specify your model input to be (None, 299, 299, 3).

@seranus
Copy link

seranus commented Mar 13, 2018

KerasJS doesn't support None, internally model with shape lets say (None, 299, 299, 3) would be represented as (299, 299, 3) or model with shape (None, None, None, 3) would be just (3)

@rychuelektryk
Copy link
Author

Thanks,

Loading model in a following way did the trick:

inceptionModel = InceptionV3(weights="imagenet", include_top=False, input_shape=(299, 299, 3))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants