We're supposed to be building robots and AI for the good of humankind, but scientists at MIT have pretty much been doing the opposite - they've built a new kind of AI with the sole purpose of generating the most frightening images ever.

Just in time for Halloween, the aptly named Nightmare Machine uses an algorithm that 'learns' what humans find scary, sinister, or just downright unnerving, and generates images based on what it thinks will freak us out the most.

"There have been a rising number of intellectuals, including Elon Musk and Stephen Hawking, raising alarms about the potential threat of superintelligent AI on humanity," one of the team, Pinar Yanardag Delul, told Digital Trends.

"In the spirit of Halloween and following the traditional MIT hack culture, we wanted to playfully commemorate humanity's fear of AI, which is a growing theme in popular culture."

Based on Google's DeepDream computer vision program, which uses a type of artificial neural network to create a dreamlike or hallucinogenic filter to run over regular images, the Nightmare Machine can create images according to a number of themes, such as "ghost town", "tentacle monster" and "slaughterhouse".

Basically, it learns what a haunted house, a toxic city, or a zombified human looks like, and applies this to innocuous images to make them horrifying.

"We [observed some] interesting outcomes," says one of the researchers, Manuel Cebrian. "Say we train a neural network on places, like a haunted house, and apply it to a person or group of people. The result is equally haunting."

So far, it's just been focussing on images of people and places, and starts by applying a scary filter based on what it's learned about what humans find scary. The public is then asked to vote on the generated images, so it can learn which are the most effective.

Here are some of the most effective scary faces:


And a few personal favourites:




Yep, that poor bastard is Kermit:


And a couple of places, first the Neuschwanstein Castle in Schwangau, Germany:


And MIT's Computer Science and Artificial Intelligence Laboratory, which is actually pretty weird on its own:


The tech isn't just there to scare people, though, the project also aims to get to the bottom of why humans fear the things they do, and if machines like robots or AI can somehow have a hand in alleviating that fear in the future.

"We aren't taking this too seriously, we want to have fun with it. But underneath is something very serious," Cebrian told Marcus Strom at The Sydney Morning Herald.

"Emotions are something that machines could learn very easily to instil in humans. If these could be positive emotions - trust, warmth - it could signal 'Work with me, I want to help you'."

Check out more of the Nightmare Machine's creations at their Instagram page, and rate the faces for yourself here.

I hope, for all our sakes, there aren't any clowns hidden in the mix…