Reputation: 191
I've been able to run the tensorflow convertor in my terminal but I'm not sure how to change the example below provided by TensorFlow to find my saved_model.pb path on the computer and save it as a Javascript file:
tensorflowjs_converter \
--input_format=tf_saved_model \
--output_format=tfjs_graph_model \
--signature_name=serving_default \
--saved_model_tags=serve \
/mobilenet/saved_model \
/mobilenet/web_model
Here is my input on the terminal causing the error:
tensorflowjs_converter \
--input_format=tf_saved_model \
--output_format=tfjs_graph_model \
--signature_name=serving_default \
--saved_model_tags=serve \
/Users/name/Desktop/name\ name\ TensorFlow/saved_model \
/Users/name/Desktop/name\ name\ TensorFlow/web_model
usage: TensorFlow.js model converters. [-h]
[--input_format {tf_frozen_model,keras_saved_model,tfjs_layers_model,tf_hub,tf_saved_model,keras}]
[--output_format {tfjs_layers_model,keras_saved_model,tfjs_graph_model,keras}]
[--signature_name SIGNATURE_NAME]
[--saved_model_tags SAVED_MODEL_TAGS]
[--quantize_float16 [QUANTIZE_FLOAT16]]
[--quantize_uint8 [QUANTIZE_UINT8]]
[--quantize_uint16 [QUANTIZE_UINT16]]
[--quantization_bytes {1,2}]
[--split_weights_by_layer] [--version]
[--skip_op_check]
[--strip_debug_ops STRIP_DEBUG_OPS]
[--weight_shard_size_bytes WEIGHT_SHARD_SIZE_BYTES]
[--output_node_names OUTPUT_NODE_NAMES]
[--control_flow_v2 CONTROL_FLOW_V2]
[--experiments EXPERIMENTS]
[input_path] [output_path]
TensorFlow.js model converters.: error: unrecognized arguments: TensorFlow/saved_model /Users/ned/Desktop/name name TensorFlow/web_model
And when I try the Tensorflow convertor it says the original path was wrong:
Welcome to TensorFlow.js Converter.
? Please provide the path of model file or the directory that contains model fil
If you are converting TFHub module please provide the URL. /Users/name/Desktop/name\ name\ TensorFlow/saved_model.pb
? What is your input model format? (model format cannot be detected.) Tensorfl
? The original path seems to be wrong, what is the directory that contains the m
odel?
Upvotes: 1
Views: 2074
Reputation: 191
I find it easier myself to write the convertor in Python, move the script to the same folder as the directory, and then run it there. Like so:
from tensorflow import keras
import tensorflowjs as tfjs
def importModel(modelPath):
model = keras.models.load_model(modelPath)
tfjs.converters.save_keras_model(model, "tfjsmodel")
importModel("modelDirectory")
This way you only have to write the model's directory name in a relative pathname.
Upvotes: 2
Reputation: 191
It only allowed access to folders under home so it would just be:
/Users/ned/Tensorflow
When trying to find the path using Tensorflow Convertor.
Upvotes: 0