Emotapal
A library to pair emotions with colors
Install / Use
/learn @josh-ashkinaze/EmotapalREADME
EmotaPal
WARNING: As of September 20th, 2020 the package is depracated.
pip install emotapal
Table of Contents
About <a name = "about"></a>
An EmotaPal is a palette of words and colors.
Just as a 'color palette' describes the colors of some visual object, an 'emotion palette' describes the emotions felt from a visual object. An EmotaPal combines both pieces (visual and psychological) of information.
Core Data <a name = "data"></a>
Functionally, this library provides methods to associate emotions with colors through an EmotaPal object. That object relies on a KNN model which predicts emotions from colors. The model was trained on a dataset constructed by parsing the dominant color of 100 Google Image results for 264 emotions.
For more information on the data, please read here.
Use Cases <a name = "usecases"></a>
Maybe you are an artist and are deciding between what color palettes to use. This, in turn, could depend on the psychological associations a color palette provokes. EmotaPal's from_colors() constructor will return the emotions associated with colors in your color palettes.
Maybe you started a brewery and are interested in how regional companies are positioning themselves. EmotaPal's from_gimg() constructor will allow you to construct an EmotaPal from google images, so you can "scrape" the probable affective responses to your competitor's logos.
Usage <a name = "usage"></a>
There are 4 ways to construct an EmotaPal.
Constructing an EmotaPal
from emotapal import EmotaPal
e1 = EmotaPal().from_colors(color_list)
e2 = EmotaPal().from_image(some_image, ncolors)
e3 = EmotaPal().from_url(image_url, ncolors)
e4 = EmotaPal().from_gimg(query, nimages)
Constructing an EmotaPal from a list of colors.
"""
Params:
clrs (list): A list of colors, each element either an RGB tupple or hex string
topn (int, optional): Keep only the topn best (input color, emotion color) matches.
unique_words (bool, optional): Keep only the best (shortest distance) match if one emotion matches with
two colors.
"""
ep = EmotaPal(topn=100, unique_words=False).from_colors(clrs)
Constructing an EmotaPal from an image.
Note: Do not make ncolors too high or you'll pick up non-central colors of an image.
"""
Params:
img (image): An image object.
ncolors (int): Construct a palette from the topn most dominant colors of an image.
topn (int, optional): see above
unique_words (bool, optional): see above
"""
ep = EmotaPal(topn=100, unique_words=False).from_image(img, ncolors)
Constructing an EmotaPal from a url pointing to an image.
"""
Params:
url (str): A url pointing to an image.
ncolors (int): Construct a palette from the topn colors of an image.
topn (int, optional): see above
unique_words (bool, optional): see above
"""
ep = EmotaPal(topn=100, unique_words=False).from_url(url, ncolors)
Constructing an EmotaPal from a Google Images query.
"""
Params:
query (str): A Google Images query.
nimages (int): The number of images to scrape.
topn (int, optional): see above
unique_words (bool, optional): see above
"""
ep = EmotaPal(topn=100, unique_words=False).from_gimages(query, nimages)
EmotaPal information and methods
ep = EmotaPal().from_url(url)
Return the info of an EmotaPal.
An EmotaPal's info is a list of dictionaries, each element containing information on a color, its associated emotion, and the distance between the input color and emotion color. This dictionary is sorted by distance (ascending order), such that the first entry is the best match and last entry is worst match.
info = ep.info
Words
words = ep.words.text # return words of EmotaPal
sentiment = ep.words.sentiment # return sentiment of EmotaPal's words
Colors
rgbs = ep.colors.as_rgb # return colors as rgb values
hexs = ep.colors.as_hex # return colors as strings of hex values
ep.colors.display(save_img=False) # display color palette with option to save image
Related Skills
node-connect
347.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
