patlevin / tfjs-to-tf

A TensorFlow.js Graph Model Converter
MIT License
139 stars 18 forks source link

Depth error while converting graph model to frozen #42

Closed dasmehdix closed 1 year ago

dasmehdix commented 2 years ago

Hi. I am trying to convert a TFJS Graph model to TF Frozen model. Inside TFJS Graph model(model.json) there is not a weightsManifestattribute. There is weightSpecsattribute instead of weightsManifest. So, I converted weigthSpecsto weightsManifestand add a path attribute inside weightsManifest as shown in below image. converting

After, I have tried to convert TFJS Graph model to frozen model but I get this error.

TensorFlow.js Graph Model Converter

Graph model:    model2.json
Output:         converted.pb
Target format:  tf_frozen_model

Converting.... Error: Depth of input (1633707611) is not a multiple of input depth of filter (3) for '{{node model/conv2d/Conv2D}} = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], explicit_paddings=[], padding="VALID", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true, _device="/device:CPU:0"](model/zero_padding2d/Pad, Const_114:0)' with input shapes: [1751275624,1818515716,1819108088,1633707611], [3,3,3,24].

As I understand model is corrupted, how can I convert this model to frozen?

patlevin commented 2 years ago

As I understand model is corrupted, how can I convert this model to frozen?

I don't know that the model is broken. There is a way in TFJS to save a model to local storage (i.e. in the browser's DB) that uses the weightSpec field instead of weightManifest. That's because the browser's local storage doesn't have file paths, whereas weight manifest does.

You can try and load the model using TFJS in the browser and see whether that works first. To be of any further help I would need to take a look at the model.json.