patlevin / tfjs-to-tf

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

Posenet_res50 to tensorflow Converting Error #10

Closed mandoo92 closed 4 years ago

mandoo92 commented 4 years ago

Hello~

I am trying to convert from a tensorflow graph model to a Tensorflow model. The model is Posenet_resnet50 as follows.

Model Json : https://storage.googleapis.com/tfjs-models/savedmodel/posenet/resnet50/float/model-stride32.json Model Weight : https://storage.googleapis.com/tfjs-models/savedmodel/posenet/resnet50/float/group1-shard[1-23]of23.bin

I used the following code:

import tfjs_graph_converter.api as tfjs tfjs.graph_model_to_frozen_graph("/google_posenet_resnet50_float/", "/out")

Then the following error occurred.

ValueError: Paddings must be non-negative for 'resnet_v1_50/Pad' (op: 'Pad') with input shapes: [1,?,?,3], [4,2] and with computed input tensors: input[1] = <[-1123626725 -1119932221][-1136420229 1010317122][1016908063 -1138584835][1023272709 -1128308161]>.

I thought about it. There seems to be no weight corresponding to "resnet_v1_50 / Pad".

So I forcibly added the "resnet_v1_50 / Pad" random weight value (positive number[4,2]), but similarly an error occurs.

Check Please.....

patlevin commented 4 years ago

I was unable to reproduce the issue and the model converted just fine for me.

Judging from your sample output, though, my suspicion is that the weight files you downloaded are broken.

Could you please confirm the following:

  1. you use the latest converter version (i.e. the PyPi-version)
  2. all weight files except for group1-shard23of23.bin are exactly 4096kb in size

In case the weight files differ in size, make sure the files are decompressed. using curl this can be forced by using

curl -O --decompress https://storage.googleapis.com/tfjs-models/savedmodel/posenet/resnet50/float/group1-shard[1-23]of23.bin

to download the weights.

Let me know if that fixed the issue.

mandoo92 commented 4 years ago

I had downloaded the model file to a web browser.

but,,, I downloaded it again using curl and confirmed that it worked without any problems.

Thank you so much.

Thank you for kindly explaining and watching me until it is resolved.

Sadam1195 commented 4 years ago

@mandoo92 Do you have the tf model file for posenet_resnet50. I am getting errors and don't know how to use above mentioned files to convert it to tf model. @patlevin

mandoo92 commented 4 years ago

I received the model as a web browser and... try to convert it. I checked that each size of the model is 4096kb (but,,,, the last model is small) Then the above error occurred. (like ValueError)

but, Downloading and converting the model using @patlevin method (curl command) worked without any problems.

All I did was download the model in Curl.

Sadam1195 commented 4 years ago

I received the model as a web browser and... try to convert it. I checked that each size of the model is 4096kb (but,,,, the last model is small) Then the above error occurred. (like ValueError)

but, Downloading and converting the model using @patlevin method (curl command) worked without any problems.

All I did was download the model in Curl.

I did the same but it gave me class name error. Can you share model file?

mandoo92 commented 4 years ago

Ok! Here is the model file downloaded with my curl. http://gofile.me/4tDK3/dKchRNhI9 And it's a converted file. http://gofile.me/4tDK3/istgmOiL3

The conversion instruction is as follows....... $ pip install tfjs_graph_converter $ ls model/ tfjs-to-tf/ $ tfjs_graph_converter model/ posenet_res50.pb TensorFlow.js Graph Model Converter

Graph model: model/ Output: posenet_res50.pb Target format: tf_frozen_model

Converting.... Done. Conversion took 2.020s $ ls posenet_res50.pb* model/ tfjs-to-tf/

Sadam1195 commented 4 years ago

Thank you. Do you know how to convert posenet_res50 to tflite? @mandoo92