Great news, technophobes: Machines are now learning how to scare us. With the help of deep learning algorithms, an artificial intelligence project dubbed the Nightmare Machine is figuring out how to create the most horrifying human faces possible, and the results are just as disturbing as you might have hoped or feared.

“Warning: Images on this website are generated by deep learning algorithms and may not be suitable for all users,” reads a message on the Nightmare Machine webpage. And it isn’t wrong. The scariest faces produced by the Nightmare Machine so far look like an Instagram account from hell: eyes replaced with blackened sockets, skin seemingly flayed from bloodied faces, lips pulled ghoulishly back from the teeth of rotting corpses. But if we find the facial phantasmagoria dismaying, we have only ourselves to blame. After all, it learned everything it knows about horror by watching us.

The project was created by Pinar Yanardag, Manuel Cebrian and Iyad Rahwan, three researchers at the MIT Media Lab. The trio had previously met to discuss how artificial intelligence could be used to create positive emotional responses in people, perhaps by generating text and images. “A big theme in our research group is cooperation and, in particular, interaction between humans and machines,” Rahwan said. “We thought that the ability of machines to convey feelings of trust, of warmth, or distrust could play a major role in establishing cooperation between them.”

As Halloween approached, their thoughts turned to a more ominous question: Instead of learning how to build trust with humans, could the artificial intelligence learn how to inspire fear?

“Elon Musk said that with the development of AI, we are ‘summoning the demon,’” Rahwan said. “We wanted to playfully explore whether and how AI can indeed become a demon that can learn how to scare us, both by extracting features from scary images and subsequently refining it using crowd feedback.”

To create their own evolving digital horror show, the researchers first used hundreds of thousands of celebrity photos to teach an algorithm (called a deep convolutional generative adversarial network) to make faces. They then dropped a “hint of scariness” into the mix with another deep learning algorithm that had been trained on images of zombies. (A related “Haunted Places�� project uses a similar process to make international landmarks look scary, although adding algorithmic spookiness to buildings ultimately feels far less frightening than adding it to humans.)

If you load up the website and agree to help the researchers with the project, you’ll be asked to rate 10 algorithmically generated faces as either “scary” or “not scary.” The Nightmare Machine will then use your data to make its faces just a little bit more upsetting for the next person who comes along. So what has the Nightmare Machine learned after more than 300,000 evaluations? “Initial tallies reveal that humans quickly converge and find some of the images very scary and others not so much,” Yanardag said. “In terms of scariest faces, it seems like people find blood-covered faces more scary.”

Although there’s something particularly alarming about asking artificial intelligence to perfect the creation of a nightmare in human form, this isn’t the first time AI has been used to generate horror. Recently, “Impossible Things,” a horror film whose primary narrative elements were “co-written” with an AI that had been trained on the plots of thousands of other movies, was successfully crowdfunded on Kickstarter.

In a way, stories and images created by AI are a perfect match for horror. “Nowadays, nothing seems to frighten humanity more than runaway intelligent machines,” Yanardag said. “The rapid progress in the field of AI has people worried about everything from mass unemployment to the annihilation of the human race at the hand of evil robots.”

Although Yanardag noted that the faces generated by the Nightmare Machine are remarkably creepy, she said there’s still a lot of room for improvement. “There is extra information in how humans perceive horror that can be exploited to make even scarier faces or even personalized horror images where we tailor the generation process to the individual data,” she said. That’s right — not only can machines home in on what people in general find the most frightening, but with a bit more data, they can also become experts in scaring you specifically. It’s a concept eerily reminiscent of a recent episode of the sci-fi series “Black Mirror,” in which a young man playtests a virtual reality horror game only to realize that it’s combing through his memories to create personalized moments of terror.

We seem to be safe for the moment, however — the MIT team said it has no interest in taking artificially intelligent horror machines to the next level or exploring their darker possibilities. “We wanted to playfully commemorate humanity’s fear of AI, which is a growing theme in popular culture, but we currently have no plans to use the immense power of AI to scare people further,” Yanardag said. “The world is already pretty scary!”

This was an edition of If Then Next, a column that explores how algorithms intersect with culture and our everyday lives. Got feedback, suggestions or a news tip? Leave suggestions in the comments section or tweet to me @laura_hudson.