简体   繁体   中英

How can I convert Tensorflow model to tensorflow.js model?

I trained a custom model using this tutorial: https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10

As output, I get checkpoint files, like model.ckpt-41288.data-00000-of-00001 or.data or.meta.

I can export it as a frozen graph, but Tensorflow.js does not support conversion of a frozen graph anymore. I tried using the legacy version but was unable to convert.

I have looked at Tensorflow's documentation and I found it to be confusing.

Can someone give me a simple solution for how to convert a trained Tensorflow model to tensorflow.js?

Do you get a directory with the name saved_model which contains after running export_inference_graph.py (as mentioned here )? Inside the directory it's the model in SavedModel format.

Using the latest tensorflowjs version (v2.0 and above) you should be able to convert the model from SavedModel format to tfjs format. The output files should be group1-shardxofx.bin files and a model.json file.

tensorflowjs_converter --input_format=tf_saved_model --output_node_names='detection_boxes,detection_classes,detection_features,detection_multiclass_scores,detection_scores,num_detections,raw_detection_boxes,raw_detection_scores' --saved_model_tags=serve --output_format=tfjs_graph_model path_to_your_exported_inference_model_dir/saved_model path_to_save_your_tfjs_model

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM