DEV Community

Cover image for Diversifying Emojis With AI
Jordan
Jordan

Posted on

Diversifying Emojis With AI

I've been advising GFXvs.com, a daily AI art battle with on-chain rewards. Sharing the daily battle across social media required some clever design. After several iterations the team landed on "spinners":

spinner that reveals two different ai generated artworks by rotating a bright green pixelated line in a circle, sweeping over the image in a perfectly endless loop

This design met the requirements of incorporating both images, but also established an unmistakably branded asset for people to collect. The motion catches eyes on social platforms but makes it difficult to say if your daily vote is going to the left or right image. The answer was to watermark the two contestants with emoji, which also brought a more playful feeling to the collectables and voting.

With all of the hard problems out of the way, it was time to indulgently bike-shed something that didn't really need fixing: how can we ensure the emojis appearing on the artworks are not only interesting, but also diverse? While I joke that it's not important, little details like this are what can make or break a series of digital collectables.

For the sake of numerology we decided to select 420 of the most popular and coded emoji from the current set of 3,782. By narrowing things down we had the freedom to pick and choose to meet our diversity requirements: an even spread of colors and categories.

Our first pass at the emoji dataset was something like this:

var emojis =  {
    "1": {
        "emoji": "🤣"
    },
    "2": {
        "emoji": "❤️"
    },
...
}
Enter fullscreen mode Exit fullscreen mode

Effective, but it didn't give us enough to work with. So we summoned the Cursor AI to tear through and update our data to look more like this:

        "6": {
            "emoji": "😇",
            "name": "Smiling Face with Halo",
            "category": "Smileys & Emotion",
            "unicode": "U+1F607",
            "color": "yellow"
        },
Enter fullscreen mode Exit fullscreen mode

Not perfect, but better than going through 420 emojis by hand! To help with the final sorting and selection, Cursor AI provided a python script that would console log the emojis by color and category, for easier sorting:

import json

# Load the JSON data from file with utf-8 encoding
with open('emojis.json', 'r', encoding='utf-8') as file:
    data = json.load(file)

# Dictionaries to count emojis of each color and category, and store the emojis
color_emojis = {}
category_emojis = {}
seen_emojis = set()
special_unicode_emojis = []
replacement_char_emojis = []

# Iterate through each emoji entry
for key, emoji_info in data['emojis'].items():
    emoji = emoji_info.get('emoji')
    unicode_repr = emoji_info.get('unicode', 'unknown')
    color = emoji_info.get('color', 'unknown')
    category = emoji_info.get('category', 'unknown')
    name = emoji_info.get('name', 'unknown')

    # Check for duplicates
    if emoji in seen_emojis:
        print(f"Duplicate emoji found: {emoji} (ID: {key})")
    else:
        seen_emojis.add(emoji)

    # Check for special Unicode characters
    if '2640' in unicode_repr or '2642' in unicode_repr:  # Unicode for ♀️ and ♂️ respectively
        special_unicode_emojis.append((emoji, unicode_repr))

    # Check for replacement character
    if '' in emoji:
        replacement_char_emojis.append((emoji, name))

    # Collect emojis for each color
    if color in color_emojis:
        color_emojis[color].append(emoji)
    else:
        color_emojis[color] = [emoji]

    # Collect emojis for each category
    if category in category_emojis:
        category_emojis[category].append(emoji)
    else:
        category_emojis[category] = [emoji]

# Sort and print the emojis for each color and category
print("Counts by Color:")
for color, emojis in sorted(color_emojis.items(), key=lambda item: len(item[1]), reverse=True):
    print(f"{color}: {len(emojis)} {' '.join(emojis)}")

print("\nCounts by Category:")
for category, emojis in sorted(category_emojis.items(), key=lambda item: len(item[1]), reverse=True):
    print(f"{category}: {len(emojis)} {' '.join(emojis)}")

# Print special Unicode emojis
if special_unicode_emojis:
    print("\nSpecial Unicode Emojis:")
    for emoji, unicode_repr in special_unicode_emojis:
        print(f"{emoji} with Unicode {unicode_repr}")

# Print emojis that resulted in the replacement character
if replacement_char_emojis:
    print("\nEmojis resulting in Replacement Character:")
    for emoji, name in replacement_char_emojis:
        print(f"{emoji} - {name}")
Enter fullscreen mode Exit fullscreen mode

The output allowed us to quickly iterate on the curation process, turning our previously jumbled emojis with duplicates and so on into something that soothed our detail oriented souls:

emojis in a terminal output sorted by color

emojis in a terminal output sorted by category

This diversity maximizes the interesting outcomes from creating the daily battle spinners. If you like AI artwork come join the fun at GFXvs.com. Spinners are minted as NFTs every day you vote, and one lucky winner gets the unique rare NFT of the day!

Top comments (0)