Pyaesthetics logo.

pyaesthetics, a Python Package for Empirical Aesthetic Analysis

Gabrieli G., Scapin G., Esposito G.

Th empirical analyis of the Aesthetic of images of different types (e.g. websites, paintings, photgraphs, etc) relies on the analysis of different features estimated from the original images.

Here we propose pyaesthetics, a python package that implements methods for the estimation of different features from still images.

The package provides methods for the estimation of the visual complexity, symmetry, colorfulness, and brightness of an images, as well as method to study the ratio between the visual and textual areas of the image, presence of human faces, and distribution of different colors.

The package is free as both in free beers and freedom, allowing users to customize all the available features as well as to implement their own methods. Each feature estimation method is optimized to require the least amount of resources as well as minimizing the computation time.

The package is available on Github and the pypi package manager. For installation instructions, please visit either the Github page or use pip.

Below we'll show you two examples of usage of the package.

Websites' analysis

Pyaesthetics has been used to study the aesthetic judgments of still images of web pages. The full article is available online. Images of websites were analyzed using the package, and aesthetic judgments collected from 59 healthy participants. pyaesthetics was used to estimate different features, including symmetry, visual complexity (see image below), and colorfulness, among others.

An example of quadratic tree decomposition applied to still images of websites.

Results of the analysis allowed the understanding of which visual features of web pages are considered by users in their evaluation of the aesthetic appearance of the page.

Mona Lisa vs Caked Lisa

A cut from The Guardian reporting a news about the Mona Lisa Cake incident.

In May 2022 a man was arrested after he smeared the protective glass of Leonardo's famous panting with a cake.

Pictures of the Mona Lisa covered in Cake were taken by visitors of the Louvre Museum, and rapidly published online. As a way to showcase pyaesthetics capabilities, here we will see how to apply the package to rapidly extract features from images, and verify whether the cake-covered version of the painting, that we friendly called "Caked Lisa", have an higher aesthetic value as compared to the original painting.

Mona Lisa vs Caked Lisa.

To obtain an estimate of aesthetic judgments of Caked Lisa, we trained a Machine Learning Regressor to predict judgments of paintings from their aesthetic features. We trained the model on a freely available dataset of 39 paintings, each rated by 48 individuals. The model was then employed to generate an estimated rating for the Mona Lisa and the Caked Lisa.

Analysis' flowchart.

Four different features were extracted from each painting, namely Brightness, Visual Complexity, Symmetry, and Colorfulness. The 48 individual ratings were averaged to obtained a single rating per painting. In total, the analysis took less than 2 minutes (1 minute and 40 seconds) on a medium range laptop (Intel i7, Memory 16Gb, Linux Mint 20.3, Kernel: 5.4.0-113-generic). On average, the computation time to extract required features was about 2 seconds per image.

Stuff for nerds, feel free to scroll down

Some coding details. The full notebook is available at the end of this page.

The package can be imported using:

import pyaesthetics

The analysis of all the features can be done using:

pyaesthetics.analysis.analyzeImage(pathToImage, method="complete")

where pathToImage is the full path to the image you want to analyze.

Alternatively, method='fast' can be used to estimate a limited number of features, that should cover the majority of the use cases.

Single features can be esitmated using individual modulues. Please check the documentation for the full list of modules and methods.

And the winner is...

Results.

Results show that Caked Lisa was rated by the Machine Learning Regressor as slightly more appealing (estimated rating = 2.32) as compared to the original version of the painting (estimated rating = 2.26)

Results.

Disclaimer

This is just a sample usage of the library. Machine learning model was not optmized and accuracy not tested, and the images used were all drawn from different sources, as such they have diffferent size and resolutions.

We hope we have conviced you to give pyaesthetics a try. If you want to have a 1-to-1 chat with me, help in setting up the package, or if you want new features or help developing features extraction methods, get in touch with me using the buttons below.

Also, if you are looking to hire a post-doc to work in the field of neuroaesthetics, please contact me.

A special thank to GitGraken for having sponsored this work.

Don't forget to grab a sticker!


Downloads

If you want to download a copy of the poster, click on the download