How I built OctoStudio powered by OctoAI
We launched the OctoAI Image Gen Solution this week, the fastest and most customizable GenAI stack for production-grade image generation applications. One application area where we’re already seeing lots of interest is e-commerce – specifically generating high quality product images — and I thought it would be fun to build a showcase of how OctoAI can power e-commerce use cases like product placement. In this blog, I’m going to walk you through how I built OctoStudio, a sample app that generates 100s or even 1000s of custom images of your product, in minutes.
![OctoStudio preview with Indian man wearing VR headset next to AI generated images of many Indian men wearing VR headsets with a Holi festival theme OctoStudio preview with Indian man wearing VR headset next to AI generated images of many Indian men wearing VR headsets with a Holi festival theme](/_next/image/?url=https%3A%2F%2Fwww.datocms-assets.com%2F45680%2F1699472488-octostudio-thumbnail-preview-blog.png&w=3840&q=75)
I took inspiration from AI-powered creative tooling for advertisers and retailers that came from Amazon and Google. These new tools help small businesses more easily connect with online shoppers by harnessing the power of Generative AI to customize product photography.
But I wanted to take the idea a notch further. What if instead of just simple background replacement, we had the opportunity to fully leverage the flexibility of GenAI models (e.g. SDXL, LLAMA) to place the product under highly custom situations? What if I display the product under different angles? What if I could have very fine control over the person who is wearing the item? Or over what’s displayed in the background of the photo shoot? And what if I could build this based on open models and technologies, with full control to change the models over time and no restrictive lock-in? That would be pretty cool.
The key objective behind this exercise was to create a blueprint for a modern, multimodal GenAI e-commerce app. One that delivers a high degree of customization towards a target demographic and time of the year / cultural event for which the product is being marketed. Out of a small collection of photographic assets, I can achieve asset amplification and specialization to a degree never delivered before. And all of this with production-grade speed, scalability and reliability out of the box.
We will use a number of generative AI capabilities under the covers, including the SDXL model, fine-tuning, and the Llama 2 large language model. But before we start — let me give you a sneak preview of a sample outcome:
![GenAI images of an Indian male wearing a VR headset during Holi festival GenAI images of an Indian male wearing a VR headset during Holi festival](/_next/image/?url=https%3A%2F%2Fwww.datocms-assets.com%2F45680%2F1699418387-octostudio-generated-images-adult-indian-male-during-holi-with-vr-headset.png&w=3840&q=75)
These are images of “my product” (the branded virtual reality headset) placed on a person in multiple background settings and taken at multiple angles, all powered by generative AI. Let me now walk you through the steps in building this application.
Customization - create your fine-tuning assets and add it to the asset library
The first step on this journey is to create your fine-tuning assets — the building blocks you use to customize your images.
Let’s start by looking at Stable Diffusion XL, the gold standard for text to image generation. Here I’m asking SDXL to generate an image of someone wearing a branded VR headset. As you can see, SDXL out of the box really struggles with this — that’s likely because that specific product wasn’t in its training set.
![text to image GenAI of people in apple vision headsets text to image GenAI of people in apple vision headsets](/_next/image/?url=https%3A%2F%2Fwww.datocms-assets.com%2F45680%2F1699418415-octoai-ui-showing-text-to-image-prompt-for-apple-vision.png&w=3840&q=75)
In order to teach the model how to generate images of our product, I can train a Low-Rank Adaptation (LoRA) of SDXL. LoRA was initially conceived for fine-tuning large language models, but has since been adopted in other areas like image generation. You can think of the LoRA as a minor software patch that you apply to your large model. With the OctoAI Image Gen Solution you’ll be able to create and apply your own LoRA fine-tunes by providing a small set of images featuring your product under different angles.
![OctoAI UI showing fine-tune training images of people in VR headsets OctoAI UI showing fine-tune training images of people in VR headsets](/_next/image/?url=https%3A%2F%2Fwww.datocms-assets.com%2F45680%2F1699418432-fine-tne-training-images-people-in-vr-headsets.png&w=3840&q=75)
Once the LoRA is trained, I can apply it to SDXL via OctoAI’s asset orchestrator: this lets us now generate images featuring the branded VR headset. Let’s take a look at the results. The difference is like night and day!
![OctoAI UI showing text to image prompts of people wearing a VR headset based on a custom asset OctoAI UI showing text to image prompts of people wearing a VR headset based on a custom asset](/_next/image/?url=https%3A%2F%2Fwww.datocms-assets.com%2F45680%2F1699418454-octoai-text-to-image-ui-showing-images-of-vr-headsets-from-prompt.png&w=3840&q=75)
You can train a new LoRA for each product that you want to showcase. I’ve trained a second one for the OctoAI shirt we used at the launch of the OctoAI compute service in June.
![OctoAI fine tune assets of Octonauts in OctoAI shirts OctoAI fine tune assets of Octonauts in OctoAI shirts](/_next/image/?url=https%3A%2F%2Fwww.datocms-assets.com%2F45680%2F1699418468-octoai-shirt-training-images-adults.png&w=3840&q=75)
The amazing thing is, even though this OctoAI shirt LoRA was only trained on adults, I can now (via the flexibility of SDXL) generate the shirt in kid’s sizes too! This is so much more powerful than performing manual background replacement.
![text to image GenAI with two children wearing OctoAI shirts based on custom assets text to image GenAI with two children wearing OctoAI shirts based on custom assets](/_next/image/?url=https%3A%2F%2Fwww.datocms-assets.com%2F45680%2F1699483427-ai-generated-black-children-wearing-an-octoai-shirt.png&w=3840&q=75)
![OctoAI Asset Library UI with two custom assets of VR headsets and the OctoAI shirt OctoAI Asset Library UI with two custom assets of VR headsets and the OctoAI shirt](/_next/image/?url=https%3A%2F%2Fwww.datocms-assets.com%2F45680%2F1699418488-octoai-asset-library-prodcut-ui-screen-shot-with-custom-assets.png&w=3840&q=75)
Power of the platform — mix and match leading GenAI models to build your experience
You may think that OctoAI only offers APIs to text to image models like SDXL, and that couldn’t be further from the truth! OctoAI offer an extensive array of other GenAI models that you can use, including the Llama 2 model family.
Specifically you can build very powerful workflows when you combine say a text to image model like SDXL with an LLM like Llama 2. For OctoStudio, I thought a Llama 2 would be really neat to rely upon in order to obtain background suggestions for product photography according to a given theme.
See how Llama 2 thinks fast on its feet when I ask it to generate 5 different backdrop suggestions for Holi, a “festival of colors” from the Indian subcontinent. Typically these are prompts I’d have to think up of and then manually enter into SDXL. By relying on Llama 2, I can quickly and easily perform an exploration of various generation ideas based on a single theme — Holi. These backdrop suggestions, as you can see, are quite on point. And this reliance on Llama 2 really accelerates the process of creating a gallery with minimal user intervention.
![OctoSutdio screen shot showing Llama 2 suggestions when an image is input OctoSutdio screen shot showing Llama 2 suggestions when an image is input](/_next/image/?url=https%3A%2F%2Fwww.datocms-assets.com%2F45680%2F1699418512-snapshot-of-llama-2-suggestions-in-octostudio.png&w=3840&q=75)
By composing with SDXL and Llama 2 I’ve created a unique “model cocktail” that can work across data of different modalities.
SDXL + LoRA lets us generate the initial set of pictures featuring the product worn by a specific model, which the user gets to specify (e.g. Indian male in his 30s).
Llama 2 then suggests different backgrounds to cycle through, based on a theme that the user specified, (e.g. “Holi”).
With that list of backgrounds suggestions and series of initial photos in hand, we perform image amplification via background replacement using a GenAI pipeline similar to one that Amazon or Google are using to perform image segmentation, and in-painting with SDXL and a depth ControlNet.
As a developer, you too can think of and chain together your unique model cocktail here for a highly tailored GenAI multimodal pipeline that works for your specific needs and for your product placement outcomes.
Truly unlocking GenAI — from 10s to 100s to 1000s of products
I wanted to not just show a one-off demo but really inspire developers to build tooling that can scale and serve to the most demanding e-commerce companies. When the cost of generating a highly custom photo drops to a fraction of a penny, this drastically changes the way we think of product photography.
But to take advantage of that low cost, and take product photography asset generation to another level (say an e-commerce giant wanting to offer this service to their 10s or 100s of thousands of retailers), you need a solid and scalable infrastructure to build on top of.
That’s what I wanted to showcase in action — the OctoShop being able to generate a gallery of dozens of high quality images in less than a minute. Mind you there are a lot of models involved here that have to be sequentially invoked too, so achieving this level of speed is nothing short of impressive. This all built on OctoAI’s deep expertise in AI systems, combined with extensive engineering work the team has done to ensure speed and reliability in GenAI model execution.
Check out the video I’ve recorded to get a sense of the blazing speed you’d be getting with OctoAI.
I’ll leave it to the developers out there and their unbounded imagination and creativity to build the next wave of e-commerce product photography tooling, I can’t wait to see what the future holds!
Get started today
You can sign up and start building on the OctoAI Image Gen Solution today.
You’re also welcome to join us on Discord to engage with the team and our community. We’ll use the Discord channel to share about upcoming features, promotions and competitions. Stay tuned to learn more, and I look forward to see the applications and imagery you build using GenAI.