patlevin / tfjs-to-tf

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

convert bodypix js model to pb #4

Closed DCC-lzhy closed 4 years ago

DCC-lzhy commented 4 years ago

when I followed the answer on (https://stackoverflow.com/questions/58841355/bodypix-real-time-person-segmentation?answertab=active#tab-top), I have the problem: Converting.... buffer is smaller than requested size I can't find any information about it from source code.

patlevin commented 4 years ago

Make sure that the files you downloaded are ok: the weight files (group1-shardXXof23.bin) have to have the same size (4096kB each), except for the last one (group1.shard23of23.bin), which might be smaller. The problem usually occurs, because the downloaded files are compressed. Either download the shard files via a browser or tell your download command to decompress the downloaded files, e.g.

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

Does this solve your problem?

DCC-lzhy commented 4 years ago

Make sure that the files you downloaded are ok: the weight files (group1-shardXXof23.bin) have to have the same size (4096kB each), except for the last one (group1.shard23of23.bin), which might be smaller. The problem usually occurs, because the downloaded files are compressed. Either download the shard files via a browser or tell your download command to decompress the downloaded files, e.g.

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

Does this solve your problem?

Yes, it works. I have another question, I download the json file which name is model-stride16.json, but it doesn't work.Converting.... Model not found: model\model.json. So, I change the file name to be model.json, it works. Is that right?

patlevin commented 4 years ago

@DCC-lzhy

So, I change the file name to be model.json, it works. Is that right?

Yes, the converter expects this name. I might change this later so you can provide any model file name, but for now the name has to be model.json.

HHMedic commented 3 years ago

@patlevin Hi. I have done steps as @DCC-lzhy done. then I got the model.pb.

then. process the following:

tflite_convert --output_file /Users/chengyanfang/Desktop/model/model.tflite --graph_def_file /Users/chengyanfang/Desktop/model/saved_model.pb --saved_model_dir /Users/chengyanfang/Desktop/model

I got error: RuntimeError: MetaGraphDef associated with tags {'serve'} could not be found in SavedModel. To inspect available tag-sets in the SavedModel, please use the SavedModel CLI: saved_model_cli

then. process the following:

The given SavedModel contains the following tag-sets: ''

how can i fix

patlevin commented 3 years ago

@HHMedic sorry for the late reply - it's better to open a new issue as I don't look into closed issues so I didn't see your message.

Can you please provide a link to the model you're trying to convert? An empty tag set is usually due to a missing signature in the model. This is very unusual.