Update, April 2022: As of now, you will no longer be able to port new models to Runway or update existing models. Models which you have already ported will remain available for the foreseeable future.
For this short tutorial, we will be porting Progressive Growing of GANs (PGAN), an open-source model that creates high-quality images, available in the Pytorch Hub and GitHub. The code to run and generate an image with a pre-trained PGAN checkpoint from the Pytorch hub is short and simple, let’s review the base code we will be using:
Let’s start by creating a file called
runway_model.py, pasting our sample code from above and adding the
runway-python SDK. We will also add
numpy for some minor post-processing. (Be sure to install the Runway python SDK with
pip install runway-python first!)
The setup function is used to load the checkpoints and render any UI elements in Runway that will be part of the initial model configuration. In this case, just by defining a
runway.category and adding the default PGAN checkpoint as options we get this nice UI in Runway ✨:
Next, let’s wrap the inference part of the model in a Runway command function. A command is a special function that is used to define a way you can interact with a model. This will allow you to define input and output types.
A command decorator function is built with three options:
Defining a command that takes a vector as input creates a vector grid interface to navigate the latent space of PGAN and show the resulting image as the output.
Now, we are ready to add our model to Runway! Let’s create a
runway.yml file, next to our
runway_model.py defining how our model should run:
This file provides instructions for defining an environment, installing dependencies, and running your model in a standard and reproducible manner.
That’s it! Let’s create a GitHub repo and push our code to GitHub and get our model in Runway.
Runway can take any existing repository that contains a
runway.yml file and create a model that you can use and share in Runway.
Open Runway and click “From GitHub” in the lower-left corner of the models' directory, select your repository and follow the steps to add a model.
Once the model has been added, Runway will start the build process automatically. You can check the process on the versions tab. Every time you push a commit to GitHub, Runway creates a new version of your model. 🎩
Once the model has been built, you can add it to your workspace and start exploring! 🦄
If you want to learn more about how Runway works, check out the links below. We would love to get your feedback!