Preparing AI Art for Production at Scale w/ Python

Preparing AI Art for Production at Scale w/ Python

Images generated by GenAI are an incredible innovation, but they aren't automatically ready for product integration, especially if you are leveraing Print-On-Demand (POD) and Direct to Garment (DTG) printing services.

If you've ever delved into the world of AI-generated imagery, you know there's a substantial process that comes after the initial creation. This post will take you through the essential steps of post-processing to prepare your images for seamless application on your products.

Let’s look at a few of the key steps, and how to quickly achieve them.

You can find the code to accomplish these tasks on our public Github profile. Execute from command line. 

> py modify_images_for_product_creation.py "<image directory>"

GenAI Image Post-Processing and Transparency

Use good “Pre-Processing” to Make Life Simpler

Images should be generated to be relatively simple, and come on a solid color background to begin with. By starting with an easy image with a clean background you will save yourself a lot of work.

While we are going to dive far deeper into pre-processing later, and the use of StableDiffusion Inpainting, to start: we typically find that adding “2d vector art, plain white background” will get us something close to what we want on Midjourney, and we will refine from there. 

Scale the Image Using Stable Diffusion

For Direct-to-Garment (DTG) printing, you’ll want to have a sufficiently large image to have a high resolution final product. At Paws and Prints, we typically aim for images of at least 3,000 x 3,000 pixels, and often go higher depending on the complexity of the art.

The scaling process must be done in a large number of ways, but we ultimately decided we liked using Stable Diffusion. We use Automatic1111 as our interface for SD, and the ERSGAN_4x sampling method to process the images. This step needs to be first in order to avoid re-introducing errors during further steps. 

Reduce the Color Space

A typical image wil have ~16 million colors. At Paws and Prints, we reduce the color space to 4,096 colors. This step makes it significantly easier to get clean transparency and other post-processing steps done well. Flattening the color space also aids in DTGprinting. By removing subtle shading and artifacts you can  maintain crisp lines and consistent coloration. In short, you'll achieve a more professional and attractive result.

Transparentize the Background

Creating a transparent background is a vital step; without it you’ll only be selling white t-shirts! We user Python to identify the primary background colors and systematically remove them. This doesn't just involve the removal of the main background hue, but also the elimination of large contiguous areas sharing the same color.

Remove Fragment Pixels and Disconnected parts of the Image. 

Fragment pixels are loose, floating pixels that can be found on the transparent background after removing the primary background color. These stray fragments can disrupt the overall aesthetic of the image, make bounding poor on products like stickers, and make the image look less clean. 

Conclusion

Post-processing is more than a series of technical steps; it's an art form that requires attention to detail and an understanding of the tools at your disposal. By following these principles, you can transform your GenAI-generated images into stunning visuals ready to enhance your products.

Whether you're an experienced designer or just starting with GenAI, these guidelines offer a solid foundation for turning your creative visions into tangible assets. Stay tuned to Tech Tails for more insights into the fascinating world of GenAI and ecommerce.

Feel free to explore Paws And Prints Boutique for more on GenAI technology, advertising insights, and, of course, all things canine clothing.

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.