Teeming prisons are a hotbed of TB, the world's second deadliest communicable disease after COVID, according to the World Health Organization. Mozambique, a country of 32 million people, recorded about 120,000 infections last year.
Caused by a bacteria that most often affects the lungs, it infected more than 10 million people in 2022 and killed 1.3 million, according to WHO.
Almost one in four infections last year occurred in Africa.
In the sprawling courtyard of the maximum security jail in the Mozambican capital Maputo, an inmate in an orange T-shirt stood before a tripod with a wide white tablet.
Behind him, a doctor scoured a two-piece portable X-ray machine connected to an AI program that has been hailed as a breakthrough in the fight against tuberculosis.
"It processes it in real time, we have the results in less than five minutes," the doctor said.
The image popped on the computer of a technician sitting at a table outside a medical tent a few meters away, along with a diagnosis.
"Radiological signs suggestive of tuberculosis—negative," the message said.
The program is part of a large test run of the technology to scan all inmates at three prisons in Maputo. It is being conducted by a local non-profit organisation supported by the Stop TB Partnership, a UN-backed entity.
Early diagnosis is key to save lives and tackle the spread of the disease.
While a chronic cough is a hallmark of infection, people can also carry TB without showing symptoms. Prisons are a perfect breeding ground due to crammed cells and airborne transmission.
Traditional spit, skin or blood tests for TB involves visits to a lab and the results can take up to three days. The quickest time for reliable results is 24 hours.
'Great leap in technology'
The combination of AI and portable X-ray machines is faster and eliminates the need for visits to clinics and radiologists, who can be scarce in poor rural areas, said Stop TB's deputy head Suvanand Sahu.
"This is a great leap in technology," he said.
At the Maputo Provincial Penitentiary, prisoners testing positive are placed in isolation, locked in a quarantine room behind a rusty metal door.
Inside, about a dozen inmates wearing face masks sit on mattresses thrown on the ground. Clothing, blankets and other belongings hang from a line strung between two discolored blue pillars.
Serious cases are taken to a medical ward.
Mozambique's jails were about 50 percent over capacity in 2022, according to the UN.
"It's not easy to see your friends playing and walking there but you have to accept that I am sick," Kennet Fortune, an inmate who has spent 10 year behind bars for drug-related offenses, said pointing at the trees in the prison yard.
He is currently undergoing treatment and the process can take months. "When the time comes, I'll be out," he said.
A WHO report this month found that global deaths from tuberculosis dipped in 2022, showing progress towards eradicating the disease.
The UN health agency said 7.5 million people were diagnosed with TB in 2022—the highest figure since it began monitoring in 1995.
Sahu of Stop TB said he was hoping that the success of pilot programs could help get funding to scale up the use of AI in diagnosing tuberculosis.
"Only a few years ago, if I was to say in a meeting that we can bring X-rays to all communities and have them read by a artificial intelligence with no need for radiologists, they would have kicked me out of the room and told me to go write a sci-fi novel," he said.