Installation
Let’s start by installing it withpip:
Installing via pip
While the Python SDK doesn’t currently require PyTorch 2.0
(
torch > 2.0.0),
some of our future SDK features will require it as we’ll start using many of
the new PyTorch 2.0 APIs / IRs such as .compile().Add Cellulose decorator to your nn.Module
Let’s create a new Python script that contains a simplenn.Module that we
eventually want to export and upload to the dashboard.
First, let’s import everything we’ll need in the later steps:
Cellulose imports
Cellulose decorator and come back to CelluloseContext
in a later section.
Decorate the SuperResolutionNet module with the Cellulose decorator, then
provide the input_names and output_names arguments:
torch_model,
call load_state_dict and set it to eval mode:
Initialization and export
Create an input tensor
Model input
Instantiate a CelluloseContext
Now let’s create aCelluloseContext and pass in a personal API key. You can
read more on how to create / retrieve your API keys
here.
Export and upload the model to the dashboard
We just provide thetorch_model module and the input tensor to
CelluloseContext’s export() method like below:


Uploaded PyTorch model in the model list

Graph of uploaded PyTorch model

Generate the Cellulose artifact with all exported model assets
The SDK also has aflush method that conveniently packs all the generated
ONNX outputs in a zip file.
Generate and save all export artifacts
generated_artifacts.cellulose.zip folder
in the “current” directory.
Here are the contents once it is unzipped:

The TOML metadata file is autogenerated and shouldn’t be directly modified. This
is mostly useful to us for debugging and diagnostics purposes so we can help you
resolve issues quickly if you run into them.

