UFF Converter
The uff
package contains a set of utilites to convert trained models from various frameworks to a common format.
Conversion Tools
Tensorflow Modelstream to UFF
- uff.from_tensorflow(graphdef, output_nodes=[], preprocessor=None, **kwargs)
Converts a TensorFlow GraphDef to a UFF model.
- Parameters
graphdef (tensorflow.GraphDef) – The TensorFlow graph to convert.
output_nodes (list(str)) – The names of the outputs of the graph. If not provided, graphsurgeon is used to automatically deduce output nodes.
output_filename (str) – The UFF file to write.
preprocessor (str) – The path to a preprocessing script that will be executed before the converter. This script should define a
preprocess
function which accepts a graphsurgeon DynamicGraph and modifies it in place.write_preprocessed (bool) – If set to True, the converter will write out the preprocessed graph as well as a TensorBoard visualization. Must be used in conjunction with output_filename.
text (bool) – If set to True, the converter will also write out a human readable UFF file. Must be used in conjunction with output_filename.
quiet (bool) – If set to True, suppresses informational messages. Errors may still be printed.
debug_mode (bool) – If set to True, the converter prints verbose debug messages.
return_graph_info (bool) – If set to True, this function returns the graph input and output nodes in addition to the serialized UFF graph.
- Returns
serialized UFF MetaGraph (str)
OR, if return_graph_info is set to True,
serialized UFF MetaGraph (str), graph inputs (list(tensorflow.NodeDef)), graph outputs (list(tensorflow.NodeDef))
Tensorflow Frozen Protobuf Model to UFF
- uff.from_tensorflow_frozen_model(frozen_file, output_nodes=[], preprocessor=None, **kwargs)
Converts a TensorFlow frozen graph to a UFF model.
- Parameters
frozen_file (str) – The path to the frozen TensorFlow graph to convert.
output_nodes (list(str)) – The names of the outputs of the graph. If not provided, graphsurgeon is used to automatically deduce output nodes.
output_filename (str) – The UFF file to write.
preprocessor (str) – The path to a preprocessing script that will be executed before the converter. This script should define a
preprocess
function which accepts a graphsurgeon DynamicGraph and modifies it in place.write_preprocessed (bool) – If set to True, the converter will write out the preprocessed graph as well as a TensorBoard visualization. Must be used in conjunction with output_filename.
text (bool) – If set to True, the converter will also write out a human readable UFF file. Must be used in conjunction with output_filename.
quiet (bool) – If set to True, suppresses informational messages. Errors may still be printed.
debug_mode (bool) – If set to True, the converter prints verbose debug messages.
return_graph_info (bool) – If set to True, this function returns the graph input and output nodes in addition to the serialized UFF graph.
- Returns
serialized UFF MetaGraph (str)
OR, if return_graph_info is set to True,
serialized UFF MetaGraph (str), graph inputs (list(tensorflow.NodeDef)), graph outputs (list(tensorflow.NodeDef))