Codementor Events

Image Aesthetic Assessment

Published Jul 15, 2017Last updated Sep 27, 2017
Image Aesthetic Assessment

"Beauty is really in the eye of the beholder"

Image aesthetics assessment is an attempt to define the beauty of an Image. While everyone has different tastes, there are universally accepted norms when it comes to beauty – things which everyone pretty much agrees are beautiful, like sunsets or sunrises over the mountains or the ocean.

Some of the visual features that come handy are

  • edge distributions,
  • color histogram,
  • Some photographic rules like rule of thirds also determines the beauty of an image.

Defining image quality with visual features like other manually curated features are limited in the scope.

The two photographer's story.

Great Shot!! So what?
Beautiful Image low quality Image

The Image is of the same place taken with different lightning, angle, adjusted contrast. And it is obvious that image on the left has better aesthetic attire.

Significance of Image Aesthetics

For a platform especially that serves media content, one of the crucial aspects is to show high-quality content. With social sites and the given ‘selfie’ trend, we are generating a huge amount of data in the form of either images or videos. Having a track on the quality will always be helpful.

Curated Content User Generated Content
Curated Content User Generated Content

Can we model such Human Perception?

Deep learning

The topic needs no introduction. It’s a revolution especially in the image classification domain since the last 5 years. With “Alexnet” winning the Image-Net competition, improving error rate with a huge margin acted as a spark in the field. Since then, CNN has many state of the arts on its name.

Network architecture of Alexnet.

Alexnet architecture

The first layer is input, where input is fed to the network. We can see their pooling operations, convolution operations finally followed by a fully connected layer and final softmax layer so that we get values as the probability for each class we label.

Fixed size input constraint

Input Layer
Input Layer Input image re-sized to 224 * 224 irrespective of original image shape.

We always resize the input feature vector. If the image is larger, image is cropped or pad image if image dimensions are smaller, to get a fixed size input to feed the network

The Mountains Qutub Minar
Mountains Qutub Minar

The above two images are beautiful in their original aspect ratio. What happens if we re-size the image to a fixed size of 224 * 224? Certainly, the image will loose all it’s original aesthetic value! From Landscape to Squared size. All damage is done. The original image composition is lost when an image is re-sized.

Demystifying the Network Architecture

Network Architecture

Let’s unveil the hidden layers! So, we can see that after the input, there are few layers of Operations. The operations are either Max-pooling or convolving with a filter i.e. Convolution. So why the fixed size of input is required at all then?
It’s because of the Fully Connected Layer just before the outputs. Fully Connected Layers are in the network for the non-linear combination of feature extracted before in convolution network.

Let's understand bit by bit.

Max Pooling

Max pooling are there for Down-sampling the feature space while maintaining the spatial information Max Pooling in action

Max Pooling

Spatial Pyramid Pooling

In spp, an image is divided into bins. Each bin is pooled in its turn. As the number of bins is fixed, we always get the Fixed Shape Output.

Spp operation in action

Spatial Pyramid Pooling

Spatial Pyramid Pooling

Spp Network Architecture

Spp Network Architecture

The first network is the traditional CNN, we can see the Max-pool layer just before the fully connected layer. In the second architecture, the last max pooling layer is replaced by a Spp layer. With the Fixed Bin size (1,2,4) we make sure that the fully connected layer gets the fixed shape input.

Spp Network Architecture

Training the Spp-Net

Training the Spp-Net on live-dataset , very small dataset, about 1K images total, model achieved the accuracy of 75% on training data, 83% of the test data.

Accuracy Training Loss
Spp-Net Accuracy Spp-Net Training Loss

Takeaways

With Spp in Network

  • Model learns the scale invariant feature like SIFT(traditional image processing algorithm).
  • One of the challenges in text classification with Deep learning is the fixed size feature vector representation of the sentence.

Interesting Results

After training model, I experimented with few results. These are the most interesting and promising results I found.

Blurred Cropped Image Complete Image
Blurred Image Complete Image

I recently came across this Photographer experience from being an amateur to professional.
He proved what difference a change in perspective can make. So, I decided to make my trained model judge for his efficacy.

Amateur Click? Yes, it is. Pro Click? I am already amazed.
Beautiful Image low quality Image

The aesthetic trained model has passed him with flying colors in Photographic skills. Well done Phillip Haumesser.

References

With that, I would like to wrap up. Any Questions?

The blog orginally appeared here
SPP Network gist

Discover and read more posts from Amit Kushwaha
get started
post comments1Reply
Jun Li
6 years ago

Quite good job. If it is possible, can you share me the training dataset, it will really great help, thanks a lot. My email is boostleej@gmail.com.