Retrain image detection with MobileNet

后端 未结 4 1142
执念已碎
执念已碎 2020-12-06 12:01

Several ways of retraining MobileNet for use with Tensorflow.js have failed for me. Is there any way to use a retrained model with Tensorflow.js?

Both using the mode

4条回答
  •  有刺的猬
    2020-12-06 12:26

    The retrain.py python script does not generate a saved model, it actually generates a frozen graph model. That is why you cannot convert it using the tfjs 1.x converter. You need to use tfjs 0.8.5 pip to convert. Also, the output node name is different from the mobilenet model graph, it is 'final_result' for retrained graph.

    To convert it you need to use the tensorflowjs 0.8.5 pip:

    • use virtualenv to create an empty env.
    • pip install tensorflowjs==0.8.5
    • run the converter
    tensorflowjs_converter \
      --input_format=tf_frozen_model \
      --output_node_names='final_result' \
      --output_json=true /tmp/output_graph.pb \ /tmp/web_model
    

    This should give you something like the following:

    ls /tmp/web_model/
    group1-shard10of21  group1-shard14of21  group1-shard18of21  group1-shard21of21  group1-shard5of21  group1-shard9of21
    group1-shard11of21  group1-shard15of21  group1-shard19of21  group1-shard2of21   group1-shard6of21  model.json
    group1-shard12of21  group1-shard16of21  group1-shard1of21   group1-shard3of21   group1-shard7of21
    group1-shard13of21  group1-shard17of21  group1-shard20of21  group1-shard4of21   group1-shard8of21
    

提交回复
热议问题