💄 Name-My-Lipstick: Where AI Crafts Stunning Names and Fabulous Ad Images

tcvieira
6 min readOct 30, 2023

Motivation

My wife is really into beauty cosmetic products and one of the things that got me wondering was how beauty brands come up with those captivating and stylish names for their lipstick shades. Ruby Woo, Viva Glam, Kinda Sex, All Fired Up…

Then I often found myself intrigued by the creativity and allure of lipstick names, particularly those from iconic brands like MAC Cosmetics.

The process of crafting the perfect lipstick name is a blend of art, marketing, and branding. If you’re not from a marketing or product background like me, this creative task might seem daunting.

But what if you could harness the power of Generative AI as leverage to create lipstick names that align with the MAC Cosmetics style?

Problem

How to generate names for lipsticks in the MAC cosmetics style from any color?

TL;DR

The code is available here and the app can be accessed on this link deployed on Streamlit Cloud.

Dataset

To solve this problem, I’d need as many lipstick names and color combinations as possible. Where to find them?

After much digging, including in official sources, I came upon the following collection:

2018 MAC Shade List from https://i.pinimg.com/originals/93/90/05/93900596abfce58764532f9e69bd57b9.png

Preprocessing

The first step was to slice the image into chunks based on the number of rows and columns.

For each chunk, I took the top right pixel with some padding to pick the chunk color. Then I ran OCR to extract the text from the chunk using EasyOCR and PyTesseract.

The final step was to generate a CSV with these data for later cleaning and support for prompt engineering.

preprocessing code can be found here.

RGB — Color Lookup Table

As the output from the preprocessing step, we have the dataframe as shown below.

head of the generated dataframe

As the final cleaned dataset, we got a CSV file with two columns: RGB values and lipstick name (the majority of them from EasyOCR). This dataset is used as a lookup table (like RAG 💋)for color similarity search over the original dataset.

Prompts

All prompts can be found here.

One thing that is interesting to mention is how similar colors were selected for the few-shot prompt.

FEW_SHOT_PROMPT_TEMPLATE = """
As a head of MAC cosmetic advertisement department and marketing expert,
Create only one lipstick name that is based on the pairs of RGB tuples color and lipstick name delimited by
<hex> and <name> tags below:

{examples}
<rgb>{color}<rgb>,

do not repeat any name from the examples
output only the new name between the <name> tag without the tag or any punctuation
"""

Color Similarity Search

Instead of using Euclidean distance to search for similar colors based on the user selection against the lookup table, I found out about CIELAB color space.

This color space approximates very closely the way humans perceive colors. So, why not use it? Cool!

For this task, I found a few Python libs that could be used. I chose the colorspacious lib.

Now we can say that we have a RAG like lookup table to enhance our few-shot prompt! Nice 👍

Streamlit App

The app was built with Streamlit and has the following controls on the sidebar:

  • Input to provide the OpenAI API key;
  • OpenAI model selection dropdown;
  • Toggle to enable the use of the LLM model to create the prompt for the DALLE2;
  • Slider to control the model temperature.

Rate limits may apply to new users and keys. The application makes 3 calls for each name generation and the initial limit for a new key for a new user is 3 rpm. As a result, a new OpenAI user account with a new key will only be able to perform one name creation request per minute. More info

After providing at least the OpenAI API key, the user should select a color from the color picker and click the button to generate the names.

Final Architecture

app architecture image

Results

Although gpt-4 generates far more appealing and creative names, I feel that the text-davinci-003 (instructGPT) model has a decent balance and was picked in most cases for evaluation.

One thing to notice is that fixed image prompt produced more consistent images based on the desired behavior.

All build and tests processing costs aprox. $30 on OpenAI API call.
Here are some of the best-generated images (DALLE-2) and names.

Fiery Red, Eletric Violet and Cherry Bomb
Flame Thrower, Violet Vixen and Lilac Petal

Here are some of the funny and not desirable image outputs, although with good names.

Blazin Sunset Rouge and Emerald Enchantment

Feel free to play with the app and create your lipstick names and ad images on this link deployed on Streamlit Cloud.

Improvements

  • Allow user to custom image prompt at runtime;
  • Do the reverse. Given a lipstick name generate the color;
  • Use DALLE-3 API (n̶o̶t̶ ̶a̶v̶a̶i̶l̶a̶b̶l̶e̶ ̶y̶e̶t̶) or other image GenAI to provide lettering and writing on the generated images;
  • Add support to run on a local LLM;
  • Add feedback feature for later RLHF pipeline implementation;
  • Collect more data from other brands.

Update (11/25/2023)

Here we have some images generated with DALLE-3

Acknowledgment

https://www.kagglex.org/ logo
https://www.kagglex.org/

I’d like to express appreciation to my mentor, Corey Levinson, for his support throughout this KaggleX Mentorship Program Cohort 3 journey so far. Our discussions and talks were quite fruitful, providing numerous ideas and enhancements for this project.

I’d also like to thank the entire KaggleX Mentorship Program team for their outstanding work in promoting knowledge and ensuring that everyone is represented in the field of data science.

Thanks to everyone who has made it this far and hope to see you again on the next project.

Feel free to reach out if you have any questions or feedback!

Linkedin

--

--