Deploying the Docker Image

The simplest way to deploy a cloud service using the Loomie SDK is via our Docker image. The image can be run as follows:

docker run -ti \
-p 5000:5000 \
-e LOOMAI_LICENSE=$(cat your-license-file) \
loomai/loomie:latest \
bash

We've bundled our container with a small sample REST server app, which we can run like this:

python3 /usr/local/share/loomai/examples/python/loomie-rest.py

And that's it! Congratulations, you're running a service using the Loomie SDK. Breaking it down:

  • 'loomai/loomie:latest' is our Docker image. You will need your Docker Hub account to be authorized in order to access it. (For a stable deployment you'll naturally use a fixed version in place of 'latest'.)

  • '-e LOOMAI_LICENSE=...' makes your license token avilable in the container's environment. The Loomie API will need this string passed in to it before the API can be used. The example app we're running here looks for the token in this environment variable then passes it to the API. Your application can follow the same pattern, or you can store your license in a file that your application reads, or whatever approach works best.

  • The rest is specific to this example app: opening the port it needs, and running the app itself.

Let's try it out! This simple app provides two endpoints. The first:

curl http://localhost:5000/stickers/5 \
-X get \
-F "image=@path/to/image.jpg" \
-o test.zip

...will take the given image, create a Loomie, and return a ZIP archive containing sticker pack images for that Loomie. It will also create some number (in this case 5) of randomized varitions on the solved Loomie, and include sticker pack images for those variations in the archive as well.

As an example, let's use this photo as input:

The solved Loomie we get back will look something like this in the neutral pose:

If we ask for randomized variations, and sample a few of the poses returned, we might get sticker images that look something like these:

The second endpoint:

curl http://localhost:5000/gltf/5 \
-X get \
-F "image=@path/to/image.jpg" \
-o test.zip

...is similar to the first, but instead of sticker pack images, returns an archive of binary GLTF files representing the solved Loomie and random variations.

Of course, our image can also be used as a base image for your own applications written for the Loomie SDK: just use our image in the FROM command in your Dockerfile, then add your software and whatever else you need in your image.

Next we'll walk through the source of the example app and break down how it uses the Loomie API.