PyTorch

PyTorch models can be uploaded to BioLib via the Open Neural Network Exchange format (.onnx). To obtain a .onnx file from your PyTorch model, use the torch.onnx.export API:

import torch

dummy_input = [1,2,3]
model = torch.load("path_to_saved_model")
torch.onnx.export(model, dummy_input, "./model.onnx")

The API requires three variables: model: an instance of a pretrained model. dummy_input: an input tensor to construct the network graph. And a path ("./model.onnx") to specify where the .onnx file should be stored. Any PyTorch model can be saved and loaded using the torch.save() and torch.load() APIs.

After creating a .onnx file you can upload it to your application using the PyTorch template: Create Application