An artificial intelligence (AI) algorithm developed by scientists at Stanford University can detect sexual orientation based on a series of facial images with 91 percent accuracy.

In their paper, titled Deep Neural Networks are More Accurate than Humans at Detecting Sexual Orientation from Facial Images, researchers Michal Kosinski and Yilun Wang report that the algorithm can correctly distinguish between gay and straight persons. The software can correctly detect sexual orientation in men with a single facial image 81 percent of the time, and 74 percent of the time when the subjects are women. Human judges accurately determined a person's sexual orientation 61 percent of the time for men and 54 percent for women.

Accuracy climbed to 91 percent in men and 83 percent in women with five images.

Kosinski and Yilun applied their algorithm to more than 35,000 facial images uploaded to a U.S. dating website. The sample did not include black and ethnic minority faces. Bisexual people were not included.

“Consistent with the prenatal hormone theory of sexual orientation, gay men and women tended to have gender-atypical facial morphology, expression and grooming styles,” the authors wrote. “Average landmark locations revealed that gay men had narrower jaws and longer noses, while lesbians had larger jaws. Composite faces suggest that gay men had larger foreheads than heterosexual men, while lesbians had smaller foreheads than heterosexual women.”

The researchers warned that the technology has the potential to be abused.

“Given that companies and governments are increasingly using computer vision algorithms to detect people's intimate traits, our findings expose a threat to the privacy and safety of gay men and women,” they wrote.