It was December 31, 2014. In Shanghai, thousands flocked to the historic and picturesque Bund, where there had been reports a light show would take place to ring in the new year. Unfortunately, too many people had the same idea. A dangerously dense crowd formed, and at a viewing platform in Chen Yi Square overlooking the river, confusion and a lack of crowd control led to panic and eventually stampede. Within minutes, 36 people had been killed and another 49 had been injured in the crush.

Sadly, the 2014 stampede isn’t the only deadly crowd crush in China’s living memory. Eight children died in a school stampede in Hunan in 2009. Three died and many were injured in a 2007 crush during a Carrefour sale in Chongqing. 37 people were killed in a stampede during Lantern Festival celebrations in Beijing in 2004. In 1991, a deadly crush in Taiyuan killed over 100 people. Even Shanghai itself has experienced this before, havinglost at least 17 people in a stampede at a ferry terminal in 1987.

In other words: China’s crowds can be deadly. But the folks at Baidu’s Big Data Lab have a solution: data-crunching predictive A.I.

In a new academic paper, Baidu researchers detail a computer system that uses Baidu Maps data to predict areas where dangerous crowds could be forming, and warn people — users, authorities, or both — in advance.

Areas with spiking Baidu Map queries from users at nearby locations might be places where crowds are likely to form in the near future.

The basic idea is that these days, when people go somewhere, they tend to check out their route and their destination beforehand. Given that, Baidu researchers figured that areas with spiking Baidu Map queries from users at nearby locations might be places where crowds are likely to form in the near future. They studied mapping data from a number of high-density crowd events, including the 2014 stampede, and found that this was indeed the case. The team devised a method to crunch Baidu’s mapping query data in real time and output a warning if the number of queries on a single area from nearby locations crossed a specific threshold. Then, a machine learning system was implemented to help crunch historical data and make accurate predictions about future danger areas.

For the moment, this technology is still academic, although Baidu does have a functional system that you can watch in action right here. It hasn’t been implemented anywhere yet, but real-world implementation is the ultimate goal. “We believe the successful deployment of our method can bring many benefits to our society,” the paper concludes.

Alternative uses

Preventing deadly crushes and stampedes is a noble goal, but of course, it’s not the only potential application for this kind of technology.

First, there is tremendous commercial potential. In China especially, crowd management can be a big challenge at popular attractions like tourist sites, major events, and cultural areas like zoos and museums. Being able to anticipate crowding events before they happen could help businesses handle the crowds more effectively and efficiently, increasing customer satisfaction levels and (probably) revenues. For example, Baidu’s system could warn a theme park about an incoming spike of visitors early enough that the park could potentially reassign staff and perhaps even call in some help to ensure they can handle the extra visitors.

Baidu says it’s using the software only to monitor large-scale events for crowd crush danger.

For now, though, Baidu is “not pursuing anything related to commercial application,” according to Baidu rep Kaiser Kuo. The company isn’t ruling anything out in the future, but at present it’s strictly a research project that’s intended as a public service.

Of course, crowd prediction technology also has a variety of potential government applications. Some of them are innocuous; Baidu’s system might be able to help Chinese municipal authorities improve traffic by studying people’s movement patterns and predicting when the roads are about to get a surge of travel to a particular area. But this tech could also be used by authorities to stifle dissent by preventing large gatherings and protests before they happen. For example, if authorities saw a large group was about to gather in a public square and suspected it was related to some kind of political dissent, they could shut down public transit to the area, or simply dispatch large numbers of law enforcement to break things up before the protest gets started.

Whether that’s a bad thing depends on your point of view, of course. And authorities have a number of other ways that they can already monitor and track dissenters and protesters. But for now, it’s a moot point, as Baidu says it’s using the software only to monitor large-scale events for crowd crush danger.