Learn how to import models into Tensorleap
Tensorleap supports importing models exported to various standard formats, including standard TensorFlow (SaveModel/H5/JSON) and PyTorch (ONNX).
The JSON format serializes the model layers, their properties and connectivity. It does not hold the state (weights) of the model.
Below is a code snippet for saving a TensorFlow model as a JSON file:
json_file = open("model.json", "w")
h5format serializes the model and model state (weights) as a single
Below is a code snippet for loading an exported
onnxformat is commonly used in PyTorch for serializing the model's layers and state (weights).
Below is a code snippet for exporting a model to an
onnxfile in PyTorch:
dummy_input = torch.randn(10, 3, 224, 224, device="cuda")
model = torchvision.models.alexnet(pretrained=True).cuda()
input_names = [ "actual_input_1" ] + [ "learned_%d" % i for i in range(16) ]
output_names = [ "output1" ]
torch.onnx.export(model, dummy_input, "alexnet.onnx", verbose=True, input_names=input_names, output_names=output_names)
Uses the TensorFlow 2
SaveModelto export a folder with files containing the serialized model layers and state.
Below is a code snippet to load the model from the extracted folder:
The serialized data is stored to a folder with this directory structure:
When importing the folder generated by the
model.save()format from Tensorleap, the exported folder needs to be contained in a
One way to do it is by using
tar -zcvf model_folder.tar.gz model_folder
To import a model:
- 1.On the Network view, clickto open the Import Model panel.
- 2.Enter the revision name and model name, and select the import file format from the list.
- 3.Click and select the import file from your system.
5. Click Import.
Setting up the import
7. Position your cursor over the version and click
, then Open Commit.
Importing a model and pointing its Dataset Block to a dataset instance