# A Trip Through Time

Teja Aluru

> We made the first avatars in a WeWork with my friend Kalani, using old Python notebooks from when he first started getting into deep learning.

San Francisco, CA. March 11, 2022. When I joined Sapien, my first task was to create artwork for the first [passport NFT collection](/content/passport/index.html). While most NFT projects drop randomly generated, fairly homogenous collections, Sapien aspired to make each avatar highly individualized and meaningful. Unlike other projects, each person gets to be involved in the avatar creation process through selecting their historical figure as well as their avatar’s picture.

We made the first avatars in a WeWork with my friend Kalani, using old Python notebooks from when he first started getting into deep learning. There were two requirements - the collection needed to feature stylized figures from history and that they should look trippy. The collection was aptly named “A Trip Through Time.” The pipeline overall was fairly simple and relied on two pre-trained models, one for semantic segmentation and another one for style transfer.

First, the semantic segmentation model produces classifications for each pixel in an image (in this case determining if a pixel belongs to a person or the background). We use this to automatically remove the background from any images.

Second, the style transfer model was used to apply the styling for the images. The task of neural style transfer is to take the “style” of one image and apply it over to another by optimizing the statistics between two images. This allows you to replicate the styling of say Picasso onto your favorite picture. In our case, we used the Sapien logo to stylize the images of each historical figure. Our initial avatars looked like this.

## Reaching New Peaks

While the style and look certainly wasn’t the worst, the avatars still didn’t feel “special.” The colors weren’t bright, the images showed lots of negative space, and many avatars lost detail in their features. In order to resolve these issues, I went back to the drawing board.

I first pulled all Sapien assets from the company drive to see the stylization results for different variations of the logo. In addition, after some suggestions from our CMO, Hash, I pre-processed the avatars after the background removal to sharpen the details in some of the images. This led to some interesting results.

I personally liked the style on the right, but the team agreed that the middle result was best given it balanced the vibrancy of the colors with the preservation of the facial features.

## Smoothening the Experience

While we were all satisfied with the stylization in the middle, Hash found that the avatars didn’t pop quite as much when they were shrunk to thumbnail size for socials. He used Photoshop’s noise reduction tool to smooth out the image, and then increased the brightness and contrast of the image. This led to the following final avatar results shown below.

I didn’t quite know how Photoshop did it’s noise reduction, but from my best guess, it was using an [edge-preserving image smoothing technique](https://en.wikipedia.org/wiki/Edge-preserving_smoothing) Luckily, there was an [edge-preserving filter in OpenCV](https://docs.opencv.org/4.x/df/dac/group__photo__render.html#gafaee2977597029bc8e35da6e67bd31f7) that provided similar results to the Photoshop noise reduction. I was also able to automate the brightness/contrast adjustment with OpenCV functions.

If you like the art style and want to create your own, our passport sale starts March 14th for whitelisted members. Purchasers who participate in the sale will get access to their own historical figure stylized in the Sapien manner. For those interested in learning more about the passport and its utility, check out [Why NFT Passports?](/content/news/why-nft-passports/index.html) As opposed to other NFTs that simply sit in a wallet, these are works of technoart you can be proud of and use as your signature!

For those who made it to the end, this is some cool shiz I whipped up the other day 👀
